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 <johannes.schindelin@gmx.de>
This commit is contained in:
Johannes Schindelin
2016-12-12 22:31:57 +01:00
2 changed files with 13 additions and 1 deletions

View File

@@ -235,7 +235,7 @@ static int add_cacheinfo(struct merge_options *o,
struct cache_entry *nce;
nce = refresh_cache_entry(ce, CE_MATCH_REFRESH | CE_MATCH_IGNORE_MISSING);
if (nce != ce)
if (nce && nce != ce)
ret = add_cache_entry(nce, options);
}
return ret;

View File

@@ -141,4 +141,16 @@ test_expect_success 'cherry-pick "-" works with arguments' '
test_cmp expect actual
'
test_expect_success 'cherry-pick works with dirty renamed file' '
test_commit to-rename &&
git checkout -b unrelated &&
test_commit unrelated &&
git checkout @{-1} &&
git mv to-rename.t renamed &&
test_tick &&
git commit -m renamed &&
echo modified >renamed &&
git cherry-pick refs/heads/unrelated
'
test_done