# Re: Patch-level-format conversion

4 messages from 2011-06-15 to 2011-06-15. Participants: Jonathan Nieder, Sedat Dilek, Junio C Hamano.
Thread: https://gitlist.dev/t/27633

## Jonathan Nieder, 2011-06-15 20:55

Subject: Re: Patch-level-format conversion
Message-ID: <20110615205507.GB27172@elie>
URL: https://gitlist.dev/e/20110615205507.GB27172%40elie
In-Reply-To: <BANLkTimRArtFBqA4BFASjkS9BC1sbSfUJQ@mail.gmail.com>

```
(+cc: the git list so others can correct me.  I hope that's okay.)

Hi,

Sedat Dilek wrote:

> I have here a patchset extracted from my own git-repo (via git format-patch).
>
> The project for which those patches are want "p0" format, means no
> ---- a/... +++ b/... but --- ... +++ ...
>
> IIRC git does "p1" format as default.
> Any help? Idea?

If I understand correctly, you are in luck.  The "git format-patch
--no-prefix" command thanks to Dscho seems to do exactly that:

 $ git log -Sno-prefix -- Documentation/diff-options.txt
 commit eab9a40b6dd5c1c571b1deb264133db47bb4794d
 Author: Johannes Schindelin <Johannes.Schindelin@gmx.de>
 Date:   Tue Dec 18 19:32:14 2007 +0000

     Teach diff machinery to display other prefixes than "a/" and "b/"

     With the new options "--src-prefix=<prefix>", "--dst-prefix=<prefix>"
     and "--no-prefix", you can now control the path prefixes of the diff
     machinery.  These used to by hardwired to "a/" for the source prefix
     and "b/" for the destination prefix.

     Initial patch by Pascal Obry.  Sane option names suggested by Linus.

     Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
     Acked-by: Linus Torvalds <torvalds@linux-foundation.org>
     Signed-off-by: Junio C Hamano <gitster@pobox.com>

Hope that helps.
Jonathan

```

## Sedat Dilek, 2011-06-15 21:16

Subject: Re: Patch-level-format conversion
Message-ID: <BANLkTim8bdVGo8u_HzZpE_5+xmPe_O+_Dw@mail.gmail.com>
URL: https://gitlist.dev/e/BANLkTim8bdVGo8u_HzZpE_5%2BxmPe_O%2B_Dw%40mail.gmail.com
In-Reply-To: <20110615205507.GB27172@elie>

```
On Wed, Jun 15, 2011 at 10:55 PM, Jonathan Nieder <jrnieder@gmail.com> wrote:
> (+cc: the git list so others can correct me.  I hope that's okay.)
>
> Hi,
>
> Sedat Dilek wrote:
>
>> I have here a patchset extracted from my own git-repo (via git format-patch).
>>
>> The project for which those patches are want "p0" format, means no
>> ---- a/... +++ b/... but --- ... +++ ...
>>
>> IIRC git does "p1" format as default.
>> Any help? Idea?
>
> If I understand correctly, you are in luck.  The "git format-patch
> --no-prefix" command thanks to Dscho seems to do exactly that:
>
>  $ git log -Sno-prefix -- Documentation/diff-options.txt
>  commit eab9a40b6dd5c1c571b1deb264133db47bb4794d
>  Author: Johannes Schindelin <Johannes.Schindelin@gmx.de>
>  Date:   Tue Dec 18 19:32:14 2007 +0000
>
>     Teach diff machinery to display other prefixes than "a/" and "b/"
>
>     With the new options "--src-prefix=<prefix>", "--dst-prefix=<prefix>"
>     and "--no-prefix", you can now control the path prefixes of the diff
>     machinery.  These used to by hardwired to "a/" for the source prefix
>     and "b/" for the destination prefix.
>
>     Initial patch by Pascal Obry.  Sane option names suggested by Linus.
>
>     Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
>     Acked-by: Linus Torvalds <torvalds@linux-foundation.org>
>     Signed-off-by: Junio C Hamano <gitster@pobox.com>
>
> Hope that helps.
> Jonathan
>

Hi Jonathan,

I played a bit with git format-patch and git diff and got some helpful
hints from friends of #grml and #quassel.de.
Attached is the README.txt I produced some hours ago.

Regards,
- Sedat -


Q: How to generate freetz-conform patches out of a GIT repository?

A. Follow these instructions.

### Checkout freetz development branch
svn co http://svn.freetz.org/trunk/ freetz-trunk
cd freetz-trunk/

### Get latest revision
revision=$(LC_ALL=C svn info | grep "Last Changed Rev" | awk {'print $4'})
echo $revision

### Turn freetz-trunk source-dir into a GIT repository
git add --ignore-errors ./ ; git commit -m "`basename $PWD` SVN revision $revision"

### Edit some files and save changes
$EDITOR file1 file2

### Extract patchset
git format-patch --no-prefix --no-numbered $FIRST..$LAST

### Some git format-patch options explained:
      --no-prefix: Do not show any source or destination prefix.
   -n, --numbered: Name output in [PATCH n/m] format, even with a single patch.
-N, --no-numbered: Name output in [PATCH] format.


- Sedat Dilek <sedat.dilek@gmail.com> (15-Jun-2011)

```

## Junio C Hamano, 2011-06-15 22:13

Subject: Re: Patch-level-format conversion
Message-ID: <7v39jakajn.fsf@alter.siamese.dyndns.org>
URL: https://gitlist.dev/e/7v39jakajn.fsf%40alter.siamese.dyndns.org
In-Reply-To: <BANLkTim8bdVGo8u_HzZpE_5+xmPe_O+_Dw@mail.gmail.com>

```
Sedat Dilek <sedat.dilek@googlemail.com> writes:

> I played a bit with git format-patch and git diff and got some helpful
> hints from friends of #grml and #quassel.de.
> Attached is the README.txt I produced some hours ago.
>
> Regards,
> - Sedat -
>
> Q: How to generate freetz-conform patches out of a GIT repository?
>
> A. Follow these instructions.
>
> ### Checkout freetz development branch
> svn co http://svn.freetz.org/trunk/ freetz-trunk
> cd freetz-trunk/
>
> ### Get latest revision
> revision=$(LC_ALL=C svn info | grep "Last Changed Rev" | awk {'print $4'})
> echo $revision
>
> ### Turn freetz-trunk source-dir into a GIT repository
> git add --ignore-errors ./ ; git commit -m "`basename $PWD` SVN revision $revision"

Wouldn't "add ./" add all the cruft in .svn (and its huge "pristine"
subdirectory)?  Why --ignore-errors?

> ### Edit some files and save changes
> $EDITOR file1 file2
>
> ### Extract patchset
> git format-patch --no-prefix --no-numbered $FIRST..$LAST

You would need to record your own changes made by the $EDITOR step in
commits before asking format-patch to make patch files out of them, but I
do not see that step.

Also it is unclear how you determine $FIRST and $LAST.  FIRST must name
the commit that is the _parent_ of your first commit (i.e. your sample
command line tells $FIRST to be excluded).

> ### Some git format-patch options explained:
>       --no-prefix: Do not show any source or destination prefix.
>    -n, --numbered: Name output in [PATCH n/m] format, even with a single patch.
> -N, --no-numbered: Name output in [PATCH] format.
>
>
> - Sedat Dilek <sedat.dilek@gmail.com> (15-Jun-2011)

```

## Sedat Dilek, 2011-06-15 22:28

Subject: Re: Patch-level-format conversion
Message-ID: <BANLkTi=w1SP6zEZGs1WQ_2L0bWQ2cneNSQ@mail.gmail.com>
URL: https://gitlist.dev/e/BANLkTi%3Dw1SP6zEZGs1WQ_2L0bWQ2cneNSQ%40mail.gmail.com
In-Reply-To: <7v39jakajn.fsf@alter.siamese.dyndns.org>

```
Hi Junio,

On Thu, Jun 16, 2011 at 12:13 AM, Junio C Hamano <gitster@pobox.com> wrote:
> Sedat Dilek <sedat.dilek@googlemail.com> writes:
>
>> I played a bit with git format-patch and git diff and got some helpful
>> hints from friends of #grml and #quassel.de.
>> Attached is the README.txt I produced some hours ago.
>>
>> Regards,
>> - Sedat -
>>
>> Q: How to generate freetz-conform patches out of a GIT repository?
>>
>> A. Follow these instructions.
>>
>> ### Checkout freetz development branch
>> svn co http://svn.freetz.org/trunk/ freetz-trunk
>> cd freetz-trunk/
>>
>> ### Get latest revision
>> revision=$(LC_ALL=C svn info | grep "Last Changed Rev" | awk {'print $4'})
>> echo $revision
>>
>> ### Turn freetz-trunk source-dir into a GIT repository
>> git add --ignore-errors ./ ; git commit -m "`basename $PWD` SVN revision $revision"
>
> Wouldn't "add ./" add all the cruft in .svn (and its huge "pristine"
> subdirectory)?  Why --ignore-errors?
>

I used to use it after reading the blog-post in [1].

>> ### Edit some files and save changes
>> $EDITOR file1 file2
>>
>> ### Extract patchset
>> git format-patch --no-prefix --no-numbered $FIRST..$LAST
>
> You would need to record your own changes made by the $EDITOR step in
> commits before asking format-patch to make patch files out of them, but I
> do not see that step.
>

Ooops, yeah missed the git commit command(s) :-(.
Thanks for the pointer!

> Also it is unclear how you determine $FIRST and $LAST.  FIRST must name
> the commit that is the _parent_ of your first commit (i.e. your sample
> command line tells $FIRST to be excluded).
>

It's just an example...
IIRC I really did "git format-patch --no-prefix -19" (extract last 19 commits).
Hmmm, remember I got no "origine" for initial commit...

>> ### Some git format-patch options explained:
>>       --no-prefix: Do not show any source or destination prefix.
>>    -n, --numbered: Name output in [PATCH n/m] format, even with a single patch.
>> -N, --no-numbered: Name output in [PATCH] format.
>>
>>
>> - Sedat Dilek <sedat.dilek@gmail.com> (15-Jun-2011)
>

- Sedat -

[1] http://who-t.blogspot.com/2009/06/git-patches-from-tarballs.html

```
