Skip to content

Commit cbaabcb

Browse files
mhaggergitster
authored andcommitted
ref_transaction_commit(): provide better error messages
Now that lock_ref_sha1_basic() gives us back its error messages via a strbuf, incorporate its error message into our error message rather than emitting one error messages to stderr immediately and returning a second to our caller. Signed-off-by: Michael Haggerty <[email protected]>
1 parent abeef9c commit cbaabcb

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

refs.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3838,13 +3838,15 @@ int ref_transaction_commit(struct ref_transaction *transaction,
38383838
&update->type,
38393839
err);
38403840
if (!update->lock) {
3841+
char *reason;
3842+
38413843
ret = (errno == ENOTDIR)
38423844
? TRANSACTION_NAME_CONFLICT
38433845
: TRANSACTION_GENERIC_ERROR;
3844-
error("%s", err->buf);
3845-
strbuf_reset(err);
3846-
strbuf_addf(err, "Cannot lock the ref '%s'.",
3847-
update->refname);
3846+
reason = strbuf_detach(err, NULL);
3847+
strbuf_addf(err, "Cannot lock the ref '%s': %s",
3848+
update->refname, reason);
3849+
free(reason);
38483850
goto cleanup;
38493851
}
38503852
}

0 commit comments

Comments
 (0)