]> git.ipfire.org Git - thirdparty/git.git/blame - t/t9130-git-svn-authors-file.sh
path.c: don't call the match function without value in trie_find()
[thirdparty/git.git] / t / t9130-git-svn-authors-file.sh
CommitLineData
d727f676
EW
1#!/bin/sh
2#
3# Copyright (c) 2008 Eric Wong
4#
5
6test_description='git svn authors file tests'
7
8. ./lib-git-svn.sh
9
10cat > svn-authors <<EOF
11aa = AAAAAAA AAAAAAA <aa@example.com>
12bb = BBBBBBB BBBBBBB <bb@example.com>
13EOF
14
15test_expect_success 'setup svnrepo' '
16 for i in aa bb cc dd
17 do
da083d68 18 svn_cmd mkdir -m $i --username $i "$svnrepo"/$i
d727f676
EW
19 done
20 '
21
22test_expect_success 'start import with incomplete authors file' '
ce14e0b2 23 test_must_fail git svn clone --authors-file=svn-authors "$svnrepo" x
d727f676
EW
24 '
25
26test_expect_success 'imported 2 revisions successfully' '
27 (
cff4243d 28 cd x &&
a4d4e32a
PK
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
d727f676
EW
35 )
36 '
37
38cat >> svn-authors <<EOF
39cc = CCCCCCC CCCCCCC <cc@example.com>
40dd = DDDDDDD DDDDDDD <dd@example.com>
41EOF
42
43test_expect_success 'continues to import once authors have been added' '
44 (
cff4243d 45 cd x &&
d727f676 46 git svn fetch --authors-file=../svn-authors &&
a4d4e32a
PK
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
d727f676
EW
53 )
54 '
55
56test_expect_success 'authors-file against globs' '
da083d68 57 svn_cmd mkdir -m globs --username aa \
d727f676
EW
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
61 do
62 branch="aa/branches/$i"
da083d68 63 svn_cmd mkdir -m "$branch" --username $i "$svnrepo/$branch"
d727f676
EW
64 done
65 '
66
67test_expect_success 'fetch fails on ee' '
ce14e0b2 68 ( cd aa-work && test_must_fail git svn fetch --authors-file=../svn-authors )
d727f676
EW
69 '
70
71tmp_config_get () {
f7e87141 72 git config --file=.git/svn/.metadata --get "$1"
d727f676
EW
73}
74
75test_expect_success 'failure happened without negative side effects' '
76 (
77 cd aa-work &&
a5c98ace
EP
78 test 6 -eq "$(tmp_config_get svn-remote.svn.branches-maxRev)" &&
79 test 6 -eq "$(tmp_config_get svn-remote.svn.tags-maxRev)"
d727f676
EW
80 )
81 '
82
83cat >> svn-authors <<EOF
84ee = EEEEEEE EEEEEEE <ee@example.com>
85EOF
86
87test_expect_success 'fetch continues after authors-file is fixed' '
88 (
89 cd aa-work &&
90 git svn fetch --authors-file=../svn-authors &&
a5c98ace
EP
91 test 8 -eq "$(tmp_config_get svn-remote.svn.branches-maxRev)" &&
92 test 8 -eq "$(tmp_config_get svn-remote.svn.tags-maxRev)"
d727f676
EW
93 )
94 '
95
b9f3560c 96test_expect_success !MINGW 'fresh clone with svn.authors-file in config' '
e2f8617b
EW
97 (
98 rm -r "$GIT_DIR" &&
99 test x = x"$(git config svn.authorsfile)" &&
e2f8617b 100 test_config="$HOME"/.gitconfig &&
1f5ad6b1 101 sane_unset GIT_DIR &&
e2f8617b
EW
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 &&
a4d4e32a
PK
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) &&
e2f8617b
EW
111 test $nr_rev -eq $nr_ex
112 )
113'
114
cb427e9e
AH
115cat >> svn-authors <<EOF
116ff = FFFFFFF FFFFFFF <>
117EOF
118
119test_expect_success 'authors-file imported user without email' '
120 svn_cmd mkdir -m aa/branches/ff --username ff "$svnrepo/aa/branches/ff" &&
121 (
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 <> "
126 )
127 '
128
e2f8617b
EW
129test_debug 'GIT_DIR=gitconfig.clone/.git git log'
130
d727f676 131test_done