Skip to contentSkip to conversation

git p4: Use git diff-tree instead of format-patch

PATCH In review Crestez Dan Leonard 3 participants 4 messages Jun 15, 2016

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 git p4: Use git diff-tree instead of format-patch

The output of git format-patch can vary with user preferences. In particular setting diff.noprefix will break the "git apply" that is done as part of "git p4 submit".

---
 git-p4.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
git-p4.py +1 -1
index 31e71ff..fe988ce 100755
@@ -1308,7 +1308,7 @@ class P4Submit(Command, P4UserMap):
             else:
                 die("unknown modifier %s for %s" % (modifier, path))
 
-        diffcmd = "git format-patch -k --stdout \"%s^\"..\"%s\"" % (id, id)
+        diffcmd = "git diff-tree -p \"%s\"" % (id)
         patchcmd = diffcmd + " | git apply "
         tryPatchCmd = patchcmd + "--check -"
         applyPatchCmd = patchcmd + "--check --apply -"
#1 lore raw
Quoted 14 lines · Crestez Dan Leonard

The output of git format-patch can vary with user preferences. In particular setting diff.noprefix will break the "git apply" that is done as part of "git p4 submit".

---
 git-p4.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
git-p4.py +0 -0
index 31e71ff..fe988ce 100755

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

Quoted 8 lines
git-p4.py +1 -1
@@ -1308,7 +1308,7 @@ class P4Submit(Command, P4UserMap):
             else:
                 die("unknown modifier %s for %s" % (modifier, path))
 
-        diffcmd = "git format-patch -k --stdout \"%s^\"..\"%s\"" % (id, id)
+        diffcmd = "git diff-tree -p \"%s\"" % (id)
         patchcmd = diffcmd + " | git apply "
         tryPatchCmd = patchcmd + "--check -"
         applyPatchCmd = patchcmd + "--check --apply -"

I do not do p4 myself, but from a cursory reading it looks like the right thing to do. Thanks.

The output of "git shortlog --no-merges --since=1.year git-p4.py" tells me that Pete should be the person much more familiar with the code than myself, so I'll Cc him just in case...

Acked-by
#2 lore raw

[email protected] wrote on Thu, 21 Nov 2013 11:47 -0800:

Quoted 28 lines
Quoted 14 lines · Crestez Dan Leonard

The output of git format-patch can vary with user preferences. In particular setting diff.noprefix will break the "git apply" that is done as part of "git p4 submit".

---
 git-p4.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
git-p4.py +0 -0
index 31e71ff..fe988ce 100755

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

Quoted 8 lines
git-p4.py +1 -1
@@ -1308,7 +1308,7 @@ class P4Submit(Command, P4UserMap):
             else:
                 die("unknown modifier %s for %s" % (modifier, path))
 
-        diffcmd = "git format-patch -k --stdout \"%s^\"..\"%s\"" % (id, id)
+        diffcmd = "git diff-tree -p \"%s\"" % (id)
         patchcmd = diffcmd + " | git apply "
         tryPatchCmd = patchcmd + "--check -"
         applyPatchCmd = patchcmd + "--check --apply -"

I do not do p4 myself, but from a cursory reading it looks like the right thing to do. Thanks.

Quoted 3 lines

The output of "git shortlog --no-merges --since=1.year git-p4.py" tells me that Pete should be the person much more familiar with the code than myself, so I'll Cc him just in case...

This looks great, and passes all my tests.

Thanks,

		-- Pete