Skip to content

Commit 4616918

Browse files
peffgitster
authored andcommitted
unpack-trees: propagate errors adding entries to the index
When unpack_trees tries to write an entry to the index, add_index_entry may report an error to stderr, but we ignore its return value. This leads to us returning a successful exit code for an operation that partially failed. Let's make sure to propagate this code. Signed-off-by: Jeff King <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent d2446df commit 4616918

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

unpack-trees.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ void setup_unpack_trees_porcelain(struct unpack_trees_options *opts,
102102
opts->unpack_rejects[i].strdup_strings = 1;
103103
}
104104

105-
static void do_add_entry(struct unpack_trees_options *o, struct cache_entry *ce,
105+
static int do_add_entry(struct unpack_trees_options *o, struct cache_entry *ce,
106106
unsigned int set, unsigned int clear)
107107
{
108108
clear |= CE_HASHED | CE_UNHASHED;
@@ -112,8 +112,8 @@ static void do_add_entry(struct unpack_trees_options *o, struct cache_entry *ce,
112112

113113
ce->next = NULL;
114114
ce->ce_flags = (ce->ce_flags & ~clear) | set;
115-
add_index_entry(&o->result, ce,
116-
ADD_CACHE_OK_TO_ADD | ADD_CACHE_OK_TO_REPLACE);
115+
return add_index_entry(&o->result, ce,
116+
ADD_CACHE_OK_TO_ADD | ADD_CACHE_OK_TO_REPLACE);
117117
}
118118

119119
static struct cache_entry *dup_entry(const struct cache_entry *ce)
@@ -608,7 +608,9 @@ static int unpack_nondirectories(int n, unsigned long mask,
608608

609609
for (i = 0; i < n; i++)
610610
if (src[i] && src[i] != o->df_conflict_entry)
611-
do_add_entry(o, src[i], 0, 0);
611+
if (do_add_entry(o, src[i], 0, 0))
612+
return -1;
613+
612614
return 0;
613615
}
614616

0 commit comments

Comments
 (0)