From: Patrick Steinhardt <ps@pks.im>
To: Johannes Schindelin <Johannes.Schindelin@gmx.de>
Cc: Johannes Schindelin via GitGitGadget <gitgitgadget@gmail.com>,
git@vger.kernel.org
Subject: Re: [PATCH] Always check the return value of `repo_read_object_file()`
Date: Fri, 9 Feb 2024 09:17:59 +0100 [thread overview]
Message-ID: <ZcXft0_UbsABjlVQ@tanuki> (raw)
In-Reply-To: <3f14077f-c70c-5eef-5b25-984fdf7b3b68@gmx.de>
[-- Attachment #1: Type: text/plain, Size: 2094 bytes --]
On Fri, Feb 09, 2024 at 09:15:15AM +0100, Johannes Schindelin wrote:
> Hi Patrick,
>
> On Tue, 6 Feb 2024, Patrick Steinhardt wrote:
>
> > On Mon, Feb 05, 2024 at 02:35:53PM +0000, Johannes Schindelin via GitGitGadget wrote:
> > > From: Johannes Schindelin <johannes.schindelin@gmx.de>
> > [snip]
> > > diff --git a/rerere.c b/rerere.c
> > > index ca7e77ba68c..13c94ded037 100644
> > > --- a/rerere.c
> > > +++ b/rerere.c
> > > @@ -973,6 +973,9 @@ static int handle_cache(struct index_state *istate,
> > > mmfile[i].ptr = repo_read_object_file(the_repository,
> > > &ce->oid, &type,
> > > &size);
> > > + if (!mmfile[i].ptr)
> > > + die(_("unable to read %s"),
> > > + oid_to_hex(&ce->oid));
> > > mmfile[i].size = size;
> > > }
> > > }
> >
> > A few lines below this we check whether `mmfile[i].ptr` is `NULL` and
> > replace it with the empty string if so. So this patch here is basically
> > a change in behaviour where we now die instead of falling back to the
> > empty value.
> >
> > I'm not familiar enough with the code to say whether the old behaviour
> > is intended or not -- it certainly feels somewhat weird to me. But it
> > did leave me wondering and could maybe use some explanation.
>
> Hmm. That's a good point. The `mmfile[i].ptr == NULL` situation is indeed
> handled specifically.
>
> However, after reading the code I come to the conclusion that the `i`
> refers to the stage of an index entry, i.e. that loop
> (https://github.com/git/git/blob/v2.43.0/rerere.c#L981-L983) handles the
> case where conflicts are due to deletions (where one side of the merge
> deleted the file) or double-adds (where both sides of the merge added the
> file, with different contents).
>
> Therefore I would suggest that ignoring missing blobs (as is the pre-patch
> behavior) would mishandle the available data and paper over a corruption
> of the database (the blob is reachable via the Git index, but is missing).
Yeah, that explanation sounds reasonable to me, thanks!
Patrick
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
next prev parent reply other threads:[~2024-02-09 8:18 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-02-05 14:35 [PATCH] Always check the return value of `repo_read_object_file()` Johannes Schindelin via GitGitGadget
2024-02-05 16:10 ` Karthik Nayak
2024-02-06 18:36 ` Junio C Hamano
2024-02-12 23:16 ` Johannes Schindelin
2024-02-06 1:13 ` Kyle Lippincott
2024-02-09 8:06 ` Johannes Schindelin
2024-02-09 16:37 ` Junio C Hamano
2024-02-09 19:56 ` Kyle Lippincott
2024-02-06 6:51 ` Patrick Steinhardt
2024-02-06 18:42 ` Junio C Hamano
2024-02-09 8:15 ` Johannes Schindelin
2024-02-09 8:17 ` Patrick Steinhardt [this message]
2024-02-06 22:02 ` Junio C Hamano
2024-02-12 23:19 ` Johannes Schindelin
2024-02-16 6:43 ` Teng Long
2024-02-18 22:36 ` Johannes Schindelin
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=ZcXft0_UbsABjlVQ@tanuki \
--to=ps@pks.im \
--cc=Johannes.Schindelin@gmx.de \
--cc=git@vger.kernel.org \
--cc=gitgitgadget@gmail.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).