git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Karthik Nayak <karthik.188@gmail.com>
Cc: Johannes Schindelin via GitGitGadget <gitgitgadget@gmail.com>,
	git@vger.kernel.org,
	 Johannes Schindelin <johannes.schindelin@gmx.de>
Subject: Re: [PATCH] Always check the return value of `repo_read_object_file()`
Date: Tue, 06 Feb 2024 10:36:44 -0800	[thread overview]
Message-ID: <xmqq8r3xign7.fsf@gitster.g> (raw)
In-Reply-To: <CAOLa=ZQOALZRNqp7dDH0qDWoHwo6_3G8VgVuMbb3C20UdJ4C5A@mail.gmail.com> (Karthik Nayak's message of "Mon, 5 Feb 2024 08:10:06 -0800")

Karthik Nayak <karthik.188@gmail.com> writes:

> Hello,
>
> "Johannes Schindelin via GitGitGadget" <gitgitgadget@gmail.com> writes:
>> diff --git a/bisect.c b/bisect.c
>> index f1273c787d9..f75e50c3397 100644
>> --- a/bisect.c
>> +++ b/bisect.c
>> @@ -158,6 +158,9 @@ static void show_list(const char *debug, int counted, int nr,
>>  		const char *subject_start;
>>  		int subject_len;
>>
>> +		if (!buf)
>> +			die(_("unable to read %s"), oid_to_hex(&commit->object.oid));
>> +
>
> Nit: We know that `repo_read_object_file()` fails on corrupt objects, so
> this means that this is only happening when the object doesn't exist. I
> wonder if it makes more sense to replace "unable to read %s" which is a
> little ambiguous with something like "object %q doesn't exist".

I am not sure if that is a good move in the longer run.  We may
"fix" the called function to return NULL to allow callers to deal
with errors from object corruption better, at which time between
"doesn't exist" and "unable to read", the latter becomes far closer
to what actually happened (it is debatable if a corrupt thing really
exists in the first place, too).

> Otherwise, the patch looks good, thanks!

I haven't read the remainder of the patch, but to me this hunk looks
OK.

Thanks.

  reply	other threads:[~2024-02-06 18:36 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 [this message]
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
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=xmqq8r3xign7.fsf@gitster.g \
    --to=gitster@pobox.com \
    --cc=git@vger.kernel.org \
    --cc=gitgitgadget@gmail.com \
    --cc=johannes.schindelin@gmx.de \
    --cc=karthik.188@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).