From: Patrick Steinhardt <ps@pks.im>
To: Taylor Blau <me@ttaylorr.com>
Cc: git@vger.kernel.org, hanwenn@gmail.com
Subject: Re: [PATCH 2/4] refs: propagate errno when reading special refs fails
Date: Thu, 30 Nov 2023 08:43:37 +0100 [thread overview]
Message-ID: <ZWg9KfpeyLRdX1b8@tanuki> (raw)
In-Reply-To: <ZWeyUU/NqmGUvyOL@nand.local>
[-- Attachment #1: Type: text/plain, Size: 1518 bytes --]
On Wed, Nov 29, 2023 at 04:51:13PM -0500, Taylor Blau wrote:
> On Wed, Nov 29, 2023 at 09:14:16AM +0100, Patrick Steinhardt wrote:
> > diff --git a/refs.c b/refs.c
> > index fcae5dddc6..7d4a057f36 100644
> > --- a/refs.c
> > +++ b/refs.c
> > @@ -1806,8 +1806,12 @@ static int refs_read_special_head(struct ref_store *ref_store,
> > int result = -1;
> > strbuf_addf(&full_path, "%s/%s", ref_store->gitdir, refname);
> >
> > - if (strbuf_read_file(&content, full_path.buf, 0) < 0)
> > + errno = 0;
>
> Do we need to set errno to 0 here? Looking at the implementation of
> strbuf_read_file(), it looks like we return early in two cases. Either
> open() fails, in which errno is set for us, or strbuf_read() fails, in
> which case we set errno to whatever it was right after the failed read
> (preventing the subsequent close() call from tainting the value of errno).
>
> So I think in either case, we have the right value in errno, and don't
> need to worry about setting it to "0" ahead of time.
True. I'll drop this when rerolling.
> > +test_expect_success '--exists with existing special ref' '
> > + git rev-parse HEAD >.git/FETCH_HEAD &&
> > + git show-ref --exists FETCH_HEAD
> > +'
>
> I don't think that it matters here, but do we need to worry about
> cleaning up .git/FETCH_HEAD for future tests?
There's so many tests where I wish that we did a better job of cleanup,
so I agree that it is sensible to clean up after ourselves. Will drop
when rerolling.
Patrick
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
next prev parent reply other threads:[~2023-11-30 7:43 UTC|newest]
Thread overview: 41+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-11-29 8:14 [PATCH 0/4] refs: improve handling of special refs Patrick Steinhardt
2023-11-29 8:14 ` [PATCH 1/4] wt-status: read HEAD and ORIG_HEAD via the refdb Patrick Steinhardt
2023-11-29 21:45 ` Taylor Blau
2023-11-30 7:42 ` Patrick Steinhardt
2023-11-30 17:36 ` Taylor Blau
2023-11-29 8:14 ` [PATCH 2/4] refs: propagate errno when reading special refs fails Patrick Steinhardt
2023-11-29 21:51 ` Taylor Blau
2023-11-30 7:43 ` Patrick Steinhardt [this message]
2023-11-29 8:14 ` [PATCH 3/4] refs: complete list of special refs Patrick Steinhardt
2023-11-29 21:59 ` Taylor Blau
2023-11-30 7:44 ` Patrick Steinhardt
2023-11-30 15:42 ` Phillip Wood
2023-12-01 6:43 ` Patrick Steinhardt
2023-12-04 14:18 ` Phillip Wood
2023-11-29 8:14 ` [PATCH 4/4] bisect: consistently write BISECT_EXPECTED_REV via the refdb Patrick Steinhardt
2023-11-29 22:13 ` Taylor Blau
2023-11-29 22:14 ` [PATCH 0/4] refs: improve handling of special refs Taylor Blau
2023-11-30 7:46 ` Patrick Steinhardt
2023-11-30 17:35 ` Taylor Blau
2023-12-12 7:18 ` [PATCH v2 " Patrick Steinhardt
2023-12-12 7:18 ` [PATCH v2 1/4] wt-status: read HEAD and ORIG_HEAD via the refdb Patrick Steinhardt
2023-12-12 20:24 ` Junio C Hamano
2023-12-12 23:32 ` Ramsay Jones
2023-12-13 0:36 ` Junio C Hamano
2023-12-13 7:38 ` Patrick Steinhardt
2023-12-13 15:15 ` Junio C Hamano
2023-12-14 9:04 ` Patrick Steinhardt
2023-12-14 16:41 ` Junio C Hamano
2023-12-14 13:21 ` Patrick Steinhardt
2023-12-12 7:18 ` [PATCH v2 2/4] refs: propagate errno when reading special refs fails Patrick Steinhardt
2023-12-12 20:28 ` Junio C Hamano
2023-12-13 7:28 ` Patrick Steinhardt
2023-12-12 7:18 ` [PATCH v2 3/4] refs: complete list of special refs Patrick Steinhardt
2023-12-12 7:19 ` [PATCH v2 4/4] bisect: consistently write BISECT_EXPECTED_REV via the refdb Patrick Steinhardt
2023-12-14 13:36 ` [PATCH v3 0/4] refs: improve handling of special refs Patrick Steinhardt
2023-12-14 13:36 ` [PATCH v3 1/4] wt-status: read HEAD and ORIG_HEAD via the refdb Patrick Steinhardt
2023-12-14 13:37 ` [PATCH v3 2/4] refs: propagate errno when reading special refs fails Patrick Steinhardt
2023-12-14 13:37 ` [PATCH v3 3/4] refs: complete list of special refs Patrick Steinhardt
2023-12-14 13:37 ` [PATCH v3 4/4] bisect: consistently write BISECT_EXPECTED_REV via the refdb Patrick Steinhardt
2023-12-20 19:28 ` [PATCH v3 0/4] refs: improve handling of special refs Junio C Hamano
2023-12-21 10:08 ` Patrick Steinhardt
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=ZWg9KfpeyLRdX1b8@tanuki \
--to=ps@pks.im \
--cc=git@vger.kernel.org \
--cc=hanwenn@gmail.com \
--cc=me@ttaylorr.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.
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 NNTP newsgroup(s).