summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeff King <peff@peff.net>2014-11-24 13:36:51 -0500
committerJunio C Hamano <gitster@pobox.com>2014-11-24 12:45:30 -0800
commitb2f75e0d1ff65bf964fe3a01da7cffdb30698156 (patch)
tree8681e93da483b4eec82d111e9f81e19c39ca9446
parent76f8611a5fb7e81c1bada0fb190d573a66fc03f6 (diff)
downloadgit-b2f75e0d1ff65bf964fe3a01da7cffdb30698156.tar.gz
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 <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
-rw-r--r--unpack-trees.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/unpack-trees.c b/unpack-trees.c
index 97fc995467..02f69aeea3 100644
--- a/unpack-trees.c
+++ b/unpack-trees.c
@@ -102,7 +102,7 @@ void setup_unpack_trees_porcelain(struct unpack_trees_options *opts,
opts->unpack_rejects[i].strdup_strings = 1;
}
-static void do_add_entry(struct unpack_trees_options *o, struct cache_entry *ce,
+static int do_add_entry(struct unpack_trees_options *o, struct cache_entry *ce,
unsigned int set, unsigned int clear)
{
clear |= CE_HASHED;
@@ -111,8 +111,8 @@ static void do_add_entry(struct unpack_trees_options *o, struct cache_entry *ce,
set |= CE_WT_REMOVE;
ce->ce_flags = (ce->ce_flags & ~clear) | set;
- add_index_entry(&o->result, ce,
- ADD_CACHE_OK_TO_ADD | ADD_CACHE_OK_TO_REPLACE);
+ return add_index_entry(&o->result, ce,
+ ADD_CACHE_OK_TO_ADD | ADD_CACHE_OK_TO_REPLACE);
}
static struct cache_entry *dup_entry(const struct cache_entry *ce)
@@ -607,7 +607,9 @@ static int unpack_nondirectories(int n, unsigned long mask,
for (i = 0; i < n; i++)
if (src[i] && src[i] != o->df_conflict_entry)
- do_add_entry(o, src[i], 0, 0);
+ if (do_add_entry(o, src[i], 0, 0))
+ return -1;
+
return 0;
}