diff options
author | David Turner <dturner@twopensource.com> | 2015-07-21 17:04:50 -0400 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2015-07-21 14:07:28 -0700 |
commit | a4c653dfcd05c987028b847092a1ee7e5d86a596 (patch) | |
tree | 165a443b3011713619fee6ea2c046039edf96568 /builtin | |
parent | Sync with maint (diff) | |
download | tgif-a4c653dfcd05c987028b847092a1ee7e5d86a596.tar.xz |
refs.c: add err arguments to reflog functions
Add an err argument to log_ref_setup that can explain the reason
for a failure. This then eliminates the need to manage errno through
this function since we can just add strerror(errno) to the err string
when meaningful. No callers relied on errno from this function for
anything else than the error message.
Also add err arguments to private functions write_ref_to_lockfile,
log_ref_write_1, commit_ref_update. This again eliminates the need to
manage errno in these functions.
Some error messages are slightly reordered.
Update of a patch by Ronnie Sahlberg.
Signed-off-by: Ronnie Sahlberg <sahlberg@google.com>
Signed-off-by: David Turner <dturner@twopensource.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin')
-rw-r--r-- | builtin/checkout.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/builtin/checkout.c b/builtin/checkout.c index 9b49f0e413..8faa2d141d 100644 --- a/builtin/checkout.c +++ b/builtin/checkout.c @@ -623,16 +623,18 @@ static void update_refs_for_switch(const struct checkout_opts *opts, struct strbuf log_file = STRBUF_INIT; int ret; const char *ref_name; + struct strbuf err = STRBUF_INIT; ref_name = mkpath("refs/heads/%s", opts->new_orphan_branch); temp = log_all_ref_updates; log_all_ref_updates = 1; - ret = log_ref_setup(ref_name, &log_file); + ret = log_ref_setup(ref_name, &log_file, &err); log_all_ref_updates = temp; strbuf_release(&log_file); if (ret) { - fprintf(stderr, _("Can not do reflog for '%s'\n"), - opts->new_orphan_branch); + fprintf(stderr, _("Can not do reflog for '%s': %s\n"), + opts->new_orphan_branch, err.buf); + strbuf_release(&err); return; } } |