You are viewing a plain text version of this content. The canonical link for it is here.
Posted to infrastructure-dev@apache.org by Gavin <ga...@16degrees.com.au> on 2008/09/30 07:19:47 UTC

How to supply and apply git diffed patches

Hi All,

I have absolutely nothing to do with Git, however recently at Forrest we are
being supplied with patches which are diffs created using git. The paths
seem different and so I haven't tried to apply them, rather cut & paste.

Is there a good way for us to document how to supply git diffed patches, and
a goof way for us to implement them using our svn?

Thanks

Gav...


Re: How to supply and apply git diffed patches

Posted by sebb <se...@gmail.com>.
On 30/09/2008, Norman Maurer <no...@apache.org> wrote:
> Hi Gavin,
>
>  you need to use "patch -p$number_of_dirs_to_strip". See "man patch" for a
>  good explanation.
>  From manpage:
>
>   -pnum  or  --strip=num
>           Strip the smallest prefix containing num leading slashes  from
>  each
>           file  name found in the patch file.  A sequence of one or more
>  adja‐
>           cent slashes is counted as a single slash.  This controls  how
>  file
>           names  found  in  the  patch file are treated, in case you keep
>  your
>           files in a different directory than the  person  who  sent  out
>  the
>           patch.  For example, supposing the file name in the patch file was
>
>              /u/howard/src/blurfl/blurfl.c
>
>           setting -p0 gives the entire file name unmodified, -p1 gives
>
>              u/howard/src/blurfl/blurfl.c
>
>           without the leading slash, -p4 gives
>
>              blurfl/blurfl.c
>
>           and  not specifying -p at all just gives you blurfl.c.  Whatever
>  you
>           end up with is looked for either in the current  directory,  or
>  the
>           directory specified by the -d option.
>

Or use an IDE such as Eclipse (which supports this in the Subclipse dialogues).

>  Cheers,
>  Norman
>
>
>  2008/9/30 Gavin <ga...@16degrees.com.au>
>
>
>  >
>  >
>  > > -----Original Message-----
>  > > From: David Crossley [mailto:crossley@apache.org]
>  > > Sent: Tuesday, 30 September 2008 3:34 PM
>  > > To: infrastructure-dev@apache.org
>  > > Subject: Re: How to supply and apply git diffed patches
>  > >
>  > > Gavin wrote:
>  > > >
>  > > > I have absolutely nothing to do with Git, however recently at Forrest
>  > we
>  > > are
>  > > > being supplied with patches which are diffs created using git. The
>  > paths
>  > > > seem different and so I haven't tried to apply them, rather cut &
>  > paste.
>  > > >
>  > > > Is there a good way for us to document how to supply git diffed
>  > patches,
>  > > and
>  > > > a goof way for us to implement them using our svn?
>  > >
>  > > You need to undertand how to use the 'patch' command's "-p" option.
>  > > One often receives patches that are like this, not just via git.
>  > > This strips the appropriate number of leading slashes from
>  > > file names in the patch.
>  > >
>  > > -David
>  >
>  > ah, thanks for that, so just use -p all the time then maybe.
>  >
>  > I'll try it on the next one.
>  >
>  > Gav...
>  > >
>  > >
>  > > --
>  > > Internal Virus Database is out-of-date.
>  > > Checked by AVG.
>  > > Version: 7.5.524 / Virus Database: 270.6.21 - Release Date: 9/11/2008
>  > > 12:00 AM
>  >
>  >
>

Re: How to supply and apply git diffed patches

Posted by Norman Maurer <no...@apache.org>.
Hi Gavin,

you need to use "patch -p$number_of_dirs_to_strip". See "man patch" for a
good explanation.
>From manpage:

 -pnum  or  --strip=num
          Strip the smallest prefix containing num leading slashes  from
each
          file  name found in the patch file.  A sequence of one or more
adja‐
          cent slashes is counted as a single slash.  This controls  how
file
          names  found  in  the  patch file are treated, in case you keep
your
          files in a different directory than the  person  who  sent  out
the
          patch.  For example, supposing the file name in the patch file was

             /u/howard/src/blurfl/blurfl.c

          setting -p0 gives the entire file name unmodified, -p1 gives

             u/howard/src/blurfl/blurfl.c

          without the leading slash, -p4 gives

             blurfl/blurfl.c

          and  not specifying -p at all just gives you blurfl.c.  Whatever
you
          end up with is looked for either in the current  directory,  or
the
          directory specified by the -d option.


Cheers,
Norman


2008/9/30 Gavin <ga...@16degrees.com.au>

>
>
> > -----Original Message-----
> > From: David Crossley [mailto:crossley@apache.org]
> > Sent: Tuesday, 30 September 2008 3:34 PM
> > To: infrastructure-dev@apache.org
> > Subject: Re: How to supply and apply git diffed patches
> >
> > Gavin wrote:
> > >
> > > I have absolutely nothing to do with Git, however recently at Forrest
> we
> > are
> > > being supplied with patches which are diffs created using git. The
> paths
> > > seem different and so I haven't tried to apply them, rather cut &
> paste.
> > >
> > > Is there a good way for us to document how to supply git diffed
> patches,
> > and
> > > a goof way for us to implement them using our svn?
> >
> > You need to undertand how to use the 'patch' command's "-p" option.
> > One often receives patches that are like this, not just via git.
> > This strips the appropriate number of leading slashes from
> > file names in the patch.
> >
> > -David
>
> ah, thanks for that, so just use -p all the time then maybe.
>
> I'll try it on the next one.
>
> Gav...
> >
> >
> > --
> > Internal Virus Database is out-of-date.
> > Checked by AVG.
> > Version: 7.5.524 / Virus Database: 270.6.21 - Release Date: 9/11/2008
> > 12:00 AM
>
>

RE: How to supply and apply git diffed patches

Posted by Gavin <ga...@16degrees.com.au>.

> -----Original Message-----
> From: David Crossley [mailto:crossley@apache.org]
> Sent: Tuesday, 30 September 2008 3:34 PM
> To: infrastructure-dev@apache.org
> Subject: Re: How to supply and apply git diffed patches
> 
> Gavin wrote:
> >
> > I have absolutely nothing to do with Git, however recently at Forrest we
> are
> > being supplied with patches which are diffs created using git. The paths
> > seem different and so I haven't tried to apply them, rather cut & paste.
> >
> > Is there a good way for us to document how to supply git diffed patches,
> and
> > a goof way for us to implement them using our svn?
> 
> You need to undertand how to use the 'patch' command's "-p" option.
> One often receives patches that are like this, not just via git.
> This strips the appropriate number of leading slashes from
> file names in the patch.
> 
> -David

ah, thanks for that, so just use -p all the time then maybe.

I'll try it on the next one.

Gav...
> 
> 
> --
> Internal Virus Database is out-of-date.
> Checked by AVG.
> Version: 7.5.524 / Virus Database: 270.6.21 - Release Date: 9/11/2008
> 12:00 AM


Re: How to supply and apply git diffed patches

Posted by David Crossley <cr...@apache.org>.
Gavin wrote:
> 
> I have absolutely nothing to do with Git, however recently at Forrest we are
> being supplied with patches which are diffs created using git. The paths
> seem different and so I haven't tried to apply them, rather cut & paste.
> 
> Is there a good way for us to document how to supply git diffed patches, and
> a goof way for us to implement them using our svn?

You need to undertand how to use the 'patch' command's "-p" option.
One often receives patches that are like this, not just via git.
This strips the appropriate number of leading slashes from
file names in the patch.

-David