Skip to content

Commit 19c6a4f

Browse files
committed
merge-recursive: do not return NULL only to cause segfault
merge-recursive calls write_tree_from_memory() to come up with a virtual tree, with possible conflict markers inside the blob contents, while merging multiple common ancestors down. It is a bug to call the function with unmerged entries in the index, even if the merge to come up with the common ancestor resulted in conflicts. Otherwise the result won't be expressible as a tree object. We _might_ want to suggest the user to set GIT_MERGE_VERBOSITY to 5 and re-run the merge in the message. At least we will know which part of process_renames() or process_entry() functions is not correctly handling the unmerged paths, and it might help us diagnosing the issue. Signed-off-by: Junio C Hamano <[email protected]>
1 parent 703e6e7 commit 19c6a4f

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

merge-recursive.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -200,14 +200,14 @@ struct tree *write_tree_from_memory(struct merge_options *o)
200200

201201
if (unmerged_cache()) {
202202
int i;
203-
output(o, 0, "There are unmerged index entries:");
203+
fprintf(stderr, "BUG: There are unmerged index entries:\n");
204204
for (i = 0; i < active_nr; i++) {
205205
struct cache_entry *ce = active_cache[i];
206206
if (ce_stage(ce))
207-
output(o, 0, "%d %.*s", ce_stage(ce),
208-
(int)ce_namelen(ce), ce->name);
207+
fprintf(stderr, "BUG: %d %.*s", ce_stage(ce),
208+
(int)ce_namelen(ce), ce->name);
209209
}
210-
return NULL;
210+
die("Bug in merge-recursive.c");
211211
}
212212

213213
if (!active_cache_tree)

0 commit comments

Comments
 (0)