diff options
-rwxr-xr-x | t/t6023-merge-file.sh | 2 | ||||
-rw-r--r-- | xdiff/xmerge.c | 31 |
2 files changed, 16 insertions, 17 deletions
diff --git a/t/t6023-merge-file.sh b/t/t6023-merge-file.sh index 19556350b5..796f2128da 100755 --- a/t/t6023-merge-file.sh +++ b/t/t6023-merge-file.sh @@ -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 diff --git a/xdiff/xmerge.c b/xdiff/xmerge.c index 82b3573e7a..1ef1d358ce 100644 --- a/xdiff/xmerge.c +++ b/xdiff/xmerge.c @@ -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); |