# [PATCH] git-p4: format-patch to diff-tree change breaks binary patches

6 messages from 2014-04-25 to 2014-05-05. Participants: Tolga Ceylan, Pete Wyckoff, tolga ceylan.
Thread: https://gitlist.dev/t/36494

## Tolga Ceylan, 2014-04-25 04:46

Subject: [PATCH] git-p4: format-patch to diff-tree change breaks binary patches
Message-ID: <20140425044618.GA7058@olive>
URL: https://gitlist.dev/e/20140425044618.GA7058%40olive

```
When applying binary patches a full index is required. format-patch
already handles this, but diff-tree needs '--full-index' argument
to always output full index.

Signed-off-by: Tolga Ceylan <tolga.ceylan@gmail.com>
---
 git-p4.py |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/git-p4.py b/git-p4.py
index cdfa2df..4ee6739 100755
--- a/git-p4.py
+++ b/git-p4.py
@@ -1311,7 +1311,7 @@ class P4Submit(Command, P4UserMap):
             else:
                 die("unknown modifier %s for %s" % (modifier, path))
 
-        diffcmd = "git diff-tree -p \"%s\"" % (id)
+        diffcmd = "git diff-tree --full-index -p \"%s\"" % (id)
         patchcmd = diffcmd + " | git apply "
         tryPatchCmd = patchcmd + "--check -"
         applyPatchCmd = patchcmd + "--check --apply -"
-- 
1.7.9.5

```

## Pete Wyckoff, 2014-04-26 12:43

Subject: Re: [PATCH] git-p4: format-patch to diff-tree change breaks binary patches
Message-ID: <20140426124307.GB4767@padd.com>
URL: https://gitlist.dev/e/20140426124307.GB4767%40padd.com
In-Reply-To: <20140425044618.GA7058@olive>

```
tolga.ceylan@gmail.com wrote on Thu, 24 Apr 2014 21:46 -0700:
> When applying binary patches a full index is required. format-patch
> already handles this, but diff-tree needs '--full-index' argument
> to always output full index.
> 
> Signed-off-by: Tolga Ceylan <tolga.ceylan@gmail.com>
> ---
>  git-p4.py |    2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/git-p4.py b/git-p4.py
> index cdfa2df..4ee6739 100755
> --- a/git-p4.py
> +++ b/git-p4.py
> @@ -1311,7 +1311,7 @@ class P4Submit(Command, P4UserMap):
>              else:
>                  die("unknown modifier %s for %s" % (modifier, path))
>  
> -        diffcmd = "git diff-tree -p \"%s\"" % (id)
> +        diffcmd = "git diff-tree --full-index -p \"%s\"" % (id)
>          patchcmd = diffcmd + " | git apply "
>          tryPatchCmd = patchcmd + "--check -"
>          applyPatchCmd = patchcmd + "--check --apply -"
> -- 

This looks like a straightforward change, but can you give a
bit more background on why a full index is required?  Do you
mean that "git apply" will reject a patch with abbreviated
blob object names?

		-- Pete

```

## tolga ceylan, 2014-04-26 21:12

Subject: Re: [PATCH] git-p4: format-patch to diff-tree change breaks binary patches
Message-ID: <535C2138.3050400@gmail.com>
URL: https://gitlist.dev/e/535C2138.3050400%40gmail.com
In-Reply-To: <20140426124307.GB4767@padd.com>

```
Yes, when git-p4 runs git-apply to test the patch, this fails
due to abbreviated blob object names. I think git-apply requires
full object names for binary patches.

On 04/26/2014 05:43 AM, Pete Wyckoff wrote:
> tolga.ceylan@gmail.com wrote on Thu, 24 Apr 2014 21:46 -0700:
>> When applying binary patches a full index is required. format-patch
>> already handles this, but diff-tree needs '--full-index' argument
>> to always output full index.
>>
>> Signed-off-by: Tolga Ceylan <tolga.ceylan@gmail.com>
>> ---
>>   git-p4.py |    2 +-
>>   1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/git-p4.py b/git-p4.py
>> index cdfa2df..4ee6739 100755
>> --- a/git-p4.py
>> +++ b/git-p4.py
>> @@ -1311,7 +1311,7 @@ class P4Submit(Command, P4UserMap):
>>               else:
>>                   die("unknown modifier %s for %s" % (modifier, path))
>>
>> -        diffcmd = "git diff-tree -p \"%s\"" % (id)
>> +        diffcmd = "git diff-tree --full-index -p \"%s\"" % (id)
>>           patchcmd = diffcmd + " | git apply "
>>           tryPatchCmd = patchcmd + "--check -"
>>           applyPatchCmd = patchcmd + "--check --apply -"
>> --
>
> This looks like a straightforward change, but can you give a
> bit more background on why a full index is required?  Do you
> mean that "git apply" will reject a patch with abbreviated
> blob object names?
>
> 		-- Pete
>

```

## tolga ceylan, 2014-04-26 21:31

Subject: Re: [PATCH] git-p4: format-patch to diff-tree change breaks binary patches
Message-ID: <535C25B5.4050506@gmail.com>
URL: https://gitlist.dev/e/535C25B5.4050506%40gmail.com
In-Reply-To: <535C2138.3050400@gmail.com>

```


On 04/26/2014 02:12 PM, tolga ceylan wrote:
> Yes, when git-p4 runs git-apply to test the patch, this fails
> due to abbreviated blob object names. I think git-apply requires
> full object names for binary patches.
>
>> This looks like a straightforward change, but can you give a
>> bit more background on why a full index is required?  Do you
>> mean that "git apply" will reject a patch with abbreviated
>> blob object names?
>>
>>         -- Pete
>>

This is the error message git-apply emits in this case:

error: cannot apply binary patch to '<filename>' without full index line
error: <filename>: patch does not apply

Cheers,
Tolga

```

## tolga ceylan, 2014-05-03 05:40

Subject: Re: [PATCH] git-p4: format-patch to diff-tree change breaks binary patches
Message-ID: <53648169.7010307@gmail.com>
URL: https://gitlist.dev/e/53648169.7010307%40gmail.com
In-Reply-To: <535C25B5.4050506@gmail.com>

```

>
> This is the error message git-apply emits in this case:
>
> error: cannot apply binary patch to '<filename>' without full index line
> error: <filename>: patch does not apply
>
> Cheers,
> Tolga

Any feedback is appreciated.
Cheers,
Tolga

```

## Pete Wyckoff, 2014-05-05 13:14

Subject: Re: [PATCH] git-p4: format-patch to diff-tree change breaks binary patches
Message-ID: <20140505131456.GA21505@padd.com>
URL: https://gitlist.dev/e/20140505131456.GA21505%40padd.com
In-Reply-To: <53648169.7010307@gmail.com>

```
tolga.ceylan@gmail.com wrote on Fri, 02 May 2014 22:40 -0700:
> 
> >
> >This is the error message git-apply emits in this case:
> >
> >error: cannot apply binary patch to '<filename>' without full index line
> >error: <filename>: patch does not apply
> >
> >Cheers,
> >Tolga
> 
> Any feedback is appreciated.

Sorry, travel delay.  This explanation is pretty
straight-forward, thanks.

Suggest you include it in the commit message along with the
other text you had, and resend to the list, cc me and junio.
Oh, and include an ack:

    Acked-by: Pete Wyckoff <pw@padd.com>

```
