From: Junio C Hamano Date: Wed, 12 Aug 2015 21:09:56 +0000 (-0700) Subject: Merge branch 'dt/reflog-tests' X-Git-Tag: v2.6.0-rc0~75 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/0188f32304d916ec6a2443937e36421e8da9a8fd?ds=inline;hp=-c Merge branch 'dt/reflog-tests' Tests that assume how reflogs are represented on the filesystem too much have been corrected. * dt/reflog-tests: tests: remove some direct access to .git/logs t/t7509: remove unnecessary manipulation of reflog --- 0188f32304d916ec6a2443937e36421e8da9a8fd diff --combined t/t1400-update-ref.sh index 9d21c1927e,23721322e8..97406fa4b1 --- a/t/t1400-update-ref.sh +++ b/t/t1400-update-ref.sh @@@ -23,7 -23,6 +23,7 @@@ test_expect_success setup m=refs/heads/master n_dir=refs/heads/gu n=$n_dir/fixes +outside=foo test_expect_success \ "create $m" \ @@@ -75,24 -74,6 +75,24 @@@ test_expect_success "delete $m (by HEAD ' rm -f .git/$m +test_expect_success 'update-ref does not create reflogs by default' ' + test_when_finished "git update-ref -d $outside" && + git update-ref $outside $A && + git rev-parse $A >expect && + git rev-parse $outside >actual && + test_cmp expect actual && + test_must_fail git reflog exists $outside +' + +test_expect_success 'update-ref creates reflogs with --create-reflog' ' + test_when_finished "git update-ref -d $outside" && + git update-ref --create-reflog $outside $A && + git rev-parse $A >expect && + git rev-parse $outside >actual && + test_cmp expect actual && + git reflog exists $outside +' + test_expect_success \ "create $m (by HEAD)" \ "git update-ref HEAD $A && @@@ -174,12 -155,11 +174,11 @@@ test_expect_success "(not) changed .git ' rm -f .git/$m - : a repository with working tree always has reflog these days... - : >.git/logs/refs/heads/master + rm -f .git/logs/refs/heads/master test_expect_success \ "create $m (logged by touch)" \ 'GIT_COMMITTER_DATE="2005-05-26 23:30" \ - git update-ref HEAD '"$A"' -m "Initial Creation" && + git update-ref --create-reflog HEAD '"$A"' -m "Initial Creation" && test '"$A"' = $(cat .git/'"$m"')' test_expect_success \ "update $m (logged by touch)" \ @@@ -491,25 -471,6 +490,25 @@@ test_expect_success 'stdin create ref w test_cmp expect actual ' +test_expect_success 'stdin does not create reflogs by default' ' + test_when_finished "git update-ref -d $outside" && + echo "create $outside $m" >stdin && + git update-ref --stdin expect && + git rev-parse $outside >actual && + test_cmp expect actual && + test_must_fail git reflog exists $outside +' + +test_expect_success 'stdin creates reflogs with --create-reflog' ' + echo "create $outside $m" >stdin && + git update-ref --create-reflog --stdin expect && + git rev-parse $outside >actual && + test_cmp expect actual && + git reflog exists $outside +' + test_expect_success 'stdin succeeds with quoted argument' ' git update-ref -d $a && echo "create $a \"$m\"" >stdin && @@@ -557,7 -518,7 +556,7 @@@ test_expect_success 'stdin create ref w test_expect_success 'stdin update ref fails with wrong old value' ' echo "update $c $m $m~1" >stdin && test_must_fail git update-ref --stdin err && - grep "fatal: Cannot lock ref '"'"'$c'"'"'" err && + grep "fatal: cannot lock ref '"'"'$c'"'"'" err && test_must_fail git rev-parse --verify -q $c ' @@@ -593,7 -554,7 +592,7 @@@ test_expect_success 'stdin update ref w test_expect_success 'stdin delete ref fails with wrong old value' ' echo "delete $a $m~1" >stdin && test_must_fail git update-ref --stdin err && - grep "fatal: Cannot lock ref '"'"'$a'"'"'" err && + grep "fatal: cannot lock ref '"'"'$a'"'"'" err && git rev-parse $m >expect && git rev-parse $a >actual && test_cmp expect actual @@@ -726,7 -687,7 +725,7 @@@ test_expect_success 'stdin update refs update $c '' EOF test_must_fail git update-ref --stdin err && - grep "fatal: Cannot lock ref '"'"'$c'"'"'" err && + grep "fatal: cannot lock ref '"'"'$c'"'"'" err && git rev-parse $m >expect && git rev-parse $a >actual && test_cmp expect actual && @@@ -921,7 -882,7 +920,7 @@@ test_expect_success 'stdin -z create re test_expect_success 'stdin -z update ref fails with wrong old value' ' printf $F "update $c" "$m" "$m~1" >stdin && test_must_fail git update-ref -z --stdin err && - grep "fatal: Cannot lock ref '"'"'$c'"'"'" err && + grep "fatal: cannot lock ref '"'"'$c'"'"'" err && test_must_fail git rev-parse --verify -q $c ' @@@ -937,7 -898,7 +936,7 @@@ test_expect_success 'stdin -z create re git rev-parse "$c" >expect && printf $F "create $c" "$m~1" >stdin && test_must_fail git update-ref -z --stdin err && - grep "fatal: Cannot lock ref '"'"'$c'"'"'" err && + grep "fatal: cannot lock ref '"'"'$c'"'"'" err && git rev-parse "$c" >actual && test_cmp expect actual ' @@@ -968,7 -929,7 +967,7 @@@ test_expect_success 'stdin -z update re test_expect_success 'stdin -z delete ref fails with wrong old value' ' printf $F "delete $a" "$m~1" >stdin && test_must_fail git update-ref -z --stdin err && - grep "fatal: Cannot lock ref '"'"'$a'"'"'" err && + grep "fatal: cannot lock ref '"'"'$a'"'"'" err && git rev-parse $m >expect && git rev-parse $a >actual && test_cmp expect actual @@@ -1083,7 -1044,7 +1082,7 @@@ test_expect_success 'stdin -z update re git update-ref $c $m && printf $F "update $a" "$m" "$m" "update $b" "$m" "$m" "update $c" "$m" "$Z" >stdin && test_must_fail git update-ref -z --stdin err && - grep "fatal: Cannot lock ref '"'"'$c'"'"'" err && + grep "fatal: cannot lock ref '"'"'$c'"'"'" err && git rev-parse $m >expect && git rev-parse $a >actual && test_cmp expect actual && diff --combined t/t1411-reflog-show.sh index 3eb4f102e5,d568b35b43..6ac7734d79 --- a/t/t1411-reflog-show.sh +++ b/t/t1411-reflog-show.sh @@@ -138,7 -138,7 +138,7 @@@ test_expect_success '--date magic does : >expect test_expect_success 'empty reflog file' ' git branch empty && - : >.git/logs/refs/heads/empty && + git reflog expire --expire=all refs/heads/empty && git log -g empty >actual && test_cmp expect actual @@@ -166,9 -166,4 +166,9 @@@ test_expect_success 'git log -g -p show test_cmp expect actual ' +test_expect_success 'reflog exists works' ' + git reflog exists refs/heads/master && + ! git reflog exists refs/heads/nonexistent +' + test_done diff --combined t/t3210-pack-refs.sh index 8aae98d482,9d53949323..7b5b6d452e --- a/t/t3210-pack-refs.sh +++ b/t/t3210-pack-refs.sh @@@ -169,7 -169,7 +169,7 @@@ test_expect_success 'create packed foo/ git branch foo/bar/baz && git pack-refs --all --prune && test_path_is_missing .git/refs/heads/foo/bar/baz && - test_path_is_missing .git/logs/refs/heads/foo/bar/baz + test_must_fail git reflog exists refs/heads/foo/bar/baz ' test_expect_success 'notice d/f conflict with existing directory' ' @@@ -187,21 -187,4 +187,21 @@@ test_expect_success 'notice d/f conflic test_must_fail git branch foo/bar/baz/lots/of/extra/components ' +test_expect_success 'timeout if packed-refs.lock exists' ' + LOCK=.git/packed-refs.lock && + >"$LOCK" && + test_when_finished "rm -f $LOCK" && + test_must_fail git pack-refs --all --prune +' + +test_expect_success 'retry acquiring packed-refs.lock' ' + LOCK=.git/packed-refs.lock && + >"$LOCK" && + test_when_finished "wait; rm -f $LOCK" && + { + ( sleep 1 ; rm -f $LOCK ) & + } && + git -c core.packedrefstimeout=3000 pack-refs --all --prune +' + test_done diff --combined t/t3404-rebase-interactive.sh index 9d26064aba,567d6ca9b8..d26e3f57dc --- a/t/t3404-rebase-interactive.sh +++ b/t/t3404-rebase-interactive.sh @@@ -961,13 -961,13 +961,13 @@@ test_expect_success 'rebase -i produce set_fake_editor && git rebase -i --onto I F branch-reflog-test && cat >expect <<-\EOF && - rebase -i (start): checkout I - rebase -i (pick): G - rebase -i (pick): H rebase -i (finish): returning to refs/heads/branch-reflog-test + rebase -i (pick): H + rebase -i (pick): G + rebase -i (start): checkout I EOF - tail -n 4 .git/logs/HEAD | - sed -e "s/.* //" >actual && + git reflog -n4 HEAD | + sed "s/[^:]*: //" >actual && test_cmp expect actual ' @@@ -1102,148 -1102,4 +1102,148 @@@ test_expect_success 'rebase -i commits test $(git cat-file commit HEAD | sed -ne \$p) = I ' +test_expect_success 'rebase --continue removes CHERRY_PICK_HEAD' ' + git checkout -b commit-to-skip && + for double in X 3 1 + do + test_seq 5 | sed "s/$double/&&/" >seq && + git add seq && + test_tick && + git commit -m seq-$double + done && + git tag seq-onto && + git reset --hard HEAD~2 && + git cherry-pick seq-onto && + set_fake_editor && + test_must_fail env FAKE_LINES= git rebase -i seq-onto && + test -d .git/rebase-merge && + git rebase --continue && + git diff --exit-code seq-onto && + test ! -d .git/rebase-merge && + test ! -f .git/CHERRY_PICK_HEAD +' + +rebase_setup_and_clean () { + test_when_finished " + git checkout master && + test_might_fail git branch -D $1 && + test_might_fail git rebase --abort + " && + git checkout -b $1 master +} + +test_expect_success 'drop' ' + rebase_setup_and_clean drop-test && + set_fake_editor && + FAKE_LINES="1 drop 2 3 drop 4 5" git rebase -i --root && + test E = $(git cat-file commit HEAD | sed -ne \$p) && + test C = $(git cat-file commit HEAD^ | sed -ne \$p) && + test A = $(git cat-file commit HEAD^^ | sed -ne \$p) +' + +cat >expect <actual && + test D = $(git cat-file commit HEAD | sed -ne \$p) && + test_cmp expect actual +' + +cat >expect <actual && + test_cmp expect actual && + test D = $(git cat-file commit HEAD | sed -ne \$p) +' + +cat >expect <actual && + test_cmp expect actual && + cp .git/rebase-merge/git-rebase-todo.backup \ + .git/rebase-merge/git-rebase-todo && + FAKE_LINES="1 2 drop 3 4 drop 5" \ + git rebase --edit-todo && + git rebase --continue && + test D = $(git cat-file commit HEAD | sed -ne \$p) && + test B = $(git cat-file commit HEAD^ | sed -ne \$p) +' + +cat >expect <actual && + test_cmp expect actual && + FAKE_LINES="1 2 3 drop 4 5" git rebase --edit-todo && + git rebase --continue && + test E = $(git cat-file commit HEAD | sed -ne \$p) && + test C = $(git cat-file commit HEAD^ | sed -ne \$p) +' + +cat >expect <actual && + test_cmp expect actual && + FAKE_LINES="1 2 4 5 6" git rebase --edit-todo && + git rebase --continue && + test E = $(git cat-file commit HEAD | sed -ne \$p) +' + test_done