Skip to contentSkip to conversation

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

PATCH In review Tolga Ceylan 2 participants 2 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. When git-p4 runs git-apply to test the patch, git-apply rejects the patch due to abbreviated blob object names. 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

---
 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
Quoted 7 lines · Tolga Ceylan

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. When git-p4 runs git-apply to test the patch, git-apply rejects the patch due to abbreviated blob object names. This is the error message git-apply emits in this case:

Quoted 6 lines

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

---

Because the original breakage was already in 1.9, not a regression between 1.9 and master, as the matter of principle our default is to defer until 2.0 final to avoid risking unintended additional breakages elsewhere. But this fix is an obviously correct and trivial single liner that were eyeballed by more than one person, and that affects only three calls to os.system(), and its correctness can be seen even without knowing p4 at all by somebody like me ;-)

So let's queue it for 2.0.

Thanks.

Quoted 16 lines
 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 -"