Skip to contentSkip to conversation

git-p4: format-patch to diff-tree change breaks binary patches

PATCH In review Tolga Ceylan 2 participants 6 messages Jun 15, 2016

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 git-p4: format-patch to diff-tree change breaks binary patches

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.

---
 git-p4.py |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
git-p4.py +1 -1
index cdfa2df..4ee6739 100755
@@ -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 -"
Signature · 1 line
1.7.9.5
#1 lore raw

[email protected] wrote on Thu, 24 Apr 2014 21:46 -0700:

Quoted 15 lines

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.

---
 git-p4.py |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
git-p4.py +0 -0
index cdfa2df..4ee6739 100755

git-p4.py class P4Submit(Command, P4UserMap): · line 1317

Quoted 8 lines
git-p4.py +1 -1
@@ -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
#2 lore raw

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.

Quoted 32 lines · Pete Wyckoff

[email protected] wrote on Thu, 24 Apr 2014 21:46 -0700:

Quoted 14 lines

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.

---
  git-p4.py |    2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
git-p4.py +0 -0
index cdfa2df..4ee6739 100755

git-p4.py class P4Submit(Command, P4UserMap):

Quoted 9 lines
git-p4.py +1 -2
@@ -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
#3 lore raw
Quoted 11 lines · tolga ceylan

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.

Quoted 7 lines

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

#4 lore raw
Quoted 9 lines

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

Acked-by
#5 lore raw

[email protected] wrote on Fri, 02 May 2014 22:40 -0700:

Quoted 11 lines
Quoted 9 lines

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: