unpack-trees: do not fail reset because of unmerged skipped entry
After modify/delete merge conflict happens in a file skipped by sparse checkout, "git reset --merge", which implements the "--abort" actions, and "git reset --hard" fail with message "Entry * not uptodate. Cannot update sparse checkout." As explained in [1], the up-to-date checker mistakenly treats conflicted entry which does not exist in HEAD as still skipped by sparse checkout. Use the fix suggested in [1]. Also, add test case which verifies the issue is fixed. [1] https://public-inbox.org/git/20180616051444.GA29754@duynguyen.home/ Signed-off-by: Duy Nguyen <pclouds@gmail.com> Signed-off-by: Max Kirillov <max@max630.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Max Kirillov committed
Jul 10, 2018 at 22:17 UTC
b33fdfc34cda95f92cc7a50e5c81b87f8ee65eef
2 files changed
+60
-1
t/t3035-merge-sparse.sh
new
+59
@@ -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
+1
-1
@@ -1246,7 +1246,7 @@ static void mark_new_skip_worktree(struct exclude_list *el,
1246
if (select_flag && !(ce->ce_flags & select_flag))
1247
continue;
1248
1249
- if (!ce_stage(ce))
1249
+ if (!ce_stage(ce) && !(ce->ce_flags & CE_CONFLICTED))
1250
ce->ce_flags |= skip_wt_flag;
1251
else
1252
ce->ce_flags &= ~skip_wt_flag;