@matheusbsbs / matheus-bagliano / commits / c4758d3c93
Fork 0

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>

Junio C Hamano committed Mar 18, 2008 at 22:01 UTC c4758d3c9342ea2245ca51f30f1cbf27ecc16ced
2 files changed +7 -4
t/t1004-read-tree-m-u-wf.sh
+1 -1
@@ -177,7 +177,7 @@ test_expect_success 'funny symlink in work tree' '
177
178 '
179
180 -test_expect_failure 'funny symlink in work tree, un-unlink-able' '
180 +test_expect_success 'funny symlink in work tree, un-unlink-able' '
181
182 rm -fr a b &&
183 git reset --hard &&
unpack-trees.c
+6 -3
@@ -54,13 +54,14 @@ static void unlink_entry(char *name, char *last_symlink)
54 }
55
56 static struct checkout state;
57 -static void check_updates(struct unpack_trees_options *o)
57 +static int check_updates(struct unpack_trees_options *o)
58 {
59 unsigned cnt = 0, total = 0;
60 struct progress *progress = NULL;
61 char last_symlink[PATH_MAX];
62 struct index_state *index = &o->result;
63 int i;
64 + int errs = 0;
65
66 if (o->update && o->verbose_update) {
67 for (total = cnt = 0; cnt < index->cache_nr; cnt++) {
@@ -90,12 +91,13 @@ static void check_updates(struct unpack_trees_options *o)
91 if (ce->ce_flags & CE_UPDATE) {
92 ce->ce_flags &= ~CE_UPDATE;
93 if (o->update) {
93 - checkout_entry(ce, &state, NULL);
94 + errs |= checkout_entry(ce, &state, NULL);
95 *last_symlink = '\0';
96 }
97 }
98 }
99 stop_progress(&progress);
100 + return errs != 0;
101 }
102
103 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
371 return unpack_failed(o, "Merge requires file-level merging");
372
373 o->src_index = NULL;
372 - check_updates(o);
374 + if (check_updates(o))
375 + return -1;
376 if (o->dst_index)
377 *o->dst_index = o->result;
378 return 0;