Skip to content

Commit

Permalink
Fix read-tree not to discard errors
Browse files Browse the repository at this point in the history
This fixes the issue identified with recently added tests to t1004

Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
Junio C Hamano committed Mar 19, 2008
1 parent 8a785dc commit c4758d3
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
2 changes: 1 addition & 1 deletion t/t1004-read-tree-m-u-wf.sh
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ test_expect_success 'funny symlink in work tree' '
'

test_expect_failure 'funny symlink in work tree, un-unlink-able' '
test_expect_success 'funny symlink in work tree, un-unlink-able' '
rm -fr a b &&
git reset --hard &&
Expand Down
9 changes: 6 additions & 3 deletions unpack-trees.c
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,14 @@ static void unlink_entry(char *name, char *last_symlink)
}

static struct checkout state;
static void check_updates(struct unpack_trees_options *o)
static int check_updates(struct unpack_trees_options *o)
{
unsigned cnt = 0, total = 0;
struct progress *progress = NULL;
char last_symlink[PATH_MAX];
struct index_state *index = &o->result;
int i;
int errs = 0;

if (o->update && o->verbose_update) {
for (total = cnt = 0; cnt < index->cache_nr; cnt++) {
Expand Down Expand Up @@ -90,12 +91,13 @@ static void check_updates(struct unpack_trees_options *o)
if (ce->ce_flags & CE_UPDATE) {
ce->ce_flags &= ~CE_UPDATE;
if (o->update) {
checkout_entry(ce, &state, NULL);
errs |= checkout_entry(ce, &state, NULL);
*last_symlink = '\0';
}
}
}
stop_progress(&progress);
return errs != 0;
}

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

o->src_index = NULL;
check_updates(o);
if (check_updates(o))
return -1;
if (o->dst_index)
*o->dst_index = o->result;
return 0;
Expand Down

0 comments on commit c4758d3

Please sign in to comment.