File tree Expand file tree Collapse file tree 2 files changed +67
-2
lines changed Expand file tree Collapse file tree 2 files changed +67
-2
lines changed Original file line number Diff line number Diff line change @@ -466,7 +466,7 @@ void diffcore_rename(struct diff_options *options)
466
466
else
467
467
locate_rename_dst (p -> two , 1 );
468
468
}
469
- else if (!DIFF_FILE_VALID (p -> two )) {
469
+ else if (!DIFF_PAIR_UNMERGED ( p ) && ! DIFF_FILE_VALID (p -> two )) {
470
470
/*
471
471
* If the source is a broken "delete", and
472
472
* they did not really want to get broken,
@@ -586,7 +586,10 @@ void diffcore_rename(struct diff_options *options)
586
586
struct diff_filepair * p = q -> queue [i ];
587
587
struct diff_filepair * pair_to_free = NULL ;
588
588
589
- if (!DIFF_FILE_VALID (p -> one ) && DIFF_FILE_VALID (p -> two )) {
589
+ if (DIFF_PAIR_UNMERGED (p )) {
590
+ diff_q (& outq , p );
591
+ }
592
+ else if (!DIFF_FILE_VALID (p -> one ) && DIFF_FILE_VALID (p -> two )) {
590
593
/*
591
594
* Creation
592
595
*
Original file line number Diff line number Diff line change @@ -56,4 +56,66 @@ test_expect_success C_LOCALE_OUTPUT 'M/D conflict does not segfault' '
56
56
)
57
57
'
58
58
59
+ test_expect_success ' rename & unmerged setup' '
60
+ git rm -f -r . &&
61
+ cat "$TEST_DIRECTORY/README" >ONE &&
62
+ git add ONE &&
63
+ test_tick &&
64
+ git commit -m "One commit with ONE" &&
65
+
66
+ echo Modified >TWO &&
67
+ cat ONE >>TWO &&
68
+ cat ONE >>THREE &&
69
+ git add TWO THREE &&
70
+ sha1=$(git rev-parse :ONE) &&
71
+ git rm --cached ONE &&
72
+ (
73
+ echo "100644 $sha1 1 ONE" &&
74
+ echo "100644 $sha1 2 ONE" &&
75
+ echo "100644 $sha1 3 ONE"
76
+ ) | git update-index --index-info &&
77
+ echo Further >>THREE
78
+ '
79
+
80
+ test_expect_success ' rename & unmerged status' '
81
+ git status -suno >actual &&
82
+ cat >expect <<-EOF &&
83
+ UU ONE
84
+ AM THREE
85
+ A TWO
86
+ EOF
87
+ test_cmp expect actual
88
+ '
89
+
90
+ test_expect_success ' git diff-index --cached shows 2 added + 1 unmerged' '
91
+ cat >expected <<-EOF &&
92
+ U ONE
93
+ A THREE
94
+ A TWO
95
+ EOF
96
+ git diff-index --cached --name-status HEAD >actual &&
97
+ test_cmp expected actual
98
+ '
99
+
100
+ test_expect_success ' git diff-index --cached -M shows 2 added + 1 unmerged' '
101
+ cat >expected <<-EOF &&
102
+ U ONE
103
+ A THREE
104
+ A TWO
105
+ EOF
106
+ git diff-index --cached --name-status HEAD >actual &&
107
+ test_cmp expected actual
108
+ '
109
+
110
+ test_expect_success ' git diff-index --cached -C shows 2 copies + 1 unmerged' '
111
+ cat >expected <<-EOF &&
112
+ U ONE
113
+ C ONE THREE
114
+ C ONE TWO
115
+ EOF
116
+ git diff-index --cached -C --name-status HEAD |
117
+ sed "s/^C[0-9]*/C/g" >actual &&
118
+ test_cmp expected actual
119
+ '
120
+
59
121
test_done
You can’t perform that action at this time.
0 commit comments