[PATCH 2/2] object-file: return error on index-pack abnormal exit
- From
Justin Tobler <jltobler@gmail.com>
- Date
- Nov 3, 2026, 21:24 UTC
- Message-ID
- <20261103212410.1389988-3-jltobler@gmail.com>
- In-Reply-To
- <20261103212410.1389988-1-jltobler@gmail.com>
When git-index-pack(1) exits abnormally after reporting the packfile name, `odb_transaction_files_write_pack()` records an error message in `err_msg` but still returns success. Current callers ultimately discard the return value, so this does not cause any issues at present, but the return value should still reflect the failure.
Update `odb_transaction_files_write_pack()` to return an error value in this case accordingly. While at it, simplify how the child process exit statuses are checked.
Signed-off-by: Justin Tobler <jltobler@gmail.com> --- object-file.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-)
diff --git a/object-file.c b/object-file.c index a9800143bd..e04ce0bc11 100644 --- a/object-file.c +++ b/object-file.c @@ -1429,8 +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 = -1; - int status; + int ret; hdr_err = parse_pack_header(&hdr, pack_fd); if (hdr_err) { @@ -1462,12 +1461,13 @@ static int odb_transaction_files_write_pack(struct odb_transaction *base, child.in = pack_fd; child.err = err_fd; child.git_cmd = 1; - status = run_command(&child); - if (status) { + if (run_command(&child)) { strbuf_addstr(err_msg, "unpack-objects abnormal exit"); return -1; } } else { + int report_err; + strvec_pushl(&child.args, "index-pack", "--stdin", NULL); push_header_arg(&child.args, &hdr); @@ -1487,24 +1487,24 @@ static int odb_transaction_files_write_pack(struct odb_transaction *base, child.in = pack_fd; child.err = err_fd; child.git_cmd = 1; - status = start_command(&child); - if (status) { + if (start_command(&child)) { strbuf_addstr(err_msg, "index-pack fork failed"); return -1; } - ret = read_index_pack_report(repo, child.out, &pack_name, NULL); + report_err = read_index_pack_report(repo, child.out, &pack_name, NULL); close(child.out); - status = finish_command(&child); - if (status) { + if (finish_command(&child)) { strbuf_addstr(err_msg, "index-pack abnormal exit"); + ret = -1; goto out; } - if (ret) { + if (report_err) { strbuf_addstr(err_msg, "index-pack failed to report pack name"); + ret = -1; goto out; }
-- 2.56.0.173.gf57c9a7388