Git development
 help / color / mirror / Atom feed
From: Kaartic Sivaraam <kaartic.sivaraam@gmail.com>
To: Junio C Hamano <gitster@pobox.com>
Cc: Justin Tobler <jltobler@gmail.com>, git@vger.kernel.org
Subject: Re: [PATCH 2/2] object-file: return error on index-pack abnormal exit
Date: Tue, 10 Nov 2026 23:27:43 +0530	[thread overview]
Message-ID: <590c5765-fc4e-44da-9326-b8242caa80ae@gmail.com> (raw)
In-Reply-To: <xmqqmrrgtz6i.fsf@gitster.g>

On 11/10/26 22:13, Junio C Hamano wrote:
> Kaartic Sivaraam <kaartic.sivaraam@gmail.com> writes:
> 
>>> Personally, I somehow find that the original "unless we positively
>>> declare success, default to 'ret = -1', and if we may have detected
>>> more specific error, return it back, and reset ret to 0 when we see
>>> a success" easier to follow, but that may be subjective preference.
>>
>> +1. I too have a slight preference for the old flow of having ret = -1
>> and resetting it when there's no error. It may not be worth a re-roll,
>> though.
> 
> Note that my comment you quoted was made with a misunderstanding
> of the patch and misses one important point, which is that
> read_index_pack_report() used to overwrite "ret" even when it
> succeeded, but the new code uses a separate variable to avoid
> clobbering "ret" when the call succeeds.
> 
> In other words, the original failed to honor the "have ret = -1
> and reset to 0 only after seeing everything go well" pattern,
> either, and Justin's patch is a definite improvement.

It is an improvement indeed. No arguments about it. I was just wondering 
if his change could also include a change like this on top:

diff --git a/object-file.c b/object-file.c
index e04ce0bc11..c52004014f 100644
--- a/object-file.c
+++ b/object-file.c
@@ -1429,7 +1429,7 @@ static int odb_transaction_files_write_pack(struct 
odb_transaction *base,
  	struct pack_header hdr;
  	const char *hdr_err;
  	int err_fd = opts->err_fd;
-	int ret;
+	int ret = -1;

  	hdr_err = parse_pack_header(&hdr, pack_fd);
  	if (hdr_err) {
@@ -1498,13 +1498,11 @@ static int 
odb_transaction_files_write_pack(struct odb_transaction *base,

  		if (finish_command(&child)) {
  			strbuf_addstr(err_msg, "index-pack abnormal exit");
-			ret = -1;
  			goto out;
  		}

  		if (report_err) {
  			strbuf_addstr(err_msg, "index-pack failed to report pack name");
-			ret = -1;
  			goto out;
  		}


But, I would agree that this is a digression.

-- 
Sivaraam


  reply	other threads:[~2026-11-10 17:57 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-03 21:24 [PATCH 0/2] object-file: small error handling follow-ups Justin Tobler
2026-11-03 21:24 ` [PATCH 1/2] object-file: warn on failed unlink Justin Tobler
2026-11-04 23:00   ` Junio C Hamano
2026-11-03 21:24 ` [PATCH 2/2] object-file: return error on index-pack abnormal exit Justin Tobler
2026-11-04 23:06   ` Junio C Hamano
2026-11-05 18:09     ` Justin Tobler
2026-11-10  9:04     ` Kaartic Sivaraam
2026-11-10 16:43       ` Junio C Hamano
2026-11-10 17:57         ` Kaartic Sivaraam [this message]
2026-11-10 19:25           ` Justin Tobler
2026-11-05 15:30   ` Patrick Steinhardt
2026-11-05 18:06     ` Justin Tobler
2026-11-04 13:37 ` [PATCH 0/2] object-file: small error handling follow-ups Karthik Nayak

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=590c5765-fc4e-44da-9326-b8242caa80ae@gmail.com \
    --to=kaartic.sivaraam@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=jltobler@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