[PATCH 6/5] merge-ll: handle external driver status before reading result
- From
Jeff King <peff@peff.net>
- Date
- Sep 29, 2026, 20:43 UTC
- Message-ID
- <20260929204320.GA1734030@coredump.intra.peff.net>
- In-Reply-To
- <20260929204157.GA1733321@coredump.intra.peff.net>
After running an external merge driver, ll_ext_merge() reads its output and cleans up the temporary files before converting the exit status to an ll_merge_result.
Move that conversion immediately after run_command(). This will let us override the result if reading the output fails, without having to fake an exit status. No behavior change yet.
It is tempting to only call read_mmfile() when we have LL_MERGE_OK, but callers do care about the result even with LL_MERGE_CONFLICT (e.g., the output may contain a partial). I think we could safely skip it for LL_MERGE_ERROR, but that's a rare case and not worth complicating the code for.
Signed-off-by: Jeff King <peff@peff.net> --- merge-ll.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/merge-ll.c b/merge-ll.c index 7fab7c5438..4d82836bc5 100644 --- a/merge-ll.c +++ b/merge-ll.c @@ -240,20 +240,20 @@ static enum ll_merge_result ll_ext_merge(const struct ll_merge_driver *fn, child.use_shell = 1; strvec_push(&child.args, cmd.buf); status = run_command(&child); - - /* We can ignore errors; result is left NULL/0 in that case. */ - read_mmfile(result, temp[1]); - - for (i = 0; i < 3; i++) - unlink_or_warn(temp[i]); - strbuf_release(&cmd); if (!status) ret = LL_MERGE_OK; else if (status <= 128) ret = LL_MERGE_CONFLICT; else /* died due to a signal: WTERMSIG(status) + 128 */ ret = LL_MERGE_ERROR; + + /* We can ignore errors; result is left NULL/0 in that case. */ + read_mmfile(result, temp[1]); + + for (i = 0; i < 3; i++) + unlink_or_warn(temp[i]); + strbuf_release(&cmd); return ret; }
-- 2.56.0.325.g545d7e68bc