Skip to content

Commit

Permalink
ref_transaction_commit(): provide better error messages
Browse files Browse the repository at this point in the history
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 <mhagger@alum.mit.edu>
  • Loading branch information
Michael Haggerty authored and Junio C Hamano committed May 11, 2015
1 parent abeef9c commit cbaabcb
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions refs.c
Original file line number Diff line number Diff line change
Expand Up @@ -3838,13 +3838,15 @@ int ref_transaction_commit(struct ref_transaction *transaction,
&update->type,
err);
if (!update->lock) {
char *reason;

ret = (errno == ENOTDIR)
? TRANSACTION_NAME_CONFLICT
: TRANSACTION_GENERIC_ERROR;
error("%s", err->buf);
strbuf_reset(err);
strbuf_addf(err, "Cannot lock the ref '%s'.",
update->refname);
reason = strbuf_detach(err, NULL);
strbuf_addf(err, "Cannot lock the ref '%s': %s",
update->refname, reason);
free(reason);
goto cleanup;
}
}
Expand Down

0 comments on commit cbaabcb

Please sign in to comment.