Re: [PATCH v3 5/5] builtin/stash: merge index in-core

From
Junio C Hamano <hidden>
Date
2026-09-28 15:32:18
Reply to
D. Ben Knoble, 2026-09-28
"D. Ben Knoble" [off-list ref] writes:
On Mon, Sep 28, 2026 at 5:40 AM Junio C Hamano [off-list ref] wrote:
quoted
"D. Ben Knoble" [off-list ref] writes:
quoted
+                     merge_incore_nonrecursive(&o, merge_base, head, merge,
+                                               &result);
+
+                     oidcpy(&index_tree, &result.tree->object.oid);
This is risky, isn't it?

If there were catastrophic failure (e.g., missing object that were
involved in the merge), merge_incore_nonrecursive() may stuff -1 to
result.clean and return without populating result.tree, and when
that happens, result.tree->object.oid would be dereferencing NULL.
Indeed… unfortunate. Thanks for spotting.
I did

	$ git grep merge_incore_nonrecursive \*.c

and read all the current callers.

They all have code to specifically check for the (result.clean < 0)
condition and error out before touching any of the other members of
the result structure, so they seem to be safe.
Thread (78 messages) 78 messages, 4 authors, last reply 2026-10-01
Keyboard shortcuts
hback out one level
jnext message in thread / next series-diff position
kprevious message in thread / previous series-diff position
ldrill in
Escclose help / fold thread tree
?toggle this help