Skip to content

Commit 542c264

Browse files
committed
traverse_trees_recursive(): propagate merge errors up
There were few places where merge errors detected deeper in the call chain were ignored and not propagated up the callchain to the caller. Most notably, this caused switching branches with "git checkout" to ignore a path modified in a work tree are different between the HEAD version and the commit being switched to, which it internally notices but ignores it, resulting in an incorrect two-way merge and loss of the change in the work tree. Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent 1caeacc commit 542c264

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

unpack-trees.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -144,8 +144,7 @@ int traverse_trees_recursive(int n, unsigned long dirmask, unsigned long df_conf
144144
sha1 = names[i].sha1;
145145
fill_tree_descriptor(t+i, sha1);
146146
}
147-
traverse_trees(n, t, &newinfo);
148-
return 0;
147+
return traverse_trees(n, t, &newinfo);
149148
}
150149

151150
/*
@@ -306,7 +305,9 @@ static int unpack_callback(int n, unsigned long mask, unsigned long dirmask, str
306305
if (src[0])
307306
conflicts |= 1;
308307
}
309-
traverse_trees_recursive(n, dirmask, conflicts, names, info);
308+
if (traverse_trees_recursive(n, dirmask, conflicts,
309+
names, info) < 0)
310+
return -1;
310311
return mask;
311312
}
312313

0 commit comments

Comments
 (0)