# [PATCH] git p4: Use git diff-tree instead of format-patch

4 messages from 2013-11-21 to 2013-11-22. Participants: Crestez Dan Leonard, Junio C Hamano, Pete Wyckoff.
Thread: https://gitlist.dev/t/35375

## Crestez Dan Leonard, 2013-11-21 15:19

Subject: [PATCH] git p4: Use git diff-tree instead of format-patch
Message-ID: <528E2467.4030900@gmail.com>
URL: https://gitlist.dev/e/528E2467.4030900%40gmail.com

```

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".

Signed-off-by: Crestez Dan Leonard <cdleonard@gmail.com>
---
  git-p4.py | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)




diff --git a/git-p4.py b/git-p4.py
index 31e71ff..fe988ce 100755
--- a/git-p4.py
+++ b/git-p4.py
@@ -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 -"


```

## Junio C Hamano, 2013-11-21 19:47

Subject: Re: [PATCH] git p4: Use git diff-tree instead of format-patch
Message-ID: <xmqqa9gx4jv6.fsf@gitster.dls.corp.google.com>
URL: https://gitlist.dev/e/xmqqa9gx4jv6.fsf%40gitster.dls.corp.google.com
In-Reply-To: <528E2467.4030900@gmail.com>

```
Crestez Dan Leonard <cdleonard@gmail.com> writes:

> 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".
>
> Signed-off-by: Crestez Dan Leonard <cdleonard@gmail.com>
> ---
>  git-p4.py | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/git-p4.py b/git-p4.py
> index 31e71ff..fe988ce 100755
> --- a/git-p4.py
> +++ b/git-p4.py
> @@ -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...

```

## Pete Wyckoff, 2013-11-22 23:12

Subject: Re: [PATCH] git p4: Use git diff-tree instead of format-patch
Message-ID: <20131122231245.GA30589@padd.com>
URL: https://gitlist.dev/e/20131122231245.GA30589%40padd.com
In-Reply-To: <xmqqa9gx4jv6.fsf@gitster.dls.corp.google.com>

```
gitster@pobox.com wrote on Thu, 21 Nov 2013 11:47 -0800:
> Crestez Dan Leonard <cdleonard@gmail.com> writes:
> 
> > 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".
> >
> > Signed-off-by: Crestez Dan Leonard <cdleonard@gmail.com>
> > ---
> >  git-p4.py | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/git-p4.py b/git-p4.py
> > index 31e71ff..fe988ce 100755
> > --- a/git-p4.py
> > +++ b/git-p4.py
> > @@ -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...

This looks great, and passes all my tests.

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

Thanks,

		-- Pete

```

## Junio C Hamano, 2013-11-22 23:35

Subject: Re: [PATCH] git p4: Use git diff-tree instead of format-patch
Message-ID: <xmqqmwkwyppj.fsf@gitster.dls.corp.google.com>
URL: https://gitlist.dev/e/xmqqmwkwyppj.fsf%40gitster.dls.corp.google.com
In-Reply-To: <20131122231245.GA30589@padd.com>

```
Thanks.

```
