Merge branch 'jn/push-tests'
Update t5516 with style fixes. * jn/push-tests: push test: rely on &&-chaining instead of 'if bad; then echo Oops; fi' push test: simplify check of push result push test: use test_config when appropriate
This commit is contained in:
		| @ -22,19 +22,16 @@ mk_test () { | |||||||
| 	( | 	( | ||||||
| 		for ref in "$@" | 		for ref in "$@" | ||||||
| 		do | 		do | ||||||
| 			git push testrepo $the_first_commit:refs/$ref || { | 			git push testrepo $the_first_commit:refs/$ref || | ||||||
| 				echo "Oops, push refs/$ref failure" | 			exit | ||||||
| 				exit 1 |  | ||||||
| 			} |  | ||||||
| 		done && | 		done && | ||||||
| 		cd testrepo && | 		cd testrepo && | ||||||
| 		for ref in "$@" | 		for ref in "$@" | ||||||
| 		do | 		do | ||||||
| 			r=$(git show-ref -s --verify refs/$ref) && | 			echo "$the_first_commit" >expect && | ||||||
| 			test "z$r" = "z$the_first_commit" || { | 			git show-ref -s --verify refs/$ref >actual && | ||||||
| 				echo "Oops, refs/$ref is wrong" | 			test_cmp expect actual || | ||||||
| 				exit 1 | 			exit | ||||||
| 			} |  | ||||||
| 		done && | 		done && | ||||||
| 		git fsck --full | 		git fsck --full | ||||||
| 	) | 	) | ||||||
| @ -82,15 +79,13 @@ mk_child() { | |||||||
| check_push_result () { | check_push_result () { | ||||||
| 	( | 	( | ||||||
| 		cd testrepo && | 		cd testrepo && | ||||||
| 		it="$1" && | 		echo "$1" >expect && | ||||||
| 		shift | 		shift && | ||||||
| 		for ref in "$@" | 		for ref in "$@" | ||||||
| 		do | 		do | ||||||
| 			r=$(git show-ref -s --verify refs/$ref) && | 			git show-ref -s --verify refs/$ref >actual && | ||||||
| 			test "z$r" = "z$it" || { | 			test_cmp expect actual || | ||||||
| 				echo "Oops, refs/$ref is wrong" | 			exit | ||||||
| 				exit 1 |  | ||||||
| 			} |  | ||||||
| 		done && | 		done && | ||||||
| 		git fsck --full | 		git fsck --full | ||||||
| 	) | 	) | ||||||
| @ -118,10 +113,9 @@ test_expect_success 'fetch without wildcard' ' | |||||||
| 		cd testrepo && | 		cd testrepo && | ||||||
| 		git fetch .. refs/heads/master:refs/remotes/origin/master && | 		git fetch .. refs/heads/master:refs/remotes/origin/master && | ||||||
|  |  | ||||||
| 		r=$(git show-ref -s --verify refs/remotes/origin/master) && | 		echo "$the_commit commit	refs/remotes/origin/master" >expect && | ||||||
| 		test "z$r" = "z$the_commit" && | 		git for-each-ref refs/remotes/origin >actual && | ||||||
|  | 		test_cmp expect actual | ||||||
| 		test 1 = $(git for-each-ref refs/remotes/origin | wc -l) |  | ||||||
| 	) | 	) | ||||||
| ' | ' | ||||||
|  |  | ||||||
| @ -133,10 +127,9 @@ test_expect_success 'fetch with wildcard' ' | |||||||
| 		git config remote.up.fetch "refs/heads/*:refs/remotes/origin/*" && | 		git config remote.up.fetch "refs/heads/*:refs/remotes/origin/*" && | ||||||
| 		git fetch up && | 		git fetch up && | ||||||
|  |  | ||||||
| 		r=$(git show-ref -s --verify refs/remotes/origin/master) && | 		echo "$the_commit commit	refs/remotes/origin/master" >expect && | ||||||
| 		test "z$r" = "z$the_commit" && | 		git for-each-ref refs/remotes/origin >actual && | ||||||
|  | 		test_cmp expect actual | ||||||
| 		test 1 = $(git for-each-ref refs/remotes/origin | wc -l) |  | ||||||
| 	) | 	) | ||||||
| ' | ' | ||||||
|  |  | ||||||
| @ -150,10 +143,9 @@ test_expect_success 'fetch with insteadOf' ' | |||||||
| 		git config remote.up.fetch "refs/heads/*:refs/remotes/origin/*" && | 		git config remote.up.fetch "refs/heads/*:refs/remotes/origin/*" && | ||||||
| 		git fetch up && | 		git fetch up && | ||||||
|  |  | ||||||
| 		r=$(git show-ref -s --verify refs/remotes/origin/master) && | 		echo "$the_commit commit	refs/remotes/origin/master" >expect && | ||||||
| 		test "z$r" = "z$the_commit" && | 		git for-each-ref refs/remotes/origin >actual && | ||||||
|  | 		test_cmp expect actual | ||||||
| 		test 1 = $(git for-each-ref refs/remotes/origin | wc -l) |  | ||||||
| 	) | 	) | ||||||
| ' | ' | ||||||
|  |  | ||||||
| @ -167,10 +159,9 @@ test_expect_success 'fetch with pushInsteadOf (should not rewrite)' ' | |||||||
| 		git config remote.up.fetch "refs/heads/*:refs/remotes/origin/*" && | 		git config remote.up.fetch "refs/heads/*:refs/remotes/origin/*" && | ||||||
| 		git fetch up && | 		git fetch up && | ||||||
|  |  | ||||||
| 		r=$(git show-ref -s --verify refs/remotes/origin/master) && | 		echo "$the_commit commit	refs/remotes/origin/master" >expect && | ||||||
| 		test "z$r" = "z$the_commit" && | 		git for-each-ref refs/remotes/origin >actual && | ||||||
|  | 		test_cmp expect actual | ||||||
| 		test 1 = $(git for-each-ref refs/remotes/origin | wc -l) |  | ||||||
| 	) | 	) | ||||||
| ' | ' | ||||||
|  |  | ||||||
| @ -180,10 +171,9 @@ test_expect_success 'push without wildcard' ' | |||||||
| 	git push testrepo refs/heads/master:refs/remotes/origin/master && | 	git push testrepo refs/heads/master:refs/remotes/origin/master && | ||||||
| 	( | 	( | ||||||
| 		cd testrepo && | 		cd testrepo && | ||||||
| 		r=$(git show-ref -s --verify refs/remotes/origin/master) && | 		echo "$the_commit commit	refs/remotes/origin/master" >expect && | ||||||
| 		test "z$r" = "z$the_commit" && | 		git for-each-ref refs/remotes/origin >actual && | ||||||
|  | 		test_cmp expect actual | ||||||
| 		test 1 = $(git for-each-ref refs/remotes/origin | wc -l) |  | ||||||
| 	) | 	) | ||||||
| ' | ' | ||||||
|  |  | ||||||
| @ -193,54 +183,50 @@ test_expect_success 'push with wildcard' ' | |||||||
| 	git push testrepo "refs/heads/*:refs/remotes/origin/*" && | 	git push testrepo "refs/heads/*:refs/remotes/origin/*" && | ||||||
| 	( | 	( | ||||||
| 		cd testrepo && | 		cd testrepo && | ||||||
| 		r=$(git show-ref -s --verify refs/remotes/origin/master) && | 		echo "$the_commit commit	refs/remotes/origin/master" >expect && | ||||||
| 		test "z$r" = "z$the_commit" && | 		git for-each-ref refs/remotes/origin >actual && | ||||||
|  | 		test_cmp expect actual | ||||||
| 		test 1 = $(git for-each-ref refs/remotes/origin | wc -l) |  | ||||||
| 	) | 	) | ||||||
| ' | ' | ||||||
|  |  | ||||||
| test_expect_success 'push with insteadOf' ' | test_expect_success 'push with insteadOf' ' | ||||||
| 	mk_empty && | 	mk_empty && | ||||||
| 	TRASH="$(pwd)/" && | 	TRASH="$(pwd)/" && | ||||||
| 	git config "url.$TRASH.insteadOf" trash/ && | 	test_config "url.$TRASH.insteadOf" trash/ && | ||||||
| 	git push trash/testrepo refs/heads/master:refs/remotes/origin/master && | 	git push trash/testrepo refs/heads/master:refs/remotes/origin/master && | ||||||
| 	( | 	( | ||||||
| 		cd testrepo && | 		cd testrepo && | ||||||
| 		r=$(git show-ref -s --verify refs/remotes/origin/master) && | 		echo "$the_commit commit	refs/remotes/origin/master" >expect && | ||||||
| 		test "z$r" = "z$the_commit" && | 		git for-each-ref refs/remotes/origin >actual && | ||||||
|  | 		test_cmp expect actual | ||||||
| 		test 1 = $(git for-each-ref refs/remotes/origin | wc -l) |  | ||||||
| 	) | 	) | ||||||
| ' | ' | ||||||
|  |  | ||||||
| test_expect_success 'push with pushInsteadOf' ' | test_expect_success 'push with pushInsteadOf' ' | ||||||
| 	mk_empty && | 	mk_empty && | ||||||
| 	TRASH="$(pwd)/" && | 	TRASH="$(pwd)/" && | ||||||
| 	git config "url.$TRASH.pushInsteadOf" trash/ && | 	test_config "url.$TRASH.pushInsteadOf" trash/ && | ||||||
| 	git push trash/testrepo refs/heads/master:refs/remotes/origin/master && | 	git push trash/testrepo refs/heads/master:refs/remotes/origin/master && | ||||||
| 	( | 	( | ||||||
| 		cd testrepo && | 		cd testrepo && | ||||||
| 		r=$(git show-ref -s --verify refs/remotes/origin/master) && | 		echo "$the_commit commit	refs/remotes/origin/master" >expect && | ||||||
| 		test "z$r" = "z$the_commit" && | 		git for-each-ref refs/remotes/origin >actual && | ||||||
|  | 		test_cmp expect actual | ||||||
| 		test 1 = $(git for-each-ref refs/remotes/origin | wc -l) |  | ||||||
| 	) | 	) | ||||||
| ' | ' | ||||||
|  |  | ||||||
| test_expect_success 'push with pushInsteadOf and explicit pushurl (pushInsteadOf should not rewrite)' ' | test_expect_success 'push with pushInsteadOf and explicit pushurl (pushInsteadOf should not rewrite)' ' | ||||||
| 	mk_empty && | 	mk_empty && | ||||||
| 	TRASH="$(pwd)/" && | 	TRASH="$(pwd)/" && | ||||||
| 	git config "url.trash2/.pushInsteadOf" trash/ && | 	test_config "url.trash2/.pushInsteadOf" trash/ && | ||||||
| 	git config remote.r.url trash/wrong && | 	test_config remote.r.url trash/wrong && | ||||||
| 	git config remote.r.pushurl "$TRASH/testrepo" && | 	test_config remote.r.pushurl "$TRASH/testrepo" && | ||||||
| 	git push r refs/heads/master:refs/remotes/origin/master && | 	git push r refs/heads/master:refs/remotes/origin/master && | ||||||
| 	( | 	( | ||||||
| 		cd testrepo && | 		cd testrepo && | ||||||
| 		r=$(git show-ref -s --verify refs/remotes/origin/master) && | 		echo "$the_commit commit	refs/remotes/origin/master" >expect && | ||||||
| 		test "z$r" = "z$the_commit" && | 		git for-each-ref refs/remotes/origin >actual && | ||||||
|  | 		test_cmp expect actual | ||||||
| 		test 1 = $(git for-each-ref refs/remotes/origin | wc -l) |  | ||||||
| 	) | 	) | ||||||
| ' | ' | ||||||
|  |  | ||||||
| @ -340,13 +326,8 @@ test_expect_success 'push with weak ambiguity (2)' ' | |||||||
| test_expect_success 'push with ambiguity' ' | test_expect_success 'push with ambiguity' ' | ||||||
|  |  | ||||||
| 	mk_test heads/frotz tags/frotz && | 	mk_test heads/frotz tags/frotz && | ||||||
| 	if git push testrepo master:frotz | 	test_must_fail git push testrepo master:frotz && | ||||||
| 	then | 	check_push_result $the_first_commit heads/frotz tags/frotz | ||||||
| 		echo "Oops, should have failed" |  | ||||||
| 		false |  | ||||||
| 	else |  | ||||||
| 		check_push_result $the_first_commit heads/frotz tags/frotz |  | ||||||
| 	fi |  | ||||||
|  |  | ||||||
| ' | ' | ||||||
|  |  | ||||||
| @ -489,31 +470,24 @@ test_expect_success 'push with config remote.*.push = HEAD' ' | |||||||
| 		git checkout local && | 		git checkout local && | ||||||
| 		git reset --hard $the_first_commit | 		git reset --hard $the_first_commit | ||||||
| 	) && | 	) && | ||||||
| 	git config remote.there.url testrepo && | 	test_config remote.there.url testrepo && | ||||||
| 	git config remote.there.push HEAD && | 	test_config remote.there.push HEAD && | ||||||
| 	git config branch.master.remote there && | 	test_config branch.master.remote there && | ||||||
| 	git push && | 	git push && | ||||||
| 	check_push_result $the_commit heads/master && | 	check_push_result $the_commit heads/master && | ||||||
| 	check_push_result $the_first_commit heads/local | 	check_push_result $the_first_commit heads/local | ||||||
| ' | ' | ||||||
|  |  | ||||||
| # clean up the cruft left with the previous one |  | ||||||
| git config --remove-section remote.there |  | ||||||
| git config --remove-section branch.master |  | ||||||
|  |  | ||||||
| test_expect_success 'push with config remote.*.pushurl' ' | test_expect_success 'push with config remote.*.pushurl' ' | ||||||
|  |  | ||||||
| 	mk_test heads/master && | 	mk_test heads/master && | ||||||
| 	git checkout master && | 	git checkout master && | ||||||
| 	git config remote.there.url test2repo && | 	test_config remote.there.url test2repo && | ||||||
| 	git config remote.there.pushurl testrepo && | 	test_config remote.there.pushurl testrepo && | ||||||
| 	git push there && | 	git push there && | ||||||
| 	check_push_result $the_commit heads/master | 	check_push_result $the_commit heads/master | ||||||
| ' | ' | ||||||
|  |  | ||||||
| # clean up the cruft left with the previous one |  | ||||||
| git config --remove-section remote.there |  | ||||||
|  |  | ||||||
| test_expect_success 'push with dry-run' ' | test_expect_success 'push with dry-run' ' | ||||||
|  |  | ||||||
| 	mk_test heads/master && | 	mk_test heads/master && | ||||||
| @ -834,9 +808,9 @@ test_expect_success 'fetch with branches' ' | |||||||
| 	( | 	( | ||||||
| 		cd testrepo && | 		cd testrepo && | ||||||
| 		git fetch branch1 && | 		git fetch branch1 && | ||||||
| 		r=$(git show-ref -s --verify refs/heads/branch1) && | 		echo "$the_commit commit	refs/heads/branch1" >expect && | ||||||
| 		test "z$r" = "z$the_commit" && | 		git for-each-ref refs/heads >actual && | ||||||
| 		test 1 = $(git for-each-ref refs/heads | wc -l) | 		test_cmp expect actual | ||||||
| 	) && | 	) && | ||||||
| 	git checkout master | 	git checkout master | ||||||
| ' | ' | ||||||
| @ -847,9 +821,9 @@ test_expect_success 'fetch with branches containing #' ' | |||||||
| 	( | 	( | ||||||
| 		cd testrepo && | 		cd testrepo && | ||||||
| 		git fetch branch2 && | 		git fetch branch2 && | ||||||
| 		r=$(git show-ref -s --verify refs/heads/branch2) && | 		echo "$the_first_commit commit	refs/heads/branch2" >expect && | ||||||
| 		test "z$r" = "z$the_first_commit" && | 		git for-each-ref refs/heads >actual && | ||||||
| 		test 1 = $(git for-each-ref refs/heads | wc -l) | 		test_cmp expect actual | ||||||
| 	) && | 	) && | ||||||
| 	git checkout master | 	git checkout master | ||||||
| ' | ' | ||||||
| @ -861,9 +835,9 @@ test_expect_success 'push with branches' ' | |||||||
| 	git push branch1 && | 	git push branch1 && | ||||||
| 	( | 	( | ||||||
| 		cd testrepo && | 		cd testrepo && | ||||||
| 		r=$(git show-ref -s --verify refs/heads/master) && | 		echo "$the_first_commit commit	refs/heads/master" >expect && | ||||||
| 		test "z$r" = "z$the_first_commit" && | 		git for-each-ref refs/heads >actual && | ||||||
| 		test 1 = $(git for-each-ref refs/heads | wc -l) | 		test_cmp expect actual | ||||||
| 	) | 	) | ||||||
| ' | ' | ||||||
|  |  | ||||||
| @ -873,9 +847,9 @@ test_expect_success 'push with branches containing #' ' | |||||||
| 	git push branch2 && | 	git push branch2 && | ||||||
| 	( | 	( | ||||||
| 		cd testrepo && | 		cd testrepo && | ||||||
| 		r=$(git show-ref -s --verify refs/heads/branch3) && | 		echo "$the_first_commit commit	refs/heads/branch3" >expect && | ||||||
| 		test "z$r" = "z$the_first_commit" && | 		git for-each-ref refs/heads >actual && | ||||||
| 		test 1 = $(git for-each-ref refs/heads | wc -l) | 		test_cmp expect actual | ||||||
| 	) && | 	) && | ||||||
| 	git checkout master | 	git checkout master | ||||||
| ' | ' | ||||||
| @ -958,9 +932,9 @@ test_expect_success 'push --porcelain' ' | |||||||
| 	git push >.git/bar --porcelain  testrepo refs/heads/master:refs/remotes/origin/master && | 	git push >.git/bar --porcelain  testrepo refs/heads/master:refs/remotes/origin/master && | ||||||
| 	( | 	( | ||||||
| 		cd testrepo && | 		cd testrepo && | ||||||
| 		r=$(git show-ref -s --verify refs/remotes/origin/master) && | 		echo "$the_commit commit	refs/remotes/origin/master" >expect && | ||||||
| 		test "z$r" = "z$the_commit" && | 		git for-each-ref refs/remotes/origin >actual && | ||||||
| 		test 1 = $(git for-each-ref refs/remotes/origin | wc -l) | 		test_cmp expect actual | ||||||
| 	) && | 	) && | ||||||
| 	test_cmp .git/foo .git/bar | 	test_cmp .git/foo .git/bar | ||||||
| ' | ' | ||||||
|  | |||||||
		Reference in New Issue
	
	Block a user
	 Junio C Hamano
					Junio C Hamano