diff options
Diffstat (limited to 't')
-rwxr-xr-x | t/t6002-rev-list-bisect.sh | 2 | ||||
-rwxr-xr-x | t/t6004-rev-list-path-optim.sh | 34 | ||||
-rwxr-xr-x | t/t6030-bisect-run.sh | 53 | ||||
-rwxr-xr-x | t/t7201-co.sh | 63 |
4 files changed, 145 insertions, 7 deletions
diff --git a/t/t6002-rev-list-bisect.sh b/t/t6002-rev-list-bisect.sh index 7831e3461c..fcb3302764 100755 --- a/t/t6002-rev-list-bisect.sh +++ b/t/t6002-rev-list-bisect.sh @@ -163,7 +163,7 @@ test_sequence() # the bisection point is the head - this is the bad point. # -test_output_expect_success "--bisect l5 ^root" 'git-rev-list $_bisect_option l5 ^root' <<EOF +test_output_expect_success "$_bisect_option l5 ^root" 'git-rev-list $_bisect_option l5 ^root' <<EOF c3 EOF diff --git a/t/t6004-rev-list-path-optim.sh b/t/t6004-rev-list-path-optim.sh index 5182dbb158..761f09b1e5 100755 --- a/t/t6004-rev-list-path-optim.sh +++ b/t/t6004-rev-list-path-optim.sh @@ -7,7 +7,8 @@ test_description='git-rev-list trivial path optimization test' test_expect_success setup ' echo Hello > a && git add a && -git commit -m "Initial commit" a +git commit -m "Initial commit" a && +initial=$(git rev-parse --verify HEAD) ' test_expect_success path-optimization ' @@ -16,4 +17,35 @@ test_expect_success path-optimization ' test $(git-rev-list $commit -- . | wc -l) = 1 ' +test_expect_success 'further setup' ' + git checkout -b side && + echo Irrelevant >c && + git add c && + git commit -m "Side makes an irrelevant commit" && + echo "More Irrelevancy" >c && + git add c && + git commit -m "Side makes another irrelevant commit" && + echo Bye >a && + git add a && + git commit -m "Side touches a" && + side=$(git rev-parse --verify HEAD) && + echo "Yet more Irrelevancy" >c && + git add c && + git commit -m "Side makes yet another irrelevant commit" && + git checkout master && + echo Another >b && + git add b && + git commit -m "Master touches b" && + git merge side && + echo Touched >b && + git add b && + git commit -m "Master touches b again" +' + +test_expect_success 'path optimization 2' ' + ( echo "$side"; echo "$initial" ) >expected && + git rev-list HEAD -- a >actual && + diff -u expected actual +' + test_done diff --git a/t/t6030-bisect-run.sh b/t/t6030-bisect-run.sh index 39c72283b5..de3123522a 100755 --- a/t/t6030-bisect-run.sh +++ b/t/t6030-bisect-run.sh @@ -2,7 +2,9 @@ # # Copyright (c) 2007 Christian Couder # -test_description='Tests git-bisect run functionality' +test_description='Tests git-bisect functionality' + +exec </dev/null . ./test-lib.sh @@ -37,11 +39,40 @@ test_expect_success \ HASH3=$(git rev-list HEAD | head -2 | tail -1) && HASH4=$(git rev-list HEAD | head -1)' +test_expect_success 'bisect starts with only one bad' ' + git bisect reset && + git bisect start && + git bisect bad $HASH4 && + git bisect next +' + +test_expect_success 'bisect starts with only one good' ' + git bisect reset && + git bisect start && + git bisect good $HASH1 || return 1 + + if git bisect next + then + echo Oops, should have failed. + false + else + : + fi +' + +test_expect_success 'bisect start with one bad and good' ' + git bisect reset && + git bisect start && + git bisect good $HASH1 && + git bisect bad $HASH4 && + git bisect next +' + # We want to automatically find the commit that # introduced "Another" into hello. test_expect_success \ - 'git bisect run simple case' \ - 'echo "#!/bin/sh" > test_script.sh && + '"git bisect run" simple case' \ + 'echo "#"\!"/bin/sh" > test_script.sh && echo "grep Another hello > /dev/null" >> test_script.sh && echo "test \$? -ne 0" >> test_script.sh && chmod +x test_script.sh && @@ -49,7 +80,21 @@ test_expect_success \ git bisect good $HASH1 && git bisect bad $HASH4 && git bisect run ./test_script.sh > my_bisect_log.txt && - grep "$HASH3 is first bad commit" my_bisect_log.txt' + grep "$HASH3 is first bad commit" my_bisect_log.txt && + git bisect reset' + +# We want to automatically find the commit that +# introduced "Ciao" into hello. +test_expect_success \ + '"git bisect run" with more complex "git bisect start"' \ + 'echo "#"\!"/bin/sh" > test_script.sh && + echo "grep Ciao hello > /dev/null" >> test_script.sh && + echo "test \$? -ne 0" >> test_script.sh && + chmod +x test_script.sh && + git bisect start $HASH4 $HASH1 && + git bisect run ./test_script.sh > my_bisect_log.txt && + grep "$HASH4 is first bad commit" my_bisect_log.txt && + git bisect reset' # # diff --git a/t/t7201-co.sh b/t/t7201-co.sh index 867bbd26cb..5fa6a45577 100755 --- a/t/t7201-co.sh +++ b/t/t7201-co.sh @@ -3,7 +3,20 @@ # Copyright (c) 2006 Junio C Hamano # -test_description='git-checkout tests.' +test_description='git-checkout tests. + +Creates master, forks renamer and side branches from it. +Test switching across them. + + ! [master] Initial A one, A two + * [renamer] Renamer R one->uno, M two + ! [side] Side M one, D two, A three + --- + + [side] Side M one, D two, A three + * [renamer] Renamer R one->uno, M two + +*+ [master] Initial A one, A two + +' . ./test-lib.sh @@ -129,4 +142,52 @@ test_expect_success 'checkout -m with merge conflict' ' ! test -s current ' +test_expect_success 'checkout to detach HEAD' ' + + git checkout -f renamer && git clean && + git checkout renamer^ && + H=$(git rev-parse --verify HEAD) && + M=$(git show-ref -s --verify refs/heads/master) && + test "z$H" = "z$M" && + if git symbolic-ref HEAD >/dev/null 2>&1 + then + echo "OOPS, HEAD is still symbolic???" + false + else + : happy + fi +' + +test_expect_success 'checkout to detach HEAD with branchname^' ' + + git checkout -f master && git clean && + git checkout renamer^ && + H=$(git rev-parse --verify HEAD) && + M=$(git show-ref -s --verify refs/heads/master) && + test "z$H" = "z$M" && + if git symbolic-ref HEAD >/dev/null 2>&1 + then + echo "OOPS, HEAD is still symbolic???" + false + else + : happy + fi +' + +test_expect_success 'checkout to detach HEAD with HEAD^0' ' + + git checkout -f master && git clean && + git checkout HEAD^0 && + H=$(git rev-parse --verify HEAD) && + M=$(git show-ref -s --verify refs/heads/master) && + test "z$H" = "z$M" && + if git symbolic-ref HEAD >/dev/null 2>&1 + then + echo "OOPS, HEAD is still symbolic???" + false + else + : happy + fi +' + test_done |