Skip to content

Commit 6ce069a

Browse files
committed
Merge branch 'cherry-pick-segfault'
This branch fixes the problem where merge-recursive's add_cacheinfo() expected refresh_cache_entry() always to return a valid cache entry (but it does not do that e.g. when the file in the worktree is modified). Signed-off-by: Johannes Schindelin <[email protected]>
2 parents 2ccd858 + 92fdacf commit 6ce069a

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

merge-recursive.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ static int add_cacheinfo(struct merge_options *o,
235235
struct cache_entry *nce;
236236

237237
nce = refresh_cache_entry(ce, CE_MATCH_REFRESH | CE_MATCH_IGNORE_MISSING);
238-
if (nce != ce)
238+
if (nce && nce != ce)
239239
ret = add_cache_entry(nce, options);
240240
}
241241
return ret;

t/t3501-revert-cherry-pick.sh

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,4 +141,16 @@ test_expect_success 'cherry-pick "-" works with arguments' '
141141
test_cmp expect actual
142142
'
143143

144+
test_expect_success 'cherry-pick works with dirty renamed file' '
145+
test_commit to-rename &&
146+
git checkout -b unrelated &&
147+
test_commit unrelated &&
148+
git checkout @{-1} &&
149+
git mv to-rename.t renamed &&
150+
test_tick &&
151+
git commit -m renamed &&
152+
echo modified >renamed &&
153+
git cherry-pick refs/heads/unrelated
154+
'
155+
144156
test_done

0 commit comments

Comments
 (0)