Skip to content

Commit 353c5ee

Browse files
committed
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 <[email protected]>
1 parent 6caa7b5 commit 353c5ee

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

unpack-trees.c

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -277,6 +277,17 @@ static int unpack_nondirectories(int n, unsigned long mask,
277277
return 0;
278278
}
279279

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+
280291
static int unpack_callback(int n, unsigned long mask, unsigned long dirmask, struct name_entry *names, struct traverse_info *info)
281292
{
282293
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
294305
int cmp = compare_entry(ce, info, p);
295306
if (cmp < 0) {
296307
if (unpack_index_entry(ce, o) < 0)
297-
return -1;
308+
return unpack_failed(o, NULL);
298309
continue;
299310
}
300311
if (!cmp) {
@@ -352,17 +363,6 @@ static int unpack_callback(int n, unsigned long mask, unsigned long dirmask, str
352363
return mask;
353364
}
354365

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-
366366
/*
367367
* N-way merge "len" trees. Returns 0 on success, -1 on failure to manipulate the
368368
* resulting index, -2 on failure to reflect the changes to the work tree.

0 commit comments

Comments
 (0)