Skip to content

Commit 2f682e2

Browse files
newrengitster
authored andcommitted
merge-recursive: avoid triggering add_cacheinfo error with dirty mod
If a cherry-pick or merge with a rename results in a skippable update (due to the merged content matching what HEAD already had), but the working directory is dirty, avoid trying to refresh the index as that will fail. Signed-off-by: Elijah Newren <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent bd42380 commit 2f682e2

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

merge-recursive.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2786,7 +2786,7 @@ static int merge_content(struct merge_options *o,
27862786
path_renamed_outside_HEAD = !path2 || !strcmp(path, path2);
27872787
if (!path_renamed_outside_HEAD) {
27882788
if (add_cacheinfo(o, mfi.mode, &mfi.oid, path,
2789-
0, (!o->call_depth), 0))
2789+
0, (!o->call_depth && !is_dirty), 0))
27902790
return -1;
27912791
return mfi.clean;
27922792
}

t/t3501-revert-cherry-pick.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ test_expect_success 'cherry-pick "-" works with arguments' '
141141
test_cmp expect actual
142142
'
143143

144-
test_expect_failure 'cherry-pick works with dirty renamed file' '
144+
test_expect_success 'cherry-pick works with dirty renamed file' '
145145
test_commit to-rename &&
146146
git checkout -b unrelated &&
147147
test_commit unrelated &&

0 commit comments

Comments
 (0)