Skip to content

Commit

Permalink
Merge branch 'jc/maint-1.6.0-read-tree-overlay'
Browse files Browse the repository at this point in the history
* jc/maint-1.6.0-read-tree-overlay:
  read-tree A B C: do not create a bogus index and do not segfault
  • Loading branch information
Junio C Hamano committed Mar 18, 2009
2 parents 9d5b05c + aab3b9a commit 7d4e3a7
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 3 deletions.
31 changes: 31 additions & 0 deletions t/t1008-read-tree-overlay.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#!/bin/sh

test_description='test multi-tree read-tree without merging'

. ./test-lib.sh

test_expect_success setup '
echo one >a &&
git add a &&
git commit -m initial &&
git tag initial &&
echo two >b &&
git add b &&
git commit -m second &&
git checkout -b side initial &&
echo three >a &&
mkdir b &&
echo four >b/c &&
git add b/c &&
git commit -m third
'

test_expect_success 'multi-read' '
git read-tree initial master side &&
(echo a; echo b/c) >expect &&
git ls-files >actual &&
test_cmp expect actual
'

test_done

6 changes: 3 additions & 3 deletions unpack-trees.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ static void add_entry(struct unpack_trees_options *o, struct cache_entry *ce,
memcpy(new, ce, size);
new->next = NULL;
new->ce_flags = (new->ce_flags & ~clear) | set;
add_index_entry(&o->result, new, ADD_CACHE_OK_TO_ADD|ADD_CACHE_OK_TO_REPLACE|ADD_CACHE_SKIP_DFCHECK);
add_index_entry(&o->result, new, ADD_CACHE_OK_TO_ADD|ADD_CACHE_OK_TO_REPLACE);
}

/*
Expand Down Expand Up @@ -266,9 +266,9 @@ static int unpack_nondirectories(int n, unsigned long mask,
if (o->merge)
return call_unpack_fn(src, o);

n += o->merge;
for (i = 0; i < n; i++)
add_entry(o, src[i], 0, 0);
if (src[i] && src[i] != o->df_conflict_entry)
add_entry(o, src[i], 0, 0);
return 0;
}

Expand Down

0 comments on commit 7d4e3a7

Please sign in to comment.