unpack_callback(): use unpack_failed() consistently
When unpack_index_entry() failed, consistently call unpack_failed(), instead of silently returning -1. Signed-off-by: Junio C Hamano <gitster@pobox.com>
Junio C Hamano committed
Sep 19, 2009 at 16:36 UTC
353c5eeb5cad63218ca796352cce9986df7b9c62
1 file changed
+12
-12
unpack-trees.c
+12
-12
@@ -277,6 +277,17 @@ static int unpack_nondirectories(int n, unsigned long mask,
277
return 0;
278
}
279
280
+static int unpack_failed(struct unpack_trees_options *o, const char *message)
281
+{
282
+ discard_index(&o->result);
283
+ if (!o->gently) {
284
+ if (message)
285
+ return error("%s", message);
286
+ return -1;
287
+ }
288
+ return -1;
289
+}
290
+
291
static int unpack_callback(int n, unsigned long mask, unsigned long dirmask, struct name_entry *names, struct traverse_info *info)
292
{
293
struct cache_entry *src[MAX_UNPACK_TREES + 1] = { NULL, };
@@ -294,7 +305,7 @@ static int unpack_callback(int n, unsigned long mask, unsigned long dirmask, str
305
int cmp = compare_entry(ce, info, p);
306
if (cmp < 0) {
307
if (unpack_index_entry(ce, o) < 0)
297
- return -1;
308
+ return unpack_failed(o, NULL);
309
continue;
310
}
311
if (!cmp) {
@@ -352,17 +363,6 @@ static int unpack_callback(int n, unsigned long mask, unsigned long dirmask, str
363
return mask;
364
}
365
355
-static int unpack_failed(struct unpack_trees_options *o, const char *message)
356
-{
357
- discard_index(&o->result);
358
- if (!o->gently) {
359
- if (message)
360
- return error("%s", message);
361
- return -1;
362
- }
363
- return -1;
364
-}
365
-
366
/*
367
* N-way merge "len" trees. Returns 0 on success, -1 on failure to manipulate the
368
* resulting index, -2 on failure to reflect the changes to the work tree.