Skip to content

Commit 0e1aa2f

Browse files
committed
Merge branch 'jc/maint-1.6.0-read-tree-overlay' into maint
* jc/maint-1.6.0-read-tree-overlay: read-tree A B C: do not create a bogus index and do not segfault
2 parents b60df87 + aab3b9a commit 0e1aa2f

File tree

2 files changed

+34
-3
lines changed

2 files changed

+34
-3
lines changed

t/t1008-read-tree-overlay.sh

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#!/bin/sh
2+
3+
test_description='test multi-tree read-tree without merging'
4+
5+
. ./test-lib.sh
6+
7+
test_expect_success setup '
8+
echo one >a &&
9+
git add a &&
10+
git commit -m initial &&
11+
git tag initial &&
12+
echo two >b &&
13+
git add b &&
14+
git commit -m second &&
15+
git checkout -b side initial &&
16+
echo three >a &&
17+
mkdir b &&
18+
echo four >b/c &&
19+
git add b/c &&
20+
git commit -m third
21+
'
22+
23+
test_expect_success 'multi-read' '
24+
git read-tree initial master side &&
25+
(echo a; echo b/c) >expect &&
26+
git ls-files >actual &&
27+
test_cmp expect actual
28+
'
29+
30+
test_done
31+

unpack-trees.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ static void add_entry(struct unpack_trees_options *o, struct cache_entry *ce,
4949
memcpy(new, ce, size);
5050
new->next = NULL;
5151
new->ce_flags = (new->ce_flags & ~clear) | set;
52-
add_index_entry(&o->result, new, ADD_CACHE_OK_TO_ADD|ADD_CACHE_OK_TO_REPLACE|ADD_CACHE_SKIP_DFCHECK);
52+
add_index_entry(&o->result, new, ADD_CACHE_OK_TO_ADD|ADD_CACHE_OK_TO_REPLACE);
5353
}
5454

5555
/* Unlink the last component and attempt to remove leading
@@ -286,9 +286,9 @@ static int unpack_nondirectories(int n, unsigned long mask,
286286
if (o->merge)
287287
return call_unpack_fn(src, o);
288288

289-
n += o->merge;
290289
for (i = 0; i < n; i++)
291-
add_entry(o, src[i], 0, 0);
290+
if (src[i] && src[i] != o->df_conflict_entry)
291+
add_entry(o, src[i], 0, 0);
292292
return 0;
293293
}
294294

0 commit comments

Comments
 (0)