]> granicus.if.org Git - git/commitdiff
merge-recursive: handle NULL in add_cacheinfo() correctly
authorJohannes Schindelin <johannes.schindelin@gmx.de>
Sat, 26 Nov 2016 12:48:06 +0000 (13:48 +0100)
committerJunio C Hamano <gitster@pobox.com>
Mon, 28 Nov 2016 19:00:04 +0000 (11:00 -0800)
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 https://github.com/git-for-windows/git/issues/952

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
merge-recursive.c
t/t3501-revert-cherry-pick.sh

index de37e5153c791cb51fc77974edc30d0c44daf4d7..56385d4c01b732b77fdf463408109f8d3ca67be8 100644 (file)
@@ -213,6 +213,8 @@ static int add_cacheinfo(unsigned int mode, const unsigned char *sha1,
                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);
        }
index 5bef564ff15d5e7c8e35cf1d085191faf319e84c..22970d2223853a23da8d5ef4b5719c8c56028ff9 100755 (executable)
@@ -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 &&