Skip to content

Commit 284b444

Browse files
committed
Merge branch 'mk/merge-in-sparse-checkout'
"git reset --merge" (hence "git merge ---abort") and "git reset --hard" had trouble working correctly in a sparsely checked out working tree after a conflict, which has been corrected. * mk/merge-in-sparse-checkout: unpack-trees: do not fail reset because of unmerged skipped entry
2 parents 6fc7de1 + b33fdfc commit 284b444

File tree

2 files changed

+60
-1
lines changed

2 files changed

+60
-1
lines changed

t/t3035-merge-sparse.sh

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
#!/bin/sh
2+
3+
test_description='merge with sparse files'
4+
5+
. ./test-lib.sh
6+
7+
# test_file $filename $content
8+
test_file () {
9+
echo "$2" > "$1" &&
10+
git add "$1"
11+
}
12+
13+
# test_commit_this $message_and_tag
14+
test_commit_this () {
15+
git commit -m "$1" &&
16+
git tag "$1"
17+
}
18+
19+
test_expect_success 'setup' '
20+
: >empty &&
21+
test_file checked-out init &&
22+
test_file modify_delete modify_delete_init &&
23+
test_commit_this init &&
24+
test_file modify_delete modify_delete_theirs &&
25+
test_commit_this theirs &&
26+
git reset --hard init &&
27+
git rm modify_delete &&
28+
test_commit_this ours &&
29+
git config core.sparseCheckout true &&
30+
echo "/checked-out" >.git/info/sparse-checkout &&
31+
git reset --hard &&
32+
! git merge theirs
33+
'
34+
35+
test_expect_success 'reset --hard works after the conflict' '
36+
git reset --hard
37+
'
38+
39+
test_expect_success 'is reset properly' '
40+
git status --porcelain -- modify_delete >out &&
41+
test_cmp empty out &&
42+
test_path_is_missing modify_delete
43+
'
44+
45+
test_expect_success 'setup: conflict back' '
46+
! git merge theirs
47+
'
48+
49+
test_expect_success 'Merge abort works after the conflict' '
50+
git merge --abort
51+
'
52+
53+
test_expect_success 'is aborted properly' '
54+
git status --porcelain -- modify_delete >out &&
55+
test_cmp empty out &&
56+
test_path_is_missing modify_delete
57+
'
58+
59+
test_done

unpack-trees.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1247,7 +1247,7 @@ static void mark_new_skip_worktree(struct exclude_list *el,
12471247
if (select_flag && !(ce->ce_flags & select_flag))
12481248
continue;
12491249

1250-
if (!ce_stage(ce))
1250+
if (!ce_stage(ce) && !(ce->ce_flags & CE_CONFLICTED))
12511251
ce->ce_flags |= skip_wt_flag;
12521252
else
12531253
ce->ce_flags &= ~skip_wt_flag;

0 commit comments

Comments
 (0)