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

Re: [PATCH v3 2/3] sequencer: don't use die_errno() on refs_resolve_ref_unsafe() failure

From
Junio C Hamano <gitster@pobox.com>
Date
Jan 12, 2022, 20:02 UTC
Message-ID
<xmqqczkwu3h1.fsf@gitster.g>
In-Reply-To
<patch-v3-2.3-8d8691a5e93-20220112T123117Z-avarab@gmail.com>
Ævar Arnfjörð Bjarmason  <avarab@gmail.com> writes:
Show 9 quoted lines
> Change code that was faithfully migrated to the new "resolve_errno"
> API in ed90f04155d (refs API: make resolve_ref_unsafe() not set errno,
> 2021-10-16) to stop caring about the errno at all.
>
> When we fail to resolve "HEAD" after the sequencer runs it doesn't
> really help to say what the "errno" value is, since the fake backend
> errno may or may not reflect anything real about the state of the
> ".git/HEAD". With the upcoming reftable backend this fakery will
> become even more pronounced.

OK. In principle I agree with the reasoning. Perhaps it can be better done as a preparation for the reftable backend in future cycles, not now.

> So let's just die() instead of die_errno() here. This will also help
> simplify the refs_resolve_ref_unsafe() API. This was the only user of
> it that wasn't ignoring the "failure_errno" output parameter.
Show 33 quoted lines
> Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
> ---
>  sequencer.c | 10 ++++------
>  1 file changed, 4 insertions(+), 6 deletions(-)
>
> diff --git a/sequencer.c b/sequencer.c
> index 6abd72160cc..03cdf548d72 100644
> --- a/sequencer.c
> +++ b/sequencer.c
> @@ -1281,7 +1281,7 @@ void print_commit_summary(struct repository *r,
>  	struct strbuf author_ident = STRBUF_INIT;
>  	struct strbuf committer_ident = STRBUF_INIT;
>  	struct ref_store *refs;
> -	int resolve_errno;
> +	int ignore_errno;
>  
>  	commit = lookup_commit(r, oid);
>  	if (!commit)
> @@ -1333,11 +1333,9 @@ void print_commit_summary(struct repository *r,
>  
>  	refs = get_main_ref_store(the_repository);
>  	head = refs_resolve_ref_unsafe(refs, "HEAD", 0, NULL, NULL,
> -				       &resolve_errno);
> -	if (!head) {
> -		errno = resolve_errno;
> -		die_errno(_("unable to resolve HEAD after creating commit"));
> -	}
> +				       &ignore_errno);
> +	if (!head)
> +		die(_("unable to resolve HEAD after creating commit"));
>  	if (!strcmp(head, "HEAD"))
>  		head = _("detached HEAD");
>  	else
Previous: Ævar Arnfjörð BjarmasonNext: Ævar Arnfjörð Bjarmason
Message 18 of 28 in “errno oversight”
  1. Han-Wen NienhuysDec 8, 2021
  2. Ævar Arnfjörð BjarmasonDec 8, 2021
  3. Ævar Arnfjörð BjarmasonDec 8, 2021
  4. Junio C HamanoDec 8, 2021
  5. 0/3 refs: ab/refs-errno-cleanup fixup + remove "failure_errno"Ævar Arnfjörð Bjarmason, Dec 9, 2021
  6. 1/3 refs API: use "failure_errno", not "errno"Ævar Arnfjörð Bjarmason, Dec 9, 2021
  7. 2/3 sequencer: don't use die_errno() on refs_resolve_ref_unsafe() failureÆvar Arnfjörð Bjarmason, Dec 9, 2021
  8. 3/3 refs API: remove "failure_errno" from refs_resolve_ref_unsafe()Ævar Arnfjörð Bjarmason, Dec 9, 2021
  9. 0/3 refs: ab/refs-errno-cleanup fixup + remove "failure_errno"Ævar Arnfjörð Bjarmason, Dec 12, 2021
  10. 1/3 refs API: use "failure_errno", not "errno"Ævar Arnfjörð Bjarmason, Dec 12, 2021
  11. 2/3 sequencer: don't use die_errno() on refs_resolve_ref_unsafe() failureÆvar Arnfjörð Bjarmason, Dec 12, 2021
  12. 3/3 refs API: remove "failure_errno" from refs_resolve_ref_unsafe()Ævar Arnfjörð Bjarmason, Dec 12, 2021
  13. 0/3 For v2.35.0: refs: ab/refs-errno-cleanup fixup + remove "failure_errno"Ævar Arnfjörð Bjarmason, Jan 12, 2022
  14. 1/3 refs API: use "failure_errno", not "errno"Ævar Arnfjörð Bjarmason, Jan 12, 2022
  15. Junio C HamanoJan 12, 2022
  16. Ævar Arnfjörð BjarmasonJan 13, 2022
  17. 2/3 sequencer: don't use die_errno() on refs_resolve_ref_unsafe() failureÆvar Arnfjörð Bjarmason, Jan 12, 2022
  18. Junio C HamanoJan 12, 2022
  19. 3/3 refs API: remove "failure_errno" from refs_resolve_ref_unsafe()Ævar Arnfjörð Bjarmason, Jan 12, 2022
  20. Junio C HamanoJan 12, 2022
  21. Ævar Arnfjörð BjarmasonJan 13, 2022
  22. Junio C HamanoJan 13, 2022
  23. Ævar Arnfjörð BjarmasonJan 14, 2022
  24. 0/2 refs: remove the last use of "errno" from the public APIÆvar Arnfjörð Bjarmason, Jan 26, 2022
  25. 1/2 sequencer: don't use die_errno() on refs_resolve_ref_unsafe() failureÆvar Arnfjörð Bjarmason, Jan 26, 2022
  26. Junio C HamanoJan 26, 2022
  27. 2/2 refs API: remove "failure_errno" from refs_resolve_ref_unsafe()Ævar Arnfjörð Bjarmason, Jan 26, 2022
  28. Han-Wen NienhuysDec 8, 2021

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.