Re: git apply --3way behaves abnormally when the patch contains binary changes.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, Jul 27, 2021 at 7:07 AM lilinchao@xxxxxxxxxx
<lilinchao@xxxxxxxxxx> wrote:
>
> I see the latest change about `git apply --3way` is 923cd87, but it doesn't seem to have been fully tested
> (in t4108-apply-threeway.sh).
> On latest Git version 2.32.0, consider test case below:
> "
> test_expect_success 'apply binary file patch with --3way' '
>         # 1. on new branch, commit binary file
>         git checkout -b left &&
>         cat "$TEST_DIRECTORY"/test-binary-1.png >bin.png &&
>         git add bin.png &&
>         git commit -m "add binary file" &&
>
>         # 2. based on left_bin branch, make any change, and commit
>         git checkout -b right &&
>         cat bin.png bin.png > bin.png &&
>         git add bin.png &&
>         git commit -m "update binary file" &&
>
>         # 3. make patch
>         git diff --binary left..right >bin.diff &&
>         # apply --3way, and it will fail
>         test_must_fail git apply --index --3way bin.diff
> '
> "
>
> But  "git apply --index --3way bin.diff" will not faill on Git version 2.31.0.
Are you sure? I checked out to "commit
a5828ae6b52137b913b978e16cd2334482eb4c1f (HEAD, tag: v2.31.0)" and
rebuilt and ran your test snippet and it still failed.

This was the message from the failure on 2.31.0
"error: the patch applies to 'bin.png'
(e69de29bb2d1d6434b8b29ae775ad8c2e48c5391), which does not match the
current contents.
Falling back to three-way merge...
warning: Cannot merge binary files: bin.png (ours vs. theirs)
Applied patch to 'bin.png' with conflicts.
U bin.png"

Versus the message on 2.32.0
"warning: Cannot merge binary files: bin.png (ours vs. theirs)
Applied patch to 'bin.png' with conflicts.
U bin.png"

So the failure messaging is different but it returns 1 both times. Is
there a difference between how we're testing?

I did have to modify your test to add
test_expect_success 'apply binary file patch with --3way' '
       # 1. on new branch, commit binary file
       git checkout -b left &&
+       git reset --hard &&

If this behavior is important I'd urge you to add this test to the suite.
>
>



[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux