test: avoid pipes in git related commands for test

Avoid using pipes downstream of Git commands since the exit codes
of commands upstream of pipes get swallowed, thus potentially
hiding failure of those commands. Instead, capture Git command
output to a file and apply the downstream command(s) to that file.

Signed-off-by: Pratik Karki <predatoramigo@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Pratik Karki 2018-03-27 23:16:37 +05:45 committed by Junio C Hamano
parent d32eb83c1d
commit a4d4e32a70
15 changed files with 179 additions and 159 deletions

View File

@ -311,8 +311,8 @@ test_expect_success 'unpacking with --strict' '
rm -f .git/index && rm -f .git/index &&
tail -n 10 LIST | git update-index --index-info && tail -n 10 LIST | git update-index --index-info &&
ST=$(git write-tree) && ST=$(git write-tree) &&
PACK5=$( git rev-list --objects "$LIST" "$LI" "$ST" | \ git rev-list --objects "$LIST" "$LI" "$ST" >actual &&
git pack-objects test-5 ) && PACK5=$( git pack-objects test-5 <actual ) &&
PACK6=$( ( PACK6=$( (
echo "$LIST" echo "$LIST"
echo "$LI" echo "$LI"
@ -358,8 +358,8 @@ test_expect_success 'index-pack with --strict' '
rm -f .git/index && rm -f .git/index &&
tail -n 10 LIST | git update-index --index-info && tail -n 10 LIST | git update-index --index-info &&
ST=$(git write-tree) && ST=$(git write-tree) &&
PACK5=$( git rev-list --objects "$LIST" "$LI" "$ST" | \ git rev-list --objects "$LIST" "$LI" "$ST" >actual &&
git pack-objects test-5 ) && PACK5=$( git pack-objects test-5 <actual ) &&
PACK6=$( ( PACK6=$( (
echo "$LIST" echo "$LIST"
echo "$LI" echo "$LI"

View File

@ -690,8 +690,8 @@ test_expect_success C_LOCALE_OUTPUT 'fetch aligned output' '
test_commit looooooooooooong-tag && test_commit looooooooooooong-tag &&
( (
cd full-output && cd full-output &&
git -c fetch.output=full fetch origin 2>&1 | \ git -c fetch.output=full fetch origin >actual 2>&1 &&
grep -e "->" | cut -c 22- >../actual grep -e "->" actual | cut -c 22- >../actual
) && ) &&
cat >expect <<-\EOF && cat >expect <<-\EOF &&
master -> origin/master master -> origin/master
@ -705,8 +705,8 @@ test_expect_success C_LOCALE_OUTPUT 'fetch compact output' '
test_commit extraaa && test_commit extraaa &&
( (
cd compact && cd compact &&
git -c fetch.output=compact fetch origin 2>&1 | \ git -c fetch.output=compact fetch origin >actual 2>&1 &&
grep -e "->" | cut -c 22- >../actual grep -e "->" actual | cut -c 22- >../actual
) && ) &&
cat >expect <<-\EOF && cat >expect <<-\EOF &&
master -> origin/* master -> origin/*

View File

@ -21,8 +21,8 @@ test_expect_success \
test_expect_success \ test_expect_success \
'checking the commit' \ 'checking the commit' \
'git diff-tree -r -M --name-status HEAD^ HEAD | \ 'git diff-tree -r -M --name-status HEAD^ HEAD >actual &&
grep "^R100..*path0/COPYING..*path1/COPYING"' grep "^R100..*path0/COPYING..*path1/COPYING" actual'
test_expect_success \ test_expect_success \
'moving the file back into subdirectory' \ 'moving the file back into subdirectory' \
@ -35,8 +35,8 @@ test_expect_success \
test_expect_success \ test_expect_success \
'checking the commit' \ 'checking the commit' \
'git diff-tree -r -M --name-status HEAD^ HEAD | \ 'git diff-tree -r -M --name-status HEAD^ HEAD >actual &&
grep "^R100..*path1/COPYING..*path0/COPYING"' grep "^R100..*path1/COPYING..*path0/COPYING" actual'
test_expect_success \ test_expect_success \
'mv --dry-run does not move file' \ 'mv --dry-run does not move file' \
@ -122,10 +122,9 @@ test_expect_success \
test_expect_success \ test_expect_success \
'checking the commit' \ 'checking the commit' \
'git diff-tree -r -M --name-status HEAD^ HEAD | \ 'git diff-tree -r -M --name-status HEAD^ HEAD >actual &&
grep "^R100..*path0/COPYING..*path2/COPYING" && grep "^R100..*path0/COPYING..*path2/COPYING" actual &&
git diff-tree -r -M --name-status HEAD^ HEAD | \ grep "^R100..*path0/README..*path2/README" actual'
grep "^R100..*path0/README..*path2/README"'
test_expect_success \ test_expect_success \
'succeed when source is a prefix of destination' \ 'succeed when source is a prefix of destination' \
@ -141,10 +140,9 @@ test_expect_success \
test_expect_success \ test_expect_success \
'checking the commit' \ 'checking the commit' \
'git diff-tree -r -M --name-status HEAD^ HEAD | \ 'git diff-tree -r -M --name-status HEAD^ HEAD >actual &&
grep "^R100..*path2/COPYING..*path1/path2/COPYING" && grep "^R100..*path2/COPYING..*path1/path2/COPYING" actual &&
git diff-tree -r -M --name-status HEAD^ HEAD | \ grep "^R100..*path2/README..*path1/path2/README" actual'
grep "^R100..*path2/README..*path1/path2/README"'
test_expect_success \ test_expect_success \
'do not move directory over existing directory' \ 'do not move directory over existing directory' \

View File

@ -187,7 +187,8 @@ test_expect_success 'author information is preserved' '
test \$GIT_COMMIT != $(git rev-parse master) || \ test \$GIT_COMMIT != $(git rev-parse master) || \
echo Hallo" \ echo Hallo" \
preserved-author) && preserved-author) &&
test 1 = $(git rev-list --author="B V Uips" preserved-author | wc -l) git rev-list --author="B V Uips" preserved-author >actual &&
test_line_count = 1 actual
' '
test_expect_success "remove a certain author's commits" ' test_expect_success "remove a certain author's commits" '
@ -205,7 +206,8 @@ test_expect_success "remove a certain author's commits" '
cnt1=$(git rev-list master | wc -l) && cnt1=$(git rev-list master | wc -l) &&
cnt2=$(git rev-list removed-author | wc -l) && cnt2=$(git rev-list removed-author | wc -l) &&
test $cnt1 -eq $(($cnt2 + 1)) && test $cnt1 -eq $(($cnt2 + 1)) &&
test 0 = $(git rev-list --author="B V Uips" removed-author | wc -l) git rev-list --author="B V Uips" removed-author >actual &&
test_line_count = 0 actual
' '
test_expect_success 'barf on invalid name' ' test_expect_success 'barf on invalid name' '
@ -258,7 +260,8 @@ test_expect_success 'Subdirectory filter with disappearing trees' '
git commit -m "Re-adding foo" && git commit -m "Re-adding foo" &&
git filter-branch -f --subdirectory-filter foo && git filter-branch -f --subdirectory-filter foo &&
test $(git rev-list master | wc -l) = 3 git rev-list master >actual &&
test_line_count = 3 actual
' '
test_expect_success 'Tag name filtering retains tag message' ' test_expect_success 'Tag name filtering retains tag message' '

View File

@ -33,8 +33,8 @@ test_expect_success 'init and fetch a moved directory' '
git svn fetch -i thunk && git svn fetch -i thunk &&
test "$(git rev-parse --verify refs/remotes/thunk@2)" \ test "$(git rev-parse --verify refs/remotes/thunk@2)" \
= "$(git rev-parse --verify refs/remotes/thunk~1)" && = "$(git rev-parse --verify refs/remotes/thunk~1)" &&
test "$(git cat-file blob refs/remotes/thunk:readme |\ git cat-file blob refs/remotes/thunk:readme >actual &&
sed -n -e "3p")" = goodbye && test "$(sed -n -e "3p" actual)" = goodbye &&
test -z "$(git config --get svn-remote.svn.fetch \ test -z "$(git config --get svn-remote.svn.fetch \
"^trunk:refs/remotes/thunk@2$")" "^trunk:refs/remotes/thunk@2$")"
' '
@ -48,8 +48,8 @@ test_expect_success 'init and fetch from one svn-remote' '
git svn fetch -i svn/thunk && git svn fetch -i svn/thunk &&
test "$(git rev-parse --verify refs/remotes/svn/trunk)" \ test "$(git rev-parse --verify refs/remotes/svn/trunk)" \
= "$(git rev-parse --verify refs/remotes/svn/thunk~1)" && = "$(git rev-parse --verify refs/remotes/svn/thunk~1)" &&
test "$(git cat-file blob refs/remotes/svn/thunk:readme |\ git cat-file blob refs/remotes/svn/thunk:readme >actual &&
sed -n -e "3p")" = goodbye test "$(sed -n -e "3p" actual)" = goodbye
' '
test_expect_success 'follow deleted parent' ' test_expect_success 'follow deleted parent' '
@ -107,7 +107,8 @@ test_expect_success 'follow deleted directory' '
git svn init --minimize-url -i glob "$svnrepo"/glob && git svn init --minimize-url -i glob "$svnrepo"/glob &&
git svn fetch -i glob && git svn fetch -i glob &&
test "$(git cat-file blob refs/remotes/glob:blob/bye)" = hi && test "$(git cat-file blob refs/remotes/glob:blob/bye)" = hi &&
test "$(git ls-tree refs/remotes/glob | wc -l )" -eq 1 git ls-tree refs/remotes/glob >actual &&
test_line_count = 1 actual
' '
# ref: r9270 of the Subversion repository: (http://svn.collab.net/repos/svn) # ref: r9270 of the Subversion repository: (http://svn.collab.net/repos/svn)
@ -204,8 +205,9 @@ test_expect_success "follow-parent is atomic" '
test_expect_success "track multi-parent paths" ' test_expect_success "track multi-parent paths" '
svn_cmd cp -m "resurrect /glob" "$svnrepo"/r9270 "$svnrepo"/glob && svn_cmd cp -m "resurrect /glob" "$svnrepo"/r9270 "$svnrepo"/glob &&
git svn multi-fetch && git svn multi-fetch &&
test $(git cat-file commit refs/remotes/glob | \ git cat-file commit refs/remotes/glob >actual &&
grep "^parent " | wc -l) -eq 2 grep "^parent " actual >actual2 &&
test_line_count = 2 actual2
' '
test_expect_success "multi-fetch continues to work" " test_expect_success "multi-fetch continues to work" "

View File

@ -47,8 +47,8 @@ test_expect_success 'test refspec globbing' '
git config --add svn-remote.svn.tags\ git config --add svn-remote.svn.tags\
"tags/*/src/a:refs/remotes/tags/*" && "tags/*/src/a:refs/remotes/tags/*" &&
git svn multi-fetch && git svn multi-fetch &&
git log --pretty=oneline refs/remotes/tags/end | \ git log --pretty=oneline refs/remotes/tags/end >actual &&
sed -e "s/^.\{41\}//" > output.end && sed -e "s/^.\{41\}//" actual >output.end &&
test_cmp expect.end output.end && test_cmp expect.end output.end &&
test "$(git rev-parse refs/remotes/tags/end~1)" = \ test "$(git rev-parse refs/remotes/tags/end~1)" = \
"$(git rev-parse refs/remotes/branches/start)" && "$(git rev-parse refs/remotes/branches/start)" &&
@ -75,14 +75,16 @@ test_expect_success 'test left-hand-side only globbing' '
svn_cmd commit -m "try to try" svn_cmd commit -m "try to try"
) && ) &&
git svn fetch two && git svn fetch two &&
test $(git rev-list refs/remotes/two/tags/end | wc -l) -eq 6 && git rev-list refs/remotes/two/tags/end >actual &&
test $(git rev-list refs/remotes/two/branches/start | wc -l) -eq 3 && test_line_count = 6 actual &&
git rev-list refs/remotes/two/branches/start >actual &&
test_line_count = 3 actual &&
test $(git rev-parse refs/remotes/two/branches/start~2) = \ test $(git rev-parse refs/remotes/two/branches/start~2) = \
$(git rev-parse refs/remotes/two/trunk) && $(git rev-parse refs/remotes/two/trunk) &&
test $(git rev-parse refs/remotes/two/tags/end~3) = \ test $(git rev-parse refs/remotes/two/tags/end~3) = \
$(git rev-parse refs/remotes/two/branches/start) && $(git rev-parse refs/remotes/two/branches/start) &&
git log --pretty=oneline refs/remotes/two/tags/end | \ git log --pretty=oneline refs/remotes/two/tags/end >actual &&
sed -e "s/^.\{41\}//" > output.two && sed -e "s/^.\{41\}//" actual >output.two &&
test_cmp expect.two output.two test_cmp expect.two output.two
' '

View File

@ -47,8 +47,8 @@ test_expect_success 'test refspec globbing' '
git config --add svn-remote.svn.tags\ git config --add svn-remote.svn.tags\
"tags/*/src/a:refs/remotes/tags/*" && "tags/*/src/a:refs/remotes/tags/*" &&
git svn multi-fetch && git svn multi-fetch &&
git log --pretty=oneline refs/remotes/tags/end | \ git log --pretty=oneline refs/remotes/tags/end >actual &&
sed -e "s/^.\{41\}//" > output.end && sed -e "s/^.\{41\}//" actual >output.end &&
test_cmp expect.end output.end && test_cmp expect.end output.end &&
test "$(git rev-parse refs/remotes/tags/end~1)" = \ test "$(git rev-parse refs/remotes/tags/end~1)" = \
"$(git rev-parse refs/remotes/branches/v1/start)" && "$(git rev-parse refs/remotes/branches/v1/start)" &&
@ -75,14 +75,16 @@ test_expect_success 'test left-hand-side only globbing' '
svn_cmd commit -m "try to try" svn_cmd commit -m "try to try"
) && ) &&
git svn fetch two && git svn fetch two &&
test $(git rev-list refs/remotes/two/tags/end | wc -l) -eq 6 && git rev-list refs/remotes/two/tags/end >actual &&
test $(git rev-list refs/remotes/two/branches/v1/start | wc -l) -eq 3 && test_line_count = 6 actual &&
git rev-list refs/remotes/two/branches/v1/start >actual &&
test_line_count = 3 actual &&
test $(git rev-parse refs/remotes/two/branches/v1/start~2) = \ test $(git rev-parse refs/remotes/two/branches/v1/start~2) = \
$(git rev-parse refs/remotes/two/trunk) && $(git rev-parse refs/remotes/two/trunk) &&
test $(git rev-parse refs/remotes/two/tags/end~3) = \ test $(git rev-parse refs/remotes/two/tags/end~3) = \
$(git rev-parse refs/remotes/two/branches/v1/start) && $(git rev-parse refs/remotes/two/branches/v1/start) &&
git log --pretty=oneline refs/remotes/two/tags/end | \ git log --pretty=oneline refs/remotes/two/tags/end >actual &&
sed -e "s/^.\{41\}//" > output.two && sed -e "s/^.\{41\}//" actual >output.two &&
test_cmp expect.two output.two test_cmp expect.two output.two
' '
cat > expect.four <<EOF cat > expect.four <<EOF
@ -124,14 +126,16 @@ test_expect_success 'test another branch' '
git config --add svn-remote.four.tags \ git config --add svn-remote.four.tags \
"tags/*:refs/remotes/four/tags/*" && "tags/*:refs/remotes/four/tags/*" &&
git svn fetch four && git svn fetch four &&
test $(git rev-list refs/remotes/four/tags/next | wc -l) -eq 5 && git rev-list refs/remotes/four/tags/next >actual &&
test $(git rev-list refs/remotes/four/branches/v2/start | wc -l) -eq 3 && test_line_count = 5 actual &&
git rev-list refs/remotes/four/branches/v2/start >actual &&
test_line_count = 3 actual &&
test $(git rev-parse refs/remotes/four/branches/v2/start~2) = \ test $(git rev-parse refs/remotes/four/branches/v2/start~2) = \
$(git rev-parse refs/remotes/four/trunk) && $(git rev-parse refs/remotes/four/trunk) &&
test $(git rev-parse refs/remotes/four/tags/next~2) = \ test $(git rev-parse refs/remotes/four/tags/next~2) = \
$(git rev-parse refs/remotes/four/branches/v2/start) && $(git rev-parse refs/remotes/four/branches/v2/start) &&
git log --pretty=oneline refs/remotes/four/tags/next | \ git log --pretty=oneline refs/remotes/four/tags/next >actual &&
sed -e "s/^.\{41\}//" > output.four && sed -e "s/^.\{41\}//" actual >output.four &&
test_cmp expect.four output.four test_cmp expect.four output.four
' '

View File

@ -21,37 +21,37 @@ uuid=161ce429-a9dd-4828-af4a-52023f968c89
bar_url=http://mayonaise/svnrepo/bar bar_url=http://mayonaise/svnrepo/bar
test_expect_success 'verify metadata for /bar' " test_expect_success 'verify metadata for /bar' "
git cat-file commit refs/remotes/bar | \ git cat-file commit refs/remotes/bar >actual &&
grep '^git-svn-id: $bar_url@12 $uuid$' && grep '^git-svn-id: $bar_url@12 $uuid$' actual &&
git cat-file commit refs/remotes/bar~1 | \ git cat-file commit refs/remotes/bar~1 >actual &&
grep '^git-svn-id: $bar_url@11 $uuid$' && grep '^git-svn-id: $bar_url@11 $uuid$' actual &&
git cat-file commit refs/remotes/bar~2 | \ git cat-file commit refs/remotes/bar~2 >actual &&
grep '^git-svn-id: $bar_url@10 $uuid$' && grep '^git-svn-id: $bar_url@10 $uuid$' actual &&
git cat-file commit refs/remotes/bar~3 | \ git cat-file commit refs/remotes/bar~3 >actual &&
grep '^git-svn-id: $bar_url@9 $uuid$' && grep '^git-svn-id: $bar_url@9 $uuid$' actual &&
git cat-file commit refs/remotes/bar~4 | \ git cat-file commit refs/remotes/bar~4 >actual &&
grep '^git-svn-id: $bar_url@6 $uuid$' && grep '^git-svn-id: $bar_url@6 $uuid$' actual &&
git cat-file commit refs/remotes/bar~5 | \ git cat-file commit refs/remotes/bar~5 >actual &&
grep '^git-svn-id: $bar_url@1 $uuid$' grep '^git-svn-id: $bar_url@1 $uuid$' actual
" "
e_url=http://mayonaise/svnrepo/dir/a/b/c/d/e e_url=http://mayonaise/svnrepo/dir/a/b/c/d/e
test_expect_success 'verify metadata for /dir/a/b/c/d/e' " test_expect_success 'verify metadata for /dir/a/b/c/d/e' "
git cat-file commit refs/remotes/e | \ git cat-file commit refs/remotes/e >actual &&
grep '^git-svn-id: $e_url@1 $uuid$' grep '^git-svn-id: $e_url@1 $uuid$' actual
" "
dir_url=http://mayonaise/svnrepo/dir dir_url=http://mayonaise/svnrepo/dir
test_expect_success 'verify metadata for /dir' " test_expect_success 'verify metadata for /dir' "
git cat-file commit refs/remotes/dir | \ git cat-file commit refs/remotes/dir >actual &&
grep '^git-svn-id: $dir_url@2 $uuid$' && grep '^git-svn-id: $dir_url@2 $uuid$' actual &&
git cat-file commit refs/remotes/dir~1 | \ git cat-file commit refs/remotes/dir~1 >actual &&
grep '^git-svn-id: $dir_url@1 $uuid$' grep '^git-svn-id: $dir_url@1 $uuid$' actual
" "
test_expect_success 'find commit based on SVN revision number' " test_expect_success 'find commit based on SVN revision number' "
git svn find-rev r12 | git svn find-rev r12 >actual &&
grep $(git rev-parse HEAD) grep $(git rev-parse HEAD) actual
" "
test_expect_success 'empty rebase' " test_expect_success 'empty rebase' "

View File

@ -20,32 +20,32 @@ uuid=161ce429-a9dd-4828-af4a-52023f968c89
bar_url=http://mayonaise/svnrepo/bar bar_url=http://mayonaise/svnrepo/bar
test_expect_success 'verify metadata for /bar' " test_expect_success 'verify metadata for /bar' "
git cat-file commit refs/remotes/bar | \ git cat-file commit refs/remotes/bar >actual &&
grep '^git-svn-id: $bar_url@12 $uuid$' && grep '^git-svn-id: $bar_url@12 $uuid$' actual &&
git cat-file commit refs/remotes/bar~1 | \ git cat-file commit refs/remotes/bar~1 >actual &&
grep '^git-svn-id: $bar_url@11 $uuid$' && grep '^git-svn-id: $bar_url@11 $uuid$' actual &&
git cat-file commit refs/remotes/bar~2 | \ git cat-file commit refs/remotes/bar~2 >actual &&
grep '^git-svn-id: $bar_url@10 $uuid$' && grep '^git-svn-id: $bar_url@10 $uuid$' actual &&
git cat-file commit refs/remotes/bar~3 | \ git cat-file commit refs/remotes/bar~3 >actual &&
grep '^git-svn-id: $bar_url@9 $uuid$' && grep '^git-svn-id: $bar_url@9 $uuid$' actual &&
git cat-file commit refs/remotes/bar~4 | \ git cat-file commit refs/remotes/bar~4 >actual &&
grep '^git-svn-id: $bar_url@6 $uuid$' && grep '^git-svn-id: $bar_url@6 $uuid$' actual &&
git cat-file commit refs/remotes/bar~5 | \ git cat-file commit refs/remotes/bar~5 >actual &&
grep '^git-svn-id: $bar_url@1 $uuid$' grep '^git-svn-id: $bar_url@1 $uuid$' actual
" "
e_url=http://mayonaise/svnrepo/dir/a/b/c/d/e e_url=http://mayonaise/svnrepo/dir/a/b/c/d/e
test_expect_success 'verify metadata for /dir/a/b/c/d/e' " test_expect_success 'verify metadata for /dir/a/b/c/d/e' "
git cat-file commit refs/remotes/e | \ git cat-file commit refs/remotes/e >actual &&
grep '^git-svn-id: $e_url@1 $uuid$' grep '^git-svn-id: $e_url@1 $uuid$' actual
" "
dir_url=http://mayonaise/svnrepo/dir dir_url=http://mayonaise/svnrepo/dir
test_expect_success 'verify metadata for /dir' " test_expect_success 'verify metadata for /dir' "
git cat-file commit refs/remotes/dir | \ git cat-file commit refs/remotes/dir >actual &&
grep '^git-svn-id: $dir_url@2 $uuid$' && grep '^git-svn-id: $dir_url@2 $uuid$' actual &&
git cat-file commit refs/remotes/dir~1 | \ git cat-file commit refs/remotes/dir~1 >actual &&
grep '^git-svn-id: $dir_url@1 $uuid$' grep '^git-svn-id: $dir_url@1 $uuid$' actual
" "
test_done test_done

View File

@ -68,7 +68,8 @@ test_debug 'gitk --all & sleep 1'
test_expect_success 'verify pre-merge ancestry' " test_expect_success 'verify pre-merge ancestry' "
test x\$(git rev-parse --verify refs/heads/svn^2) = \ test x\$(git rev-parse --verify refs/heads/svn^2) = \
x\$(git rev-parse --verify refs/heads/merge) && x\$(git rev-parse --verify refs/heads/merge) &&
git cat-file commit refs/heads/svn^ | grep '^friend$' git cat-file commit refs/heads/svn^ >actual &&
grep '^friend$' actual
" "
test_expect_success 'git svn dcommit merges' " test_expect_success 'git svn dcommit merges' "
@ -82,12 +83,13 @@ test_expect_success 'verify post-merge ancestry' "
x\$(git rev-parse --verify refs/remotes/origin/trunk) && x\$(git rev-parse --verify refs/remotes/origin/trunk) &&
test x\$(git rev-parse --verify refs/heads/svn^2) = \ test x\$(git rev-parse --verify refs/heads/svn^2) = \
x\$(git rev-parse --verify refs/heads/merge) && x\$(git rev-parse --verify refs/heads/merge) &&
git cat-file commit refs/heads/svn^ | grep '^friend$' git cat-file commit refs/heads/svn^ >actual &&
grep '^friend$' actual
" "
test_expect_success 'verify merge commit message' " test_expect_success 'verify merge commit message' "
git rev-list --pretty=raw -1 refs/heads/svn | \ git rev-list --pretty=raw -1 refs/heads/svn >actual &&
grep \" Merge branch 'merge' into svn\" grep \" Merge branch 'merge' into svn\" actual
" "
test_done test_done

View File

@ -26,11 +26,12 @@ test_expect_success 'start import with incomplete authors file' '
test_expect_success 'imported 2 revisions successfully' ' test_expect_success 'imported 2 revisions successfully' '
( (
cd x cd x
test "$(git rev-list refs/remotes/git-svn | wc -l)" -eq 2 && git rev-list refs/remotes/git-svn >actual &&
git rev-list -1 --pretty=raw refs/remotes/git-svn | \ test_line_count = 2 actual &&
grep "^author BBBBBBB BBBBBBB <bb@example\.com> " && git rev-list -1 --pretty=raw refs/remotes/git-svn >actual &&
git rev-list -1 --pretty=raw refs/remotes/git-svn~1 | \ grep "^author BBBBBBB BBBBBBB <bb@example\.com> " actual &&
grep "^author AAAAAAA AAAAAAA <aa@example\.com> " git rev-list -1 --pretty=raw refs/remotes/git-svn~1 >actual &&
grep "^author AAAAAAA AAAAAAA <aa@example\.com> " actual
) )
' '
@ -43,11 +44,12 @@ test_expect_success 'continues to import once authors have been added' '
( (
cd x cd x
git svn fetch --authors-file=../svn-authors && git svn fetch --authors-file=../svn-authors &&
test "$(git rev-list refs/remotes/git-svn | wc -l)" -eq 4 && git rev-list refs/remotes/git-svn >actual &&
git rev-list -1 --pretty=raw refs/remotes/git-svn | \ test_line_count = 4 actual &&
grep "^author DDDDDDD DDDDDDD <dd@example\.com> " && git rev-list -1 --pretty=raw refs/remotes/git-svn >actual &&
git rev-list -1 --pretty=raw refs/remotes/git-svn~1 | \ grep "^author DDDDDDD DDDDDDD <dd@example\.com> " actual &&
grep "^author CCCCCCC CCCCCCC <cc@example\.com> " git rev-list -1 --pretty=raw refs/remotes/git-svn~1 >actual &&
grep "^author CCCCCCC CCCCCCC <cc@example\.com> " actual
) )
' '
@ -102,8 +104,10 @@ test_expect_success !MINGW 'fresh clone with svn.authors-file in config' '
test x"$HOME"/svn-authors = x"$(git config svn.authorsfile)" && test x"$HOME"/svn-authors = x"$(git config svn.authorsfile)" &&
git svn clone "$svnrepo" gitconfig.clone && git svn clone "$svnrepo" gitconfig.clone &&
cd gitconfig.clone && cd gitconfig.clone &&
nr_ex=$(git log | grep "^Author:.*example.com" | wc -l) && git log >actual &&
nr_rev=$(git rev-list HEAD | wc -l) && nr_ex=$(grep "^Author:.*example.com" actual | wc -l) &&
git rev-list HEAD >actual &&
nr_rev=$(wc -l <actual) &&
test $nr_rev -eq $nr_ex test $nr_rev -eq $nr_ex
) )
' '

View File

@ -37,31 +37,32 @@ test_expect_success 'import authors with prog and file' '
test_expect_success 'imported 6 revisions successfully' ' test_expect_success 'imported 6 revisions successfully' '
( (
cd x cd x
test "$(git rev-list refs/remotes/git-svn | wc -l)" -eq 6 git rev-list refs/remotes/git-svn >actual &&
test_line_count = 6 actual
) )
' '
test_expect_success 'authors-prog ran correctly' ' test_expect_success 'authors-prog ran correctly' '
( (
cd x cd x
git rev-list -1 --pretty=raw refs/remotes/git-svn~1 | \ git rev-list -1 --pretty=raw refs/remotes/git-svn~1 >actual &&
grep "^author ee-foo <ee-foo@example\.com> " && grep "^author ee-foo <ee-foo@example\.com> " actual &&
git rev-list -1 --pretty=raw refs/remotes/git-svn~2 | \ git rev-list -1 --pretty=raw refs/remotes/git-svn~2 >actual &&
grep "^author dd <dd@sub\.example\.com> " && grep "^author dd <dd@sub\.example\.com> " actual &&
git rev-list -1 --pretty=raw refs/remotes/git-svn~3 | \ git rev-list -1 --pretty=raw refs/remotes/git-svn~3 >actual &&
grep "^author cc <cc@sub\.example\.com> " && grep "^author cc <cc@sub\.example\.com> " actual &&
git rev-list -1 --pretty=raw refs/remotes/git-svn~4 | \ git rev-list -1 --pretty=raw refs/remotes/git-svn~4 >actual &&
grep "^author bb <bb@example\.com> " && grep "^author bb <bb@example\.com> " actual &&
git rev-list -1 --pretty=raw refs/remotes/git-svn~5 | \ git rev-list -1 --pretty=raw refs/remotes/git-svn~5 >actual &&
grep "^author aa <aa@example\.com> " grep "^author aa <aa@example\.com> " actual
) )
' '
test_expect_success 'authors-file overrode authors-prog' ' test_expect_success 'authors-file overrode authors-prog' '
( (
cd x cd x
git rev-list -1 --pretty=raw refs/remotes/git-svn | \ git rev-list -1 --pretty=raw refs/remotes/git-svn >actual &&
grep "^author FFFFFFF FFFFFFF <fFf@other\.example\.com> " grep "^author FFFFFFF FFFFFFF <fFf@other\.example\.com> " actual
) )
' '
@ -73,8 +74,8 @@ test_expect_success 'authors-prog handled special characters in username' '
( (
cd x && cd x &&
git svn --authors-prog=../svn-authors-prog fetch && git svn --authors-prog=../svn-authors-prog fetch &&
git rev-list -1 --pretty=raw refs/remotes/git-svn | git rev-list -1 --pretty=raw refs/remotes/git-svn >actual &&
grep "^author xyz; touch evil <xyz; touch evil@example\.com> " && grep "^author xyz; touch evil <xyz; touch evil@example\.com> " actual &&
! test -f evil ! test -f evil
) )
' '

View File

@ -16,10 +16,10 @@ test_expect_success 'load svn repo' "
" "
test_expect_success 'verify uuid' " test_expect_success 'verify uuid' "
git cat-file commit refs/remotes/git-svn~0 | \ git cat-file commit refs/remotes/git-svn~0 >actual &&
grep '^git-svn-id: .*@2 $uuid$' && grep '^git-svn-id: .*@2 $uuid$' actual &&
git cat-file commit refs/remotes/git-svn~1 | \ git cat-file commit refs/remotes/git-svn~1 >actual &&
grep '^git-svn-id: .*@1 $uuid$' grep '^git-svn-id: .*@1 $uuid$' actual
" "
test_done test_done

View File

@ -48,8 +48,8 @@ test_expect_success 'test refspec prefixed globbing' '
git config --add svn-remote.svn.tags\ git config --add svn-remote.svn.tags\
"tags/t_*/src/a:refs/remotes/tags/t_*" && "tags/t_*/src/a:refs/remotes/tags/t_*" &&
git svn multi-fetch && git svn multi-fetch &&
git log --pretty=oneline refs/remotes/tags/t_end | \ git log --pretty=oneline refs/remotes/tags/t_end >actual &&
sed -e "s/^.\{41\}//" >output.end && sed -e "s/^.\{41\}//" actual >output.end &&
test_cmp expect.end output.end && test_cmp expect.end output.end &&
test "$(git rev-parse refs/remotes/tags/t_end~1)" = \ test "$(git rev-parse refs/remotes/tags/t_end~1)" = \
"$(git rev-parse refs/remotes/branches/b_start)" && "$(git rev-parse refs/remotes/branches/b_start)" &&
@ -78,14 +78,16 @@ test_expect_success 'test left-hand-side only prefixed globbing' '
svn_cmd commit -m "try to try" svn_cmd commit -m "try to try"
) && ) &&
git svn fetch two && git svn fetch two &&
test $(git rev-list refs/remotes/two/tags/t_end | wc -l) -eq 6 && git rev-list refs/remotes/two/tags/t_end >actual &&
test $(git rev-list refs/remotes/two/branches/b_start | wc -l) -eq 3 && test_line_count = 6 actual &&
git rev-list refs/remotes/two/branches/b_start >actual &&
test_line_count = 3 actual &&
test $(git rev-parse refs/remotes/two/branches/b_start~2) = \ test $(git rev-parse refs/remotes/two/branches/b_start~2) = \
$(git rev-parse refs/remotes/two/trunk) && $(git rev-parse refs/remotes/two/trunk) &&
test $(git rev-parse refs/remotes/two/tags/t_end~3) = \ test $(git rev-parse refs/remotes/two/tags/t_end~3) = \
$(git rev-parse refs/remotes/two/branches/b_start) && $(git rev-parse refs/remotes/two/branches/b_start) &&
git log --pretty=oneline refs/remotes/two/tags/t_end | \ git log --pretty=oneline refs/remotes/two/tags/t_end >actual &&
sed -e "s/^.\{41\}//" >output.two && sed -e "s/^.\{41\}//" actual >output.two &&
test_cmp expect.two output.two test_cmp expect.two output.two
' '
@ -118,14 +120,16 @@ test_expect_success 'test prefixed globs match just prefix' '
svn_cmd up svn_cmd up
) && ) &&
git svn fetch three && git svn fetch three &&
test $(git rev-list refs/remotes/three/branches/b_ | wc -l) -eq 2 && git rev-list refs/remotes/three/branches/b_ >actual &&
test $(git rev-list refs/remotes/three/tags/t_ | wc -l) -eq 3 && test_line_count = 2 actual &&
git rev-list refs/remotes/three/tags/t_ >actual &&
test_line_count = 3 actual &&
test $(git rev-parse refs/remotes/three/branches/b_~1) = \ test $(git rev-parse refs/remotes/three/branches/b_~1) = \
$(git rev-parse refs/remotes/three/trunk) && $(git rev-parse refs/remotes/three/trunk) &&
test $(git rev-parse refs/remotes/three/tags/t_~1) = \ test $(git rev-parse refs/remotes/three/tags/t_~1) = \
$(git rev-parse refs/remotes/three/branches/b_) && $(git rev-parse refs/remotes/three/branches/b_) &&
git log --pretty=oneline refs/remotes/three/tags/t_ | \ git log --pretty=oneline refs/remotes/three/tags/t_ >actual &&
sed -e "s/^.\{41\}//" >output.three && sed -e "s/^.\{41\}//" actual >output.three &&
test_cmp expect.three output.three test_cmp expect.three output.three
' '
@ -186,14 +190,16 @@ test_expect_success 'test globbing in the middle of the word' '
svn_cmd up svn_cmd up
) && ) &&
git svn fetch five && git svn fetch five &&
test $(git rev-list refs/remotes/five/branches/abcde | wc -l) -eq 2 && git rev-list refs/remotes/five/branches/abcde >actual &&
test $(git rev-list refs/remotes/five/tags/fghij | wc -l) -eq 3 && test_line_count = 2 actual &&
git rev-list refs/remotes/five/tags/fghij >actual &&
test_line_count = 3 actual &&
test $(git rev-parse refs/remotes/five/branches/abcde~1) = \ test $(git rev-parse refs/remotes/five/branches/abcde~1) = \
$(git rev-parse refs/remotes/five/trunk) && $(git rev-parse refs/remotes/five/trunk) &&
test $(git rev-parse refs/remotes/five/tags/fghij~1) = \ test $(git rev-parse refs/remotes/five/tags/fghij~1) = \
$(git rev-parse refs/remotes/five/branches/abcde) && $(git rev-parse refs/remotes/five/branches/abcde) &&
git log --pretty=oneline refs/remotes/five/tags/fghij | \ git log --pretty=oneline refs/remotes/five/tags/fghij >actual &&
sed -e "s/^.\{41\}//" >output.five && sed -e "s/^.\{41\}//" actual >output.five &&
test_cmp expect.five output.five test_cmp expect.five output.five
' '

View File

@ -43,20 +43,20 @@ test_expect_success 'fast-export | fast-import' '
MUSS=$(git rev-parse --verify muss) && MUSS=$(git rev-parse --verify muss) &&
mkdir new && mkdir new &&
git --git-dir=new/.git init && git --git-dir=new/.git init &&
git fast-export --all | git fast-export --all >actual &&
(cd new && (cd new &&
git fast-import && git fast-import &&
test $MASTER = $(git rev-parse --verify refs/heads/master) && test $MASTER = $(git rev-parse --verify refs/heads/master) &&
test $REIN = $(git rev-parse --verify refs/tags/rein) && test $REIN = $(git rev-parse --verify refs/tags/rein) &&
test $WER = $(git rev-parse --verify refs/heads/wer) && test $WER = $(git rev-parse --verify refs/heads/wer) &&
test $MUSS = $(git rev-parse --verify refs/tags/muss)) test $MUSS = $(git rev-parse --verify refs/tags/muss)) <actual
' '
test_expect_success 'fast-export master~2..master' ' test_expect_success 'fast-export master~2..master' '
git fast-export master~2..master | git fast-export master~2..master >actual &&
sed "s/master/partial/" | sed "s/master/partial/" actual |
(cd new && (cd new &&
git fast-import && git fast-import &&
test $MASTER != $(git rev-parse --verify refs/heads/partial) && test $MASTER != $(git rev-parse --verify refs/heads/partial) &&
@ -74,11 +74,12 @@ test_expect_success 'iso-8859-1' '
test_tick && test_tick &&
echo rosten >file && echo rosten >file &&
git commit -s -m den file && git commit -s -m den file &&
git fast-export wer^..wer | git fast-export wer^..wer >iso8859-1.fi &&
sed "s/wer/i18n/" | sed "s/wer/i18n/" iso8859-1.fi |
(cd new && (cd new &&
git fast-import && git fast-import &&
git cat-file commit i18n | grep "Áéí óú") git cat-file commit i18n >actual &&
grep "Áéí óú" actual)
' '
test_expect_success 'import/export-marks' ' test_expect_success 'import/export-marks' '
@ -87,20 +88,14 @@ test_expect_success 'import/export-marks' '
git fast-export --export-marks=tmp-marks HEAD && git fast-export --export-marks=tmp-marks HEAD &&
test -s tmp-marks && test -s tmp-marks &&
test_line_count = 3 tmp-marks && test_line_count = 3 tmp-marks &&
test $( git fast-export --import-marks=tmp-marks \
git fast-export --import-marks=tmp-marks\ --export-marks=tmp-marks HEAD >actual &&
--export-marks=tmp-marks HEAD | test $(grep ^commit actual | wc -l) -eq 0 &&
grep ^commit |
wc -l) \
-eq 0 &&
echo change > file && echo change > file &&
git commit -m "last commit" file && git commit -m "last commit" file &&
test $( git fast-export --import-marks=tmp-marks \
git fast-export --import-marks=tmp-marks \ --export-marks=tmp-marks HEAD >actual &&
--export-marks=tmp-marks HEAD | test $(grep ^commit\ actual | wc -l) -eq 1 &&
grep ^commit\ |
wc -l) \
-eq 1 &&
test_line_count = 4 tmp-marks test_line_count = 4 tmp-marks
' '
@ -184,7 +179,7 @@ test_expect_success 'submodule fast-export | fast-import' '
rm -rf new && rm -rf new &&
mkdir new && mkdir new &&
git --git-dir=new/.git init && git --git-dir=new/.git init &&
git fast-export --signed-tags=strip --all | git fast-export --signed-tags=strip --all >actual &&
(cd new && (cd new &&
git fast-import && git fast-import &&
test "$SUBENT1" = "$(git ls-tree refs/heads/master^ sub)" && test "$SUBENT1" = "$(git ls-tree refs/heads/master^ sub)" &&
@ -192,7 +187,7 @@ test_expect_success 'submodule fast-export | fast-import' '
git checkout master && git checkout master &&
git submodule init && git submodule init &&
git submodule update && git submodule update &&
cmp sub/file ../sub/file) cmp sub/file ../sub/file) <actual
' '
@ -367,12 +362,14 @@ test_expect_success 'path limiting with import-marks does not lose unmodified fi
echo more content >> file && echo more content >> file &&
test_tick && test_tick &&
git commit -mnext file && git commit -mnext file &&
git fast-export --import-marks=marks simple -- file file0 | grep file0 git fast-export --import-marks=marks simple -- file file0 >actual &&
grep file0 actual
' '
test_expect_success 'full-tree re-shows unmodified files' ' test_expect_success 'full-tree re-shows unmodified files' '
git checkout -f simple && git checkout -f simple &&
test $(git fast-export --full-tree simple | grep -c file0) -eq 3 git fast-export --full-tree simple >actual &&
test $(grep -c file0 actual) -eq 3
' '
test_expect_success 'set-up a few more tags for tag export tests' ' test_expect_success 'set-up a few more tags for tag export tests' '
@ -505,8 +502,8 @@ test_expect_success 'refs are updated even if no commits need to be exported' '
' '
test_expect_success 'use refspec' ' test_expect_success 'use refspec' '
git fast-export --refspec refs/heads/master:refs/heads/foobar master | \ git fast-export --refspec refs/heads/master:refs/heads/foobar master >actual2 &&
grep "^commit " | sort | uniq > actual && grep "^commit " actual2 | sort | uniq >actual &&
echo "commit refs/heads/foobar" > expected && echo "commit refs/heads/foobar" > expected &&
test_cmp expected actual test_cmp expected actual
' '
@ -534,7 +531,8 @@ test_expect_success 'when using -C, do not declare copy when source of copy is a
git -C src commit -m 2nd_commit && git -C src commit -m 2nd_commit &&
test_create_repo dst && test_create_repo dst &&
git -C src fast-export --all -C | git -C dst fast-import && git -C src fast-export --all -C >actual &&
git -C dst fast-import <actual &&
git -C src show >expected && git -C src show >expected &&
git -C dst show >actual && git -C dst show >actual &&
test_cmp expected actual test_cmp expected actual