Skip to content

Commit e10fa19

Browse files
jiangxingitster
authored andcommitted
fetch: no redundant error message for atomic fetch
If an error occurs during an atomic fetch, a redundant error message will appear at the end of do_fetch(). It was introduced in b3a8046 (fetch: make `--atomic` flag cover backfilling of tags, 2022-02-17). In function do_fetch(), a failure message is already shown before the retcode is set, so we should not call additional error() at the end of this function. We can remove the redundant error() function, because we know that the function ref_transaction_abort() never fails. While we can find a common pattern for calling ref_transaction_abort() by running command "git grep -A1 ref_transaction_abort", e.g.: if (ref_transaction_abort(transaction, &error)) error("abort: %s", error.buf); We can fix this issue follow this pattern, and the test case "fetch porcelain output (atomic)" in t5574 will also be fixed. If in the future we decide that we don't need to check the return value of the function ref_transaction_abort(), this change can be fixed along with it. Signed-off-by: Jiang Xin <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 0b9865f commit e10fa19

File tree

2 files changed

+2
-4
lines changed

2 files changed

+2
-4
lines changed

builtin/fetch.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1775,10 +1775,8 @@ static int do_fetch(struct transport *transport,
17751775
}
17761776

17771777
cleanup:
1778-
if (retcode && transaction) {
1779-
ref_transaction_abort(transaction, &err);
1778+
if (retcode && transaction && ref_transaction_abort(transaction, &err))
17801779
error("%s", err.buf);
1781-
}
17821780

17831781
display_state_release(&display_state);
17841782
close_fetch_head(&fetch_head);

t/t5574-fetch-output.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ do
9898
opt=
9999
;;
100100
esac
101-
test_expect_failure "fetch porcelain output ${opt:+(atomic)}" '
101+
test_expect_success "fetch porcelain output ${opt:+(atomic)}" '
102102
test_when_finished "rm -rf porcelain" &&
103103
104104
# Clone and pre-seed the repositories. We fetch references into two

0 commit comments

Comments
 (0)