Skip to content

Commit c4758d3

Browse files
committed
Fix read-tree not to discard errors
This fixes the issue identified with recently added tests to t1004 Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent 8a785dc commit c4758d3

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

t/t1004-read-tree-m-u-wf.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ test_expect_success 'funny symlink in work tree' '
177177
178178
'
179179

180-
test_expect_failure 'funny symlink in work tree, un-unlink-able' '
180+
test_expect_success 'funny symlink in work tree, un-unlink-able' '
181181
182182
rm -fr a b &&
183183
git reset --hard &&

unpack-trees.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,13 +54,14 @@ static void unlink_entry(char *name, char *last_symlink)
5454
}
5555

5656
static struct checkout state;
57-
static void check_updates(struct unpack_trees_options *o)
57+
static int check_updates(struct unpack_trees_options *o)
5858
{
5959
unsigned cnt = 0, total = 0;
6060
struct progress *progress = NULL;
6161
char last_symlink[PATH_MAX];
6262
struct index_state *index = &o->result;
6363
int i;
64+
int errs = 0;
6465

6566
if (o->update && o->verbose_update) {
6667
for (total = cnt = 0; cnt < index->cache_nr; cnt++) {
@@ -90,12 +91,13 @@ static void check_updates(struct unpack_trees_options *o)
9091
if (ce->ce_flags & CE_UPDATE) {
9192
ce->ce_flags &= ~CE_UPDATE;
9293
if (o->update) {
93-
checkout_entry(ce, &state, NULL);
94+
errs |= checkout_entry(ce, &state, NULL);
9495
*last_symlink = '\0';
9596
}
9697
}
9798
}
9899
stop_progress(&progress);
100+
return errs != 0;
99101
}
100102

101103
static inline int call_unpack_fn(struct cache_entry **src, struct unpack_trees_options *o)
@@ -369,7 +371,8 @@ int unpack_trees(unsigned len, struct tree_desc *t, struct unpack_trees_options
369371
return unpack_failed(o, "Merge requires file-level merging");
370372

371373
o->src_index = NULL;
372-
check_updates(o);
374+
if (check_updates(o))
375+
return -1;
373376
if (o->dst_index)
374377
*o->dst_index = o->result;
375378
return 0;

0 commit comments

Comments
 (0)