Skip to content

Commit

Permalink
merge-recursive: handle NULL in add_cacheinfo() correctly
Browse files Browse the repository at this point in the history
1335d76e45 ("merge: avoid "safer crlf" during recording of merge
results", 2016-07-08) tried to split make_cache_entry() call made
with CE_MATCH_REFRESH into a call to make_cache_entry() without one,
followed by a call to add_cache_entry(), refresh_cache() and another
add_cache_entry() as needed.  However the conversion was botched in
that it forgot that refresh_cache() can return NULL, which was
handled correctly in make_cache_entry() but in the updated code.

This fixes git-for-windows/git#952

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
(cherry picked from commit 55e9f0e5c9a918c246b7eae1fe2a2e954f6426af)
Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>

Gbp-Pq: Name merge-recursive-handle-NULL-in-add_cacheinfo-correctl.diff
  • Loading branch information
dscho authored and jrn committed Apr 20, 2020
1 parent 81f8d60 commit 8819db3
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 2 additions & 0 deletions merge-recursive.c
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,8 @@ 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)
return error(_("addinfo_cache failed for path '%s'"), path);
if (nce != ce)
ret = add_cache_entry(nce, options);
}
Expand Down
2 changes: 1 addition & 1 deletion t/t3501-revert-cherry-pick.sh
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ test_expect_success 'cherry-pick "-" works with arguments' '
test_cmp expect actual
'

test_expect_failure 'cherry-pick works with dirty renamed file' '
test_expect_success 'cherry-pick works with dirty renamed file' '
test_commit to-rename &&
git checkout -b unrelated &&
test_commit unrelated &&
Expand Down

0 comments on commit 8819db3

Please sign in to comment.