git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: "Ævar Arnfjörð Bjarmason" <avarab@gmail.com>
To: git@vger.kernel.org
Cc: "Junio C Hamano" <gitster@pobox.com>,
	"Han-Wen Nienhuys" <hanwen@google.com>,
	"Ævar Arnfjörð Bjarmason" <avarab@gmail.com>
Subject: [PATCH 2/3] sequencer: don't use die_errno() on refs_resolve_ref_unsafe() failure
Date: Thu,  9 Dec 2021 06:02:27 +0100	[thread overview]
Message-ID: <patch-2.3-a4d1dadb9c9-20211209T045735Z-avarab@gmail.com> (raw)
In-Reply-To: <cover-0.3-00000000000-20211209T045735Z-avarab@gmail.com>

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.

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.

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 b4135a78c91..a649bd737ba 100644
--- a/sequencer.c
+++ b/sequencer.c
@@ -1285,7 +1285,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)
@@ -1337,11 +1337,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
-- 
2.34.1.930.g218b4aae189


  parent reply	other threads:[~2021-12-09  5:03 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-12-08 11:38 errno oversight Han-Wen Nienhuys
2021-12-08 12:47 ` Ævar Arnfjörð Bjarmason
2021-12-08 13:00   ` Ævar Arnfjörð Bjarmason
2021-12-08 19:02     ` Junio C Hamano
2021-12-09  5:02       ` [PATCH 0/3] refs: ab/refs-errno-cleanup fixup + remove "failure_errno" Ævar Arnfjörð Bjarmason
2021-12-09  5:02         ` [PATCH 1/3] refs API: use "failure_errno", not "errno" Ævar Arnfjörð Bjarmason
2021-12-09  5:02         ` Ævar Arnfjörð Bjarmason [this message]
2021-12-09  5:02         ` [PATCH 3/3] refs API: remove "failure_errno" from refs_resolve_ref_unsafe() Ævar Arnfjörð Bjarmason
2021-12-12 19:53         ` [PATCH v2 0/3] refs: ab/refs-errno-cleanup fixup + remove "failure_errno" Ævar Arnfjörð Bjarmason
2021-12-12 19:53           ` [PATCH v2 1/3] refs API: use "failure_errno", not "errno" Ævar Arnfjörð Bjarmason
2021-12-12 19:53           ` [PATCH v2 2/3] sequencer: don't use die_errno() on refs_resolve_ref_unsafe() failure Ævar Arnfjörð Bjarmason
2021-12-12 19:53           ` [PATCH v2 3/3] refs API: remove "failure_errno" from refs_resolve_ref_unsafe() Ævar Arnfjörð Bjarmason
2022-01-12 12:36           ` [PATCH v3 0/3] For v2.35.0: refs: ab/refs-errno-cleanup fixup + remove "failure_errno" Ævar Arnfjörð Bjarmason
2022-01-12 12:36             ` [PATCH v3 1/3] refs API: use "failure_errno", not "errno" Ævar Arnfjörð Bjarmason
2022-01-12 19:59               ` Junio C Hamano
2022-01-13 12:14                 ` Ævar Arnfjörð Bjarmason
2022-01-12 12:36             ` [PATCH v3 2/3] sequencer: don't use die_errno() on refs_resolve_ref_unsafe() failure Ævar Arnfjörð Bjarmason
2022-01-12 20:02               ` Junio C Hamano
2022-01-12 12:36             ` [PATCH v3 3/3] refs API: remove "failure_errno" from refs_resolve_ref_unsafe() Ævar Arnfjörð Bjarmason
2022-01-12 19:34             ` [PATCH v3 0/3] For v2.35.0: refs: ab/refs-errno-cleanup fixup + remove "failure_errno" Junio C Hamano
2022-01-13 12:22               ` Ævar Arnfjörð Bjarmason
2022-01-13 18:54                 ` Junio C Hamano
2022-01-14 12:21                   ` Ævar Arnfjörð Bjarmason
2022-01-26 14:36               ` [PATCH v4 0/2] refs: remove the last use of "errno" from the public API Ævar Arnfjörð Bjarmason
2022-01-26 14:37                 ` [PATCH v4 1/2] sequencer: don't use die_errno() on refs_resolve_ref_unsafe() failure Ævar Arnfjörð Bjarmason
2022-01-26 23:57                   ` Junio C Hamano
2022-01-26 14:37                 ` [PATCH v4 2/2] refs API: remove "failure_errno" from refs_resolve_ref_unsafe() Ævar Arnfjörð Bjarmason
2021-12-08 13:05   ` errno oversight Han-Wen Nienhuys

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=patch-2.3-a4d1dadb9c9-20211209T045735Z-avarab@gmail.com \
    --to=avarab@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=hanwen@google.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).