Merge branch 'jx/fetch-atomic-error-message-fix'
"git fetch --atomic" issued an unnecessary empty error message, which has been corrected. * jx/fetch-atomic-error-message-fix: fetch: no redundant error message for atomic fetch t5574: test porcelain output of atomic fetch
This commit is contained in:
		| @ -1651,7 +1651,7 @@ static int do_fetch(struct transport *transport, | |||||||
| 	if (atomic_fetch) { | 	if (atomic_fetch) { | ||||||
| 		transaction = ref_transaction_begin(&err); | 		transaction = ref_transaction_begin(&err); | ||||||
| 		if (!transaction) { | 		if (!transaction) { | ||||||
| 			retcode = error("%s", err.buf); | 			retcode = -1; | ||||||
| 			goto cleanup; | 			goto cleanup; | ||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
| @ -1711,7 +1711,6 @@ static int do_fetch(struct transport *transport, | |||||||
|  |  | ||||||
| 		retcode = ref_transaction_commit(transaction, &err); | 		retcode = ref_transaction_commit(transaction, &err); | ||||||
| 		if (retcode) { | 		if (retcode) { | ||||||
| 			error("%s", err.buf); |  | ||||||
| 			ref_transaction_free(transaction); | 			ref_transaction_free(transaction); | ||||||
| 			transaction = NULL; | 			transaction = NULL; | ||||||
| 			goto cleanup; | 			goto cleanup; | ||||||
| @ -1775,9 +1774,14 @@ static int do_fetch(struct transport *transport, | |||||||
| 	} | 	} | ||||||
|  |  | ||||||
| cleanup: | cleanup: | ||||||
| 	if (retcode && transaction) { | 	if (retcode) { | ||||||
| 		ref_transaction_abort(transaction, &err); | 		if (err.len) { | ||||||
| 		error("%s", err.buf); | 			error("%s", err.buf); | ||||||
|  | 			strbuf_reset(&err); | ||||||
|  | 		} | ||||||
|  | 		if (transaction && ref_transaction_abort(transaction, &err) && | ||||||
|  | 		    err.len) | ||||||
|  | 			error("%s", err.buf); | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	display_state_release(&display_state); | 	display_state_release(&display_state); | ||||||
|  | |||||||
| @ -61,11 +61,10 @@ test_expect_success 'fetch compact output' ' | |||||||
| 	test_cmp expect actual | 	test_cmp expect actual | ||||||
| ' | ' | ||||||
|  |  | ||||||
| test_expect_success 'fetch porcelain output' ' | test_expect_success 'setup for fetch porcelain output' ' | ||||||
| 	test_when_finished "rm -rf porcelain" && |  | ||||||
|  |  | ||||||
| 	# Set up a bunch of references that we can use to demonstrate different | 	# Set up a bunch of references that we can use to demonstrate different | ||||||
| 	# kinds of flag symbols in the output format. | 	# kinds of flag symbols in the output format. | ||||||
|  | 	test_commit commit-for-porcelain-output && | ||||||
| 	MAIN_OLD=$(git rev-parse HEAD) && | 	MAIN_OLD=$(git rev-parse HEAD) && | ||||||
| 	git branch "fast-forward" && | 	git branch "fast-forward" && | ||||||
| 	git branch "deleted-branch" && | 	git branch "deleted-branch" && | ||||||
| @ -74,15 +73,10 @@ test_expect_success 'fetch porcelain output' ' | |||||||
| 	FORCE_UPDATED_OLD=$(git rev-parse HEAD) && | 	FORCE_UPDATED_OLD=$(git rev-parse HEAD) && | ||||||
| 	git checkout main && | 	git checkout main && | ||||||
|  |  | ||||||
| 	# Clone and pre-seed the repositories. We fetch references into two | 	# Backup to preseed.git | ||||||
| 	# namespaces so that we can test that rejected and force-updated | 	git clone --mirror . preseed.git && | ||||||
| 	# references are reported properly. |  | ||||||
| 	refspecs="refs/heads/*:refs/unforced/* +refs/heads/*:refs/forced/*" && |  | ||||||
| 	git clone . porcelain && |  | ||||||
| 	git -C porcelain fetch origin $refspecs && |  | ||||||
|  |  | ||||||
| 	# Now that we have set up the client repositories we can change our | 	# Continue changing our local references. | ||||||
| 	# local references. |  | ||||||
| 	git branch new-branch && | 	git branch new-branch && | ||||||
| 	git branch -d deleted-branch && | 	git branch -d deleted-branch && | ||||||
| 	git checkout fast-forward && | 	git checkout fast-forward && | ||||||
| @ -91,36 +85,53 @@ test_expect_success 'fetch porcelain output' ' | |||||||
| 	git checkout force-updated && | 	git checkout force-updated && | ||||||
| 	git reset --hard HEAD~ && | 	git reset --hard HEAD~ && | ||||||
| 	test_commit --no-tag force-update-new && | 	test_commit --no-tag force-update-new && | ||||||
| 	FORCE_UPDATED_NEW=$(git rev-parse HEAD) && | 	FORCE_UPDATED_NEW=$(git rev-parse HEAD) | ||||||
|  |  | ||||||
| 	cat >expect <<-EOF && |  | ||||||
| 	- $MAIN_OLD $ZERO_OID refs/forced/deleted-branch |  | ||||||
| 	- $MAIN_OLD $ZERO_OID refs/unforced/deleted-branch |  | ||||||
| 	  $MAIN_OLD $FAST_FORWARD_NEW refs/unforced/fast-forward |  | ||||||
| 	! $FORCE_UPDATED_OLD $FORCE_UPDATED_NEW refs/unforced/force-updated |  | ||||||
| 	* $ZERO_OID $MAIN_OLD refs/unforced/new-branch |  | ||||||
| 	  $MAIN_OLD $FAST_FORWARD_NEW refs/forced/fast-forward |  | ||||||
| 	+ $FORCE_UPDATED_OLD $FORCE_UPDATED_NEW refs/forced/force-updated |  | ||||||
| 	* $ZERO_OID $MAIN_OLD refs/forced/new-branch |  | ||||||
| 	  $MAIN_OLD $FAST_FORWARD_NEW refs/remotes/origin/fast-forward |  | ||||||
| 	+ $FORCE_UPDATED_OLD $FORCE_UPDATED_NEW refs/remotes/origin/force-updated |  | ||||||
| 	* $ZERO_OID $MAIN_OLD refs/remotes/origin/new-branch |  | ||||||
| 	EOF |  | ||||||
|  |  | ||||||
| 	# Execute a dry-run fetch first. We do this to assert that the dry-run |  | ||||||
| 	# and non-dry-run fetches produces the same output. Execution of the |  | ||||||
| 	# fetch is expected to fail as we have a rejected reference update. |  | ||||||
| 	test_must_fail git -C porcelain fetch \ |  | ||||||
| 		--porcelain --dry-run --prune origin $refspecs >actual && |  | ||||||
| 	test_cmp expect actual && |  | ||||||
|  |  | ||||||
| 	# And now we perform a non-dry-run fetch. |  | ||||||
| 	test_must_fail git -C porcelain fetch \ |  | ||||||
| 		--porcelain --prune origin $refspecs >actual 2>stderr && |  | ||||||
| 	test_cmp expect actual && |  | ||||||
| 	test_must_be_empty stderr |  | ||||||
| ' | ' | ||||||
|  |  | ||||||
|  | for opt in "" "--atomic" | ||||||
|  | do | ||||||
|  | 	test_expect_success "fetch porcelain output ${opt:+(atomic)}" ' | ||||||
|  | 		test_when_finished "rm -rf porcelain" && | ||||||
|  |  | ||||||
|  | 		# Clone and pre-seed the repositories. We fetch references into two | ||||||
|  | 		# namespaces so that we can test that rejected and force-updated | ||||||
|  | 		# references are reported properly. | ||||||
|  | 		refspecs="refs/heads/*:refs/unforced/* +refs/heads/*:refs/forced/*" && | ||||||
|  | 		git clone preseed.git porcelain && | ||||||
|  | 		git -C porcelain fetch origin $opt $refspecs && | ||||||
|  |  | ||||||
|  | 		cat >expect <<-EOF && | ||||||
|  | 		- $MAIN_OLD $ZERO_OID refs/forced/deleted-branch | ||||||
|  | 		- $MAIN_OLD $ZERO_OID refs/unforced/deleted-branch | ||||||
|  | 		  $MAIN_OLD $FAST_FORWARD_NEW refs/unforced/fast-forward | ||||||
|  | 		! $FORCE_UPDATED_OLD $FORCE_UPDATED_NEW refs/unforced/force-updated | ||||||
|  | 		* $ZERO_OID $MAIN_OLD refs/unforced/new-branch | ||||||
|  | 		  $MAIN_OLD $FAST_FORWARD_NEW refs/forced/fast-forward | ||||||
|  | 		+ $FORCE_UPDATED_OLD $FORCE_UPDATED_NEW refs/forced/force-updated | ||||||
|  | 		* $ZERO_OID $MAIN_OLD refs/forced/new-branch | ||||||
|  | 		  $MAIN_OLD $FAST_FORWARD_NEW refs/remotes/origin/fast-forward | ||||||
|  | 		+ $FORCE_UPDATED_OLD $FORCE_UPDATED_NEW refs/remotes/origin/force-updated | ||||||
|  | 		* $ZERO_OID $MAIN_OLD refs/remotes/origin/new-branch | ||||||
|  | 		EOF | ||||||
|  |  | ||||||
|  | 		# Change the URL of the repository to fetch different references. | ||||||
|  | 		git -C porcelain remote set-url origin .. && | ||||||
|  |  | ||||||
|  | 		# Execute a dry-run fetch first. We do this to assert that the dry-run | ||||||
|  | 		# and non-dry-run fetches produces the same output. Execution of the | ||||||
|  | 		# fetch is expected to fail as we have a rejected reference update. | ||||||
|  | 		test_must_fail git -C porcelain fetch $opt \ | ||||||
|  | 			--porcelain --dry-run --prune origin $refspecs >actual && | ||||||
|  | 		test_cmp expect actual && | ||||||
|  |  | ||||||
|  | 		# And now we perform a non-dry-run fetch. | ||||||
|  | 		test_must_fail git -C porcelain fetch $opt \ | ||||||
|  | 			--porcelain --prune origin $refspecs >actual 2>stderr && | ||||||
|  | 		test_cmp expect actual && | ||||||
|  | 		test_must_be_empty stderr | ||||||
|  | 	' | ||||||
|  | done | ||||||
|  |  | ||||||
| test_expect_success 'fetch porcelain with multiple remotes' ' | test_expect_success 'fetch porcelain with multiple remotes' ' | ||||||
| 	test_when_finished "rm -rf porcelain" && | 	test_when_finished "rm -rf porcelain" && | ||||||
|  |  | ||||||
|  | |||||||
		Reference in New Issue
	
	Block a user
	 Junio C Hamano
					Junio C Hamano