config.mak.uname: remove obsolete SPARSE_FLAGS setting
[git/debian.git] / t / t9130-git-svn-authors-file.sh
blobcb764bcadc72cd954d3727f6fbc4d1e0d1fe6c46
1 #!/bin/sh
3 # Copyright (c) 2008 Eric Wong
6 test_description='git svn authors file tests'
8 . ./lib-git-svn.sh
10 cat > svn-authors <<EOF
11 aa = AAAAAAA AAAAAAA <aa@example.com>
12 bb = BBBBBBB BBBBBBB <bb@example.com>
13 EOF
15 test_expect_success 'setup svnrepo' '
16 for i in aa bb cc dd
18 svn_cmd mkdir -m $i --username $i "$svnrepo"/$i
19 done
22 test_expect_success 'start import with incomplete authors file' '
23 test_must_fail git svn clone --authors-file=svn-authors "$svnrepo" x
26 test_expect_success 'imported 2 revisions successfully' '
28 cd x &&
29 git rev-list refs/remotes/git-svn >actual &&
30 test_line_count = 2 actual &&
31 git rev-list -1 --pretty=raw refs/remotes/git-svn >actual &&
32 grep "^author BBBBBBB BBBBBBB <bb@example\.com> " actual &&
33 git rev-list -1 --pretty=raw refs/remotes/git-svn~1 >actual &&
34 grep "^author AAAAAAA AAAAAAA <aa@example\.com> " actual
38 cat >> svn-authors <<EOF
39 cc = CCCCCCC CCCCCCC <cc@example.com>
40 dd = DDDDDDD DDDDDDD <dd@example.com>
41 EOF
43 test_expect_success 'continues to import once authors have been added' '
45 cd x &&
46 git svn fetch --authors-file=../svn-authors &&
47 git rev-list refs/remotes/git-svn >actual &&
48 test_line_count = 4 actual &&
49 git rev-list -1 --pretty=raw refs/remotes/git-svn >actual &&
50 grep "^author DDDDDDD DDDDDDD <dd@example\.com> " actual &&
51 git rev-list -1 --pretty=raw refs/remotes/git-svn~1 >actual &&
52 grep "^author CCCCCCC CCCCCCC <cc@example\.com> " actual
56 test_expect_success 'authors-file against globs' '
57 svn_cmd mkdir -m globs --username aa \
58 "$svnrepo"/aa/trunk "$svnrepo"/aa/branches "$svnrepo"/aa/tags &&
59 git svn clone --authors-file=svn-authors -s "$svnrepo"/aa aa-work &&
60 for i in bb ee cc
62 branch="aa/branches/$i"
63 svn_cmd mkdir -m "$branch" --username $i "$svnrepo/$branch"
64 done
67 test_expect_success 'fetch fails on ee' '
68 ( cd aa-work && test_must_fail git svn fetch --authors-file=../svn-authors )
71 tmp_config_get () {
72 git config --file=.git/svn/.metadata --get "$1"
75 test_expect_success 'failure happened without negative side effects' '
77 cd aa-work &&
78 test 6 -eq "$(tmp_config_get svn-remote.svn.branches-maxRev)" &&
79 test 6 -eq "$(tmp_config_get svn-remote.svn.tags-maxRev)"
83 cat >> svn-authors <<EOF
84 ee = EEEEEEE EEEEEEE <ee@example.com>
85 EOF
87 test_expect_success 'fetch continues after authors-file is fixed' '
89 cd aa-work &&
90 git svn fetch --authors-file=../svn-authors &&
91 test 8 -eq "$(tmp_config_get svn-remote.svn.branches-maxRev)" &&
92 test 8 -eq "$(tmp_config_get svn-remote.svn.tags-maxRev)"
96 test_expect_success !MINGW 'fresh clone with svn.authors-file in config' '
98 rm -r "$GIT_DIR" &&
99 test x = x"$(git config svn.authorsfile)" &&
100 test_config="$HOME"/.gitconfig &&
101 sane_unset GIT_DIR &&
102 git config --global \
103 svn.authorsfile "$HOME"/svn-authors &&
104 test x"$HOME"/svn-authors = x"$(git config svn.authorsfile)" &&
105 git svn clone "$svnrepo" gitconfig.clone &&
106 cd gitconfig.clone &&
107 git log >actual &&
108 nr_ex=$(grep "^Author:.*example.com" actual | wc -l) &&
109 git rev-list HEAD >actual &&
110 nr_rev=$(wc -l <actual) &&
111 test $nr_rev -eq $nr_ex
115 cat >> svn-authors <<EOF
116 ff = FFFFFFF FFFFFFF <>
119 test_expect_success 'authors-file imported user without email' '
120 svn_cmd mkdir -m aa/branches/ff --username ff "$svnrepo/aa/branches/ff" &&
122 cd aa-work &&
123 git svn fetch --authors-file=../svn-authors &&
124 git rev-list -1 --pretty=raw refs/remotes/origin/ff | \
125 grep "^author FFFFFFF FFFFFFF <> "
129 test_debug 'GIT_DIR=gitconfig.clone/.git git log'
131 test_done