unpack_trees(): allow callers to differentiate worktree errors from merge errors
Instead of uniformly returning -1 on any error, this teaches unpack_trees() to return -2 when the merge itself is Ok but worktree refuses to get updated. Signed-off-by: Junio C Hamano <gitster@pobox.com>
Junio C Hamano committed
May 28, 2008 at 15:12 UTC
2e2b887d1c2c2385825160e587d711ecb5935ef5
1 file changed
+7
-3
unpack-trees.c
+7
-3
@@ -358,8 +358,13 @@ static int unpack_failed(struct unpack_trees_options *o, const char *message)
358
return -1;
359
}
360
361
+/*
362
+ * N-way merge "len" trees. Returns 0 on success, -1 on failure to manipulate the
363
+ * resulting index, -2 on failure to reflect the changes to the work tree.
364
+ */
365
int unpack_trees(unsigned len, struct tree_desc *t, struct unpack_trees_options *o)
366
{
367
+ int ret;
368
static struct cache_entry *dfc;
369
370
if (len > MAX_UNPACK_TREES)
@@ -404,11 +409,10 @@ int unpack_trees(unsigned len, struct tree_desc *t, struct unpack_trees_options
409
return unpack_failed(o, "Merge requires file-level merging");
410
411
o->src_index = NULL;
407
- if (check_updates(o))
408
- return -1;
412
+ ret = check_updates(o) ? (-2) : 0;
413
if (o->dst_index)
414
*o->dst_index = o->result;
411
- return 0;
415
+ return ret;
416
}
417
418
/* Here come the merge functions */