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

Re: [PATCH v2] commit: check result of resolve_ref_unsafe

From
Andrey Okoshkin <a.okoshkin@samsung.com>
Date
Oct 20, 2017, 10:40 UTC
Message-ID
<19dc9ff5-54f3-290a-2dc8-c0be8e4047eb@samsung.com>
In-Reply-To
<20171019174452.hd3c47ocducddvgr@sigill.intra.peff.net>
19.10.2017 20:44, Jeff King wrote:
Show 11 quoted lines
> On Thu, Oct 19, 2017 at 12:36:50PM +0300, Andrey Okoshkin wrote:
> 
> Thanks, this looks good to me. One other possible minor improvement:
> 
>>   	head = resolve_ref_unsafe("HEAD", 0, junk_oid.hash, NULL);
>> +	if (!head)
>> +		die(_("unable to resolve HEAD after creating commit"));
> 
> Should we use die_errno() here to report the value of errno? I think
> resolve_ref_unsafe() should set it consistently (even an internal
> problem, like an illegally-formatted refname, yields EINVAL).

Thanks, sounds relevant. Also as an alternative solution it's possible to use warning_errno (instead of die_errno) and continue with 'head' set to something like 'unreadable|bad HEAD'.

Show 17 quoted lines
> I grepped the code base looking for other instances of the same problem,
> and found four of them. Patches to follow.
> 
> Unlike this one, I ended up quietly returning an error in most cases.
> The individual commit messages discuss the reasoning for each case, but
> I do wonder if we ought to simply die() in each case out of an abundance
> of caution (either the repo has a broken symref, or some weird
> filesystem error occurred, but either way it may be best not to
> continue). I dunno.
> 
> These are all independent, so can be applied in any order or combination
> with respect to each other and to your patch.
> 
>    [1/4]: test-ref-store: avoid passing NULL to printf
>    [2/4]: remote: handle broken symrefs
>    [3/4]: log: handle broken HEAD in decoration check
>    [4/4]: worktree: handle broken symrefs in find_shared_symref()
Good changes, it's better to apply.
-- 
Best regards,
Andrey
Previous: Junio C HamanoNext: Andrey Okoshkin
Message 16 of 20 in “commit: check result of resolve_ref_unsafe”
  1. commit: check result of resolve_ref_unsafeAndrey Okoshkin, Oct 18, 2017
  2. Jeff KingOct 18, 2017
  3. Junio C HamanoOct 19, 2017
  4. Jeff KingOct 19, 2017
  5. Andrey OkoshkinOct 19, 2017
  6. commit: check result of resolve_ref_unsafeAndrey Okoshkin, Oct 19, 2017
  7. Jeff KingOct 19, 2017
  8. 1/4 test-ref-store: avoid passing NULL to printfJeff King, Oct 19, 2017
  9. 2/4 remote: handle broken symrefsJeff King, Oct 19, 2017
  10. Jeff KingOct 19, 2017
  11. 3/4 log: handle broken HEAD in decoration checkJeff King, Oct 19, 2017
  12. 4/4 worktree: handle broken symrefs in find_shared_symref()Jeff King, Oct 19, 2017
  13. Eric SunshineOct 21, 2017
  14. Jeff KingOct 21, 2017
  15. Junio C HamanoOct 22, 2017
  16. Andrey OkoshkinOct 20, 2017
  17. commit: check result of resolve_ref_unsafeAndrey Okoshkin, Oct 20, 2017
  18. commit: check result of resolve_ref_unsafeAndrey Okoshkin, Oct 20, 2017
  19. Jeff KingOct 21, 2017
  20. Junio C HamanoOct 22, 2017

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.