Merge branch 'jn/maint-fix-pager' into maint
[git/mjg.git] / t / t9138-git-svn-authors-prog.sh
blob83cc5fc9d1a381ecd006fa0a203f22dea0825a82
1 #!/bin/sh
3 # Copyright (c) 2009 Eric Wong, Mark Lodato
6 test_description='git svn authors prog tests'
8 . ./lib-git-svn.sh
10 cat > svn-authors-prog <<'EOF'
11 #!/usr/bin/perl
12 $_ = shift;
13 if (s/-sub$//) {
14 print "$_ <$_\@sub.example.com>\n";
16 else {
17 print "$_ <$_\@example.com>\n";
19 EOF
20 chmod +x svn-authors-prog
22 cat > svn-authors <<'EOF'
23 ff = FFFFFFF FFFFFFF <fFf@other.example.com>
24 EOF
26 test_expect_success 'setup svnrepo' '
27 for i in aa bb cc-sub dd-sub ee-foo ff
29 svn mkdir -m $i --username $i "$svnrepo"/$i
30 done
33 test_expect_success 'import authors with prog and file' '
34 git svn clone --authors-prog=./svn-authors-prog \
35 --authors-file=svn-authors "$svnrepo" x
38 test_expect_success 'imported 6 revisions successfully' '
40 cd x
41 test "`git rev-list refs/remotes/git-svn | wc -l`" -eq 6
45 test_expect_success 'authors-prog ran correctly' '
47 cd x
48 git rev-list -1 --pretty=raw refs/remotes/git-svn~1 | \
49 grep "^author ee-foo <ee-foo@example\.com> " &&
50 git rev-list -1 --pretty=raw refs/remotes/git-svn~2 | \
51 grep "^author dd <dd@sub\.example\.com> " &&
52 git rev-list -1 --pretty=raw refs/remotes/git-svn~3 | \
53 grep "^author cc <cc@sub\.example\.com> " &&
54 git rev-list -1 --pretty=raw refs/remotes/git-svn~4 | \
55 grep "^author bb <bb@example\.com> " &&
56 git rev-list -1 --pretty=raw refs/remotes/git-svn~5 | \
57 grep "^author aa <aa@example\.com> "
61 test_expect_success 'authors-file overrode authors-prog' '
63 cd x
64 git rev-list -1 --pretty=raw refs/remotes/git-svn | \
65 grep "^author FFFFFFF FFFFFFF <fFf@other\.example\.com> "
69 git --git-dir=x/.git config --unset svn.authorsfile
70 git --git-dir=x/.git config --unset svn.authorsprog
72 test_expect_success 'authors-prog handled special characters in username' '
73 svn mkdir -m bad --username "xyz; touch evil" "$svnrepo"/bad &&
75 cd x &&
76 git svn --authors-prog=../svn-authors-prog fetch &&
77 git rev-list -1 --pretty=raw refs/remotes/git-svn |
78 grep "^author xyz; touch evil <xyz; touch evil@example\.com> " &&
79 ! test -f evil
83 test_done