Code

Change xdl_merge to generate output even for null merges
authorCharles Bailey <charles@hashpling.org>
Mon, 25 May 2009 00:21:14 +0000 (01:21 +0100)
committerJunio C Hamano <gitster@pobox.com>
Mon, 25 May 2009 06:56:34 +0000 (23:56 -0700)
xdl_merge used to have a check to ensure that there was at least
some change in one or other side being merged but this suppressed
output for the degenerate case when base, local and remote
contents were all identical.

Removing this check enables correct output in the degenerate case
and xdl_free_script handles freeing NULL scripts so there is no
need to have the check for these calls.

Signed-off-by: Charles Bailey <charles@hashpling.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
t/t6023-merge-file.sh
xdiff/xmerge.c

index 19556350b505fe67d8581f302ba970c02e961a21..796f2128da8a325a09048d3a3fbb3730244357ca 100755 (executable)
@@ -54,7 +54,7 @@ deduxit me super semitas jusitiae,
 EOF
 printf "propter nomen suum." >> new4.txt
 
-test_expect_failure 'merge with no changes' '
+test_expect_success 'merge with no changes' '
        cp orig.txt test.txt &&
        git merge-file test.txt orig.txt orig.txt &&
        test_cmp test.txt orig.txt
index 82b3573e7ada8c6df13ac24a78650b80af91ea73..1ef1d358cef61d546a3cbcb85afe5bb3d318f5a7 100644 (file)
@@ -470,23 +470,22 @@ int xdl_merge(mmfile_t *orig, mmfile_t *mf1, const char *name1,
                return -1;
        }
        status = 0;
-       if (xscr1 || xscr2) {
-               if (!xscr1) {
-                       result->ptr = xdl_malloc(mf2->size);
-                       memcpy(result->ptr, mf2->ptr, mf2->size);
-                       result->size = mf2->size;
-               } else if (!xscr2) {
-                       result->ptr = xdl_malloc(mf1->size);
-                       memcpy(result->ptr, mf1->ptr, mf1->size);
-                       result->size = mf1->size;
-               } else {
-                       status = xdl_do_merge(&xe1, xscr1, name1,
-                                             &xe2, xscr2, name2,
-                                             level, xpp, result);
-               }
-               xdl_free_script(xscr1);
-               xdl_free_script(xscr2);
+       if (!xscr1) {
+               result->ptr = xdl_malloc(mf2->size);
+               memcpy(result->ptr, mf2->ptr, mf2->size);
+               result->size = mf2->size;
+       } else if (!xscr2) {
+               result->ptr = xdl_malloc(mf1->size);
+               memcpy(result->ptr, mf1->ptr, mf1->size);
+               result->size = mf1->size;
+       } else {
+               status = xdl_do_merge(&xe1, xscr1, name1,
+                                     &xe2, xscr2, name2,
+                                     level, xpp, result);
        }
+       xdl_free_script(xscr1);
+       xdl_free_script(xscr2);
+
        xdl_free_env(&xe1);
        xdl_free_env(&xe2);