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 reflogmaint
						commit
						0188f32304
					
				|  | @ -174,12 +174,11 @@ test_expect_success "(not) changed .git/$m" " | ||||||
| ' | ' | ||||||
| rm -f .git/$m | rm -f .git/$m | ||||||
|  |  | ||||||
| : a repository with working tree always has reflog these days... | rm -f .git/logs/refs/heads/master | ||||||
| : >.git/logs/refs/heads/master |  | ||||||
| test_expect_success \ | test_expect_success \ | ||||||
| 	"create $m (logged by touch)" \ | 	"create $m (logged by touch)" \ | ||||||
| 	'GIT_COMMITTER_DATE="2005-05-26 23:30" \ | 	'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 '"$A"' = $(cat .git/'"$m"')' | ||||||
| test_expect_success \ | test_expect_success \ | ||||||
| 	"update $m (logged by touch)" \ | 	"update $m (logged by touch)" \ | ||||||
|  |  | ||||||
|  | @ -100,7 +100,8 @@ test_expect_success setup ' | ||||||
|  |  | ||||||
| 	check_fsck && | 	check_fsck && | ||||||
|  |  | ||||||
| 	test_line_count = 4 .git/logs/refs/heads/master | 	git reflog refs/heads/master >output && | ||||||
|  | 	test_line_count = 4 output | ||||||
| ' | ' | ||||||
|  |  | ||||||
| test_expect_success rewind ' | test_expect_success rewind ' | ||||||
|  | @ -116,7 +117,8 @@ test_expect_success rewind ' | ||||||
|  |  | ||||||
| 	check_have A B C D E F G H I J K L && | 	check_have A B C D E F G H I J K L && | ||||||
|  |  | ||||||
| 	test_line_count = 5 .git/logs/refs/heads/master | 	git reflog refs/heads/master >output && | ||||||
|  | 	test_line_count = 5 output | ||||||
| ' | ' | ||||||
|  |  | ||||||
| test_expect_success 'corrupt and check' ' | test_expect_success 'corrupt and check' ' | ||||||
|  | @ -134,7 +136,8 @@ test_expect_success 'reflog expire --dry-run should not touch reflog' ' | ||||||
| 		--stale-fix \ | 		--stale-fix \ | ||||||
| 		--all && | 		--all && | ||||||
|  |  | ||||||
| 	test_line_count = 5 .git/logs/refs/heads/master && | 	git reflog refs/heads/master >output && | ||||||
|  | 	test_line_count = 5 output && | ||||||
|  |  | ||||||
| 	check_fsck "missing blob $F" | 	check_fsck "missing blob $F" | ||||||
| ' | ' | ||||||
|  | @ -147,7 +150,8 @@ test_expect_success 'reflog expire' ' | ||||||
| 		--stale-fix \ | 		--stale-fix \ | ||||||
| 		--all && | 		--all && | ||||||
|  |  | ||||||
| 	test_line_count = 2 .git/logs/refs/heads/master && | 	git reflog refs/heads/master >output && | ||||||
|  | 	test_line_count = 2 output && | ||||||
|  |  | ||||||
| 	check_fsck "dangling commit $K" | 	check_fsck "dangling commit $K" | ||||||
| ' | ' | ||||||
|  | @ -213,7 +217,8 @@ test_expect_success 'delete' ' | ||||||
| test_expect_success 'rewind2' ' | test_expect_success 'rewind2' ' | ||||||
|  |  | ||||||
| 	test_tick && git reset --hard HEAD~2 && | 	test_tick && git reset --hard HEAD~2 && | ||||||
| 	test_line_count = 4 .git/logs/refs/heads/master | 	git reflog refs/heads/master >output && | ||||||
|  | 	test_line_count = 4 output | ||||||
| ' | ' | ||||||
|  |  | ||||||
| test_expect_success '--expire=never' ' | test_expect_success '--expire=never' ' | ||||||
|  | @ -222,7 +227,8 @@ test_expect_success '--expire=never' ' | ||||||
| 		--expire=never \ | 		--expire=never \ | ||||||
| 		--expire-unreachable=never \ | 		--expire-unreachable=never \ | ||||||
| 		--all && | 		--all && | ||||||
| 	test_line_count = 4 .git/logs/refs/heads/master | 	git reflog refs/heads/master >output && | ||||||
|  | 	test_line_count = 4 output | ||||||
| ' | ' | ||||||
|  |  | ||||||
| test_expect_success 'gc.reflogexpire=never' ' | test_expect_success 'gc.reflogexpire=never' ' | ||||||
|  | @ -230,7 +236,8 @@ test_expect_success 'gc.reflogexpire=never' ' | ||||||
| 	git config gc.reflogexpire never && | 	git config gc.reflogexpire never && | ||||||
| 	git config gc.reflogexpireunreachable never && | 	git config gc.reflogexpireunreachable never && | ||||||
| 	git reflog expire --verbose --all && | 	git reflog expire --verbose --all && | ||||||
| 	test_line_count = 4 .git/logs/refs/heads/master | 	git reflog refs/heads/master >output && | ||||||
|  | 	test_line_count = 4 output | ||||||
| ' | ' | ||||||
|  |  | ||||||
| test_expect_success 'gc.reflogexpire=false' ' | test_expect_success 'gc.reflogexpire=false' ' | ||||||
|  | @ -238,7 +245,8 @@ test_expect_success 'gc.reflogexpire=false' ' | ||||||
| 	git config gc.reflogexpire false && | 	git config gc.reflogexpire false && | ||||||
| 	git config gc.reflogexpireunreachable false && | 	git config gc.reflogexpireunreachable false && | ||||||
| 	git reflog expire --verbose --all && | 	git reflog expire --verbose --all && | ||||||
| 	test_line_count = 4 .git/logs/refs/heads/master && | 	git reflog refs/heads/master >output && | ||||||
|  | 	test_line_count = 4 output && | ||||||
|  |  | ||||||
| 	git config --unset gc.reflogexpire && | 	git config --unset gc.reflogexpire && | ||||||
| 	git config --unset gc.reflogexpireunreachable | 	git config --unset gc.reflogexpireunreachable | ||||||
|  |  | ||||||
|  | @ -138,7 +138,7 @@ test_expect_success '--date magic does not override explicit @{0} syntax' ' | ||||||
| : >expect | : >expect | ||||||
| test_expect_success 'empty reflog file' ' | test_expect_success 'empty reflog file' ' | ||||||
| 	git branch empty && | 	git branch empty && | ||||||
| 	: >.git/logs/refs/heads/empty && | 	git reflog expire --expire=all refs/heads/empty && | ||||||
|  |  | ||||||
| 	git log -g empty >actual && | 	git log -g empty >actual && | ||||||
| 	test_cmp expect actual | 	test_cmp expect actual | ||||||
|  |  | ||||||
|  | @ -85,8 +85,7 @@ test_expect_success 'fails silently when using -q' ' | ||||||
|  |  | ||||||
| test_expect_success 'fails silently when using -q with deleted reflogs' ' | test_expect_success 'fails silently when using -q with deleted reflogs' ' | ||||||
| 	ref=$(git rev-parse HEAD) && | 	ref=$(git rev-parse HEAD) && | ||||||
| 	: >.git/logs/refs/test && | 	git update-ref --create-reflog -m "message for refs/test" refs/test "$ref" && | ||||||
| 	git update-ref -m "message for refs/test" refs/test "$ref" && |  | ||||||
| 	git reflog delete --updateref --rewrite refs/test@{0} && | 	git reflog delete --updateref --rewrite refs/test@{0} && | ||||||
| 	test_must_fail git rev-parse -q --verify refs/test@{0} >error 2>&1 && | 	test_must_fail git rev-parse -q --verify refs/test@{0} >error 2>&1 && | ||||||
| 	test_must_be_empty error | 	test_must_be_empty error | ||||||
|  | @ -94,16 +93,14 @@ test_expect_success 'fails silently when using -q with deleted reflogs' ' | ||||||
|  |  | ||||||
| test_expect_success 'fails silently when using -q with not enough reflogs' ' | test_expect_success 'fails silently when using -q with not enough reflogs' ' | ||||||
| 	ref=$(git rev-parse HEAD) && | 	ref=$(git rev-parse HEAD) && | ||||||
| 	: >.git/logs/refs/test2 && | 	git update-ref --create-reflog -m "message for refs/test2" refs/test2 "$ref" && | ||||||
| 	git update-ref -m "message for refs/test2" refs/test2 "$ref" && |  | ||||||
| 	test_must_fail git rev-parse -q --verify refs/test2@{999} >error 2>&1 && | 	test_must_fail git rev-parse -q --verify refs/test2@{999} >error 2>&1 && | ||||||
| 	test_must_be_empty error | 	test_must_be_empty error | ||||||
| ' | ' | ||||||
|  |  | ||||||
| test_expect_success 'succeeds silently with -q and reflogs that do not go far back enough in time' ' | test_expect_success 'succeeds silently with -q and reflogs that do not go far back enough in time' ' | ||||||
| 	ref=$(git rev-parse HEAD) && | 	ref=$(git rev-parse HEAD) && | ||||||
| 	: >.git/logs/refs/test3 && | 	git update-ref --create-reflog -m "message for refs/test3" refs/test3 "$ref" && | ||||||
| 	git update-ref -m "message for refs/test3" refs/test3 "$ref" && |  | ||||||
| 	git rev-parse -q --verify refs/test3@{1.year.ago} >actual 2>error && | 	git rev-parse -q --verify refs/test3@{1.year.ago} >actual 2>error && | ||||||
| 	test_must_be_empty error && | 	test_must_be_empty error && | ||||||
| 	echo "$ref" >expect && | 	echo "$ref" >expect && | ||||||
|  |  | ||||||
|  | @ -59,7 +59,7 @@ test_expect_success 'git branch -l d/e/f should create a branch and a log' ' | ||||||
| test_expect_success 'git branch -d d/e/f should delete a branch and a log' ' | test_expect_success 'git branch -d d/e/f should delete a branch and a log' ' | ||||||
| 	git branch -d d/e/f && | 	git branch -d d/e/f && | ||||||
| 	test_path_is_missing .git/refs/heads/d/e/f && | 	test_path_is_missing .git/refs/heads/d/e/f && | ||||||
| 	test_path_is_missing .git/logs/refs/heads/d/e/f | 	test_must_fail git reflog exists refs/heads/d/e/f | ||||||
| ' | ' | ||||||
|  |  | ||||||
| test_expect_success 'git branch j/k should work after branch j has been deleted' ' | test_expect_success 'git branch j/k should work after branch j has been deleted' ' | ||||||
|  | @ -82,13 +82,13 @@ test_expect_success 'git branch -m dumps usage' ' | ||||||
| test_expect_success 'git branch -m m m/m should work' ' | test_expect_success 'git branch -m m m/m should work' ' | ||||||
| 	git branch -l m && | 	git branch -l m && | ||||||
| 	git branch -m m m/m && | 	git branch -m m m/m && | ||||||
| 	test_path_is_file .git/logs/refs/heads/m/m | 	git reflog exists refs/heads/m/m | ||||||
| ' | ' | ||||||
|  |  | ||||||
| test_expect_success 'git branch -m n/n n should work' ' | test_expect_success 'git branch -m n/n n should work' ' | ||||||
| 	git branch -l n/n && | 	git branch -l n/n && | ||||||
| 	git branch -m n/n n && | 	git branch -m n/n n && | ||||||
| 	test_path_is_file .git/logs/refs/heads/n | 	git reflog exists refs/heads/n | ||||||
| ' | ' | ||||||
|  |  | ||||||
| test_expect_success 'git branch -m o/o o should fail when o/p exists' ' | test_expect_success 'git branch -m o/o o should fail when o/p exists' ' | ||||||
|  | @ -267,12 +267,12 @@ git config branch.s/s.dummy Hello | ||||||
|  |  | ||||||
| test_expect_success 'git branch -m s/s s should work when s/t is deleted' ' | test_expect_success 'git branch -m s/s s should work when s/t is deleted' ' | ||||||
| 	git branch -l s/s && | 	git branch -l s/s && | ||||||
| 	test_path_is_file .git/logs/refs/heads/s/s && | 	git reflog exists refs/heads/s/s && | ||||||
| 	git branch -l s/t && | 	git branch -l s/t && | ||||||
| 	test_path_is_file .git/logs/refs/heads/s/t && | 	git reflog exists refs/heads/s/t && | ||||||
| 	git branch -d s/t && | 	git branch -d s/t && | ||||||
| 	git branch -m s/s s && | 	git branch -m s/s s && | ||||||
| 	test_path_is_file .git/logs/refs/heads/s | 	git reflog exists refs/heads/s | ||||||
| ' | ' | ||||||
|  |  | ||||||
| test_expect_success 'config information was renamed, too' ' | test_expect_success 'config information was renamed, too' ' | ||||||
|  |  | ||||||
|  | @ -169,7 +169,7 @@ test_expect_success 'create packed foo/bar/baz branch' ' | ||||||
| 	git branch foo/bar/baz && | 	git branch foo/bar/baz && | ||||||
| 	git pack-refs --all --prune && | 	git pack-refs --all --prune && | ||||||
| 	test_path_is_missing .git/refs/heads/foo/bar/baz && | 	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' ' | test_expect_success 'notice d/f conflict with existing directory' ' | ||||||
|  |  | ||||||
|  | @ -961,13 +961,13 @@ test_expect_success 'rebase -i produces readable reflog' ' | ||||||
| 	set_fake_editor && | 	set_fake_editor && | ||||||
| 	git rebase -i --onto I F branch-reflog-test && | 	git rebase -i --onto I F branch-reflog-test && | ||||||
| 	cat >expect <<-\EOF && | 	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 (finish): returning to refs/heads/branch-reflog-test | ||||||
|  | 	rebase -i (pick): H | ||||||
|  | 	rebase -i (pick): G | ||||||
|  | 	rebase -i (start): checkout I | ||||||
| 	EOF | 	EOF | ||||||
| 	tail -n 4 .git/logs/HEAD | | 	git reflog -n4 HEAD | | ||||||
| 	sed -e "s/.*	//" >actual && | 	sed "s/[^:]*: //" >actual && | ||||||
| 	test_cmp expect actual | 	test_cmp expect actual | ||||||
| ' | ' | ||||||
|  |  | ||||||
|  |  | ||||||
|  | @ -672,7 +672,7 @@ test_expect_success 'store updates stash ref and reflog' ' | ||||||
| 	! grep quux bazzy && | 	! grep quux bazzy && | ||||||
| 	git stash store -m quuxery $STASH_ID && | 	git stash store -m quuxery $STASH_ID && | ||||||
| 	test $(cat .git/refs/stash) = $STASH_ID && | 	test $(cat .git/refs/stash) = $STASH_ID && | ||||||
| 	grep $STASH_ID .git/logs/refs/stash && | 	git reflog --format=%H stash| grep $STASH_ID && | ||||||
| 	git stash pop && | 	git stash pop && | ||||||
| 	grep quux bazzy | 	grep quux bazzy | ||||||
| ' | ' | ||||||
|  |  | ||||||
|  | @ -12,7 +12,7 @@ delete objects that cannot be recovered. | ||||||
|  |  | ||||||
| test_expect_success 'disable reflogs' ' | test_expect_success 'disable reflogs' ' | ||||||
| 	git config core.logallrefupdates false && | 	git config core.logallrefupdates false && | ||||||
| 	rm -rf .git/logs | 	git reflog expire --expire=all --all | ||||||
| ' | ' | ||||||
|  |  | ||||||
| test_expect_success 'create history reachable only from a bogus-named ref' ' | test_expect_success 'create history reachable only from a bogus-named ref' ' | ||||||
|  |  | ||||||
|  | @ -56,7 +56,7 @@ for repack in '' true; do | ||||||
|  |  | ||||||
| 	test_expect_success "disable reflogs ($title)" ' | 	test_expect_success "disable reflogs ($title)" ' | ||||||
| 		git config core.logallrefupdates false && | 		git config core.logallrefupdates false && | ||||||
| 		rm -rf .git/logs | 		git reflog expire --expire=all --all | ||||||
| 	' | 	' | ||||||
|  |  | ||||||
| 	test_expect_success "setup basic history ($title)" ' | 	test_expect_success "setup basic history ($title)" ' | ||||||
|  |  | ||||||
|  | @ -90,22 +90,10 @@ sha1_file() { | ||||||
| remove_object() { | remove_object() { | ||||||
| 	rm -f $(sha1_file "$*") | 	rm -f $(sha1_file "$*") | ||||||
| } | } | ||||||
| no_reflog() { |  | ||||||
| 	cp .git/config .git/config.saved && |  | ||||||
| 	echo "[core] logallrefupdates = false" >>.git/config && |  | ||||||
| 	test_when_finished "mv -f .git/config.saved .git/config" && |  | ||||||
|  |  | ||||||
| 	if test -e .git/logs |  | ||||||
| 	then |  | ||||||
| 		mv .git/logs . && |  | ||||||
| 		test_when_finished "mv logs .git/" |  | ||||||
| 	fi |  | ||||||
| } |  | ||||||
|  |  | ||||||
| test_expect_success '--amend option with empty author' ' | test_expect_success '--amend option with empty author' ' | ||||||
| 	git cat-file commit Initial >tmp && | 	git cat-file commit Initial >tmp && | ||||||
| 	sed "s/author [^<]* </author  </" tmp >empty-author && | 	sed "s/author [^<]* </author  </" tmp >empty-author && | ||||||
| 	no_reflog && |  | ||||||
| 	sha=$(git hash-object -t commit -w empty-author) && | 	sha=$(git hash-object -t commit -w empty-author) && | ||||||
| 	test_when_finished "remove_object $sha" && | 	test_when_finished "remove_object $sha" && | ||||||
| 	git checkout $sha && | 	git checkout $sha && | ||||||
|  | @ -119,7 +107,6 @@ test_expect_success '--amend option with empty author' ' | ||||||
| test_expect_success '--amend option with missing author' ' | test_expect_success '--amend option with missing author' ' | ||||||
| 	git cat-file commit Initial >tmp && | 	git cat-file commit Initial >tmp && | ||||||
| 	sed "s/author [^<]* </author </" tmp >malformed && | 	sed "s/author [^<]* </author </" tmp >malformed && | ||||||
| 	no_reflog && |  | ||||||
| 	sha=$(git hash-object -t commit -w malformed) && | 	sha=$(git hash-object -t commit -w malformed) && | ||||||
| 	test_when_finished "remove_object $sha" && | 	test_when_finished "remove_object $sha" && | ||||||
| 	git checkout $sha && | 	git checkout $sha && | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue
	
	 Junio C Hamano
						Junio C Hamano