git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH 1/6] refs.c: add an err argument to log_ref_setup

From
Junio C Hamano <gitster@pobox.com>
Date
Jun 25, 2015, 16:15 UTC
Message-ID
<xmqqzj3nzrv6.fsf@gitster.dls.corp.google.com>
In-Reply-To
<1435173388-8346-2-git-send-email-dturner@twopensource.com>
David Turner <dturner@twopensource.com> writes:
Show 5 quoted lines
> Add 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.

I think I saw Michael did something similar to other codepaths in the ref API recently, and going in the same direction is generally a good thing to do for consistency ;-)

> write_ref_to_lockfile is a private function that calls
> log_ref_setup. Update this function to also take an err argument and
> fill it in.  This again eliminates the need to manage errno in this
> function.

This particular patch is not just about log_ref_setup() and its private friend write_ref_to_lockfile(), right? It seems to also touch commit_ref_update(), log_ref_write(), etc. The overall "theme" of this change is to teach parts of the ref API that deal with writing reflogs to report errors the same way (i.e. as the remainder of the ref API does by using &err), and that may be a good single-line summary of the change (aka "Subject").

Show 5 quoted lines
>  				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);

Original is underindented but this makes it even worse. Push continuation line further to the right (or restructure the code so that it does not have to indent too deeply in the first place).

Other than that, this step looks sensible.
Thanks.
Previous: David TurnerNext: David Turner
Message 3 of 16 in “refs backend preamble”
  1. 0/6 refs backend preambleDavid Turner, Jun 24, 2015
  2. 1/6 refs.c: add an err argument to log_ref_setupDavid Turner, Jun 24, 2015
  3. Junio C HamanoJun 25, 2015
  4. 2/6 cherry-pick: Use refs infrastructure for CHERRY_PICK_HEADDavid Turner, Jun 24, 2015
  5. Junio C HamanoJun 25, 2015
  6. 3/6 bisect: use refs infrastructure for BISECT_STARTDavid Turner, Jun 24, 2015
  7. Junio C HamanoJun 25, 2015
  8. David TurnerJun 25, 2015
  9. 4/6 refs: replace log_ref_write with create_reflogDavid Turner, Jun 24, 2015
  10. Junio C HamanoJun 25, 2015
  11. 5/6 git-reflog: add create and exists functionsDavid Turner, Jun 24, 2015
  12. Junio C HamanoJun 25, 2015
  13. Junio C HamanoJun 25, 2015
  14. David TurnerJun 25, 2015
  15. 6/6 git-stash: use git-reflog instead of creating filesDavid Turner, Jun 24, 2015
  16. Junio C HamanoJun 25, 2015

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.