git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* format-patch: numbered patches from a patch list?
@ 2009-07-22  2:25 tom fogal
  2009-07-22  2:43 ` Junio C Hamano
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: tom fogal @ 2009-07-22  2:25 UTC (permalink / raw)
  To: git

I have a need to generate a numbered sequence of patches from a sparse
sprinkling of patches on a branch.  Is there a way to accomplish this?

Basically I want to say, `for the patches at the heads of these sha1s,
give me a numbered sequence.'  Currently I take the list of shas that I
want, throw them in a file, and loop over each entry:

  for sha in $(cat patches) ; do git format-patch -o a/ ${sha}^..${sha} ; done

This is undesirable because each patch is the first patch in a series,
e.g. "0001-...".  A desirable interface would be specifying multiple
disconnected ranges via some separator, say ",".

To hammer it home; given:

   ... -- A -- B -- C -- D -- E -- F -- G

I'd like a command / line or two of shell which could get me:

  the patch that created A: 0001
  the patch that created B: 0002
  the patch that created E: 0003
  the patch that created G: 0004

etc.  It'd get confusing if I specified multiple branches.  Fortunately
I don't need that use case, and anyway I think just providing a raw
ordering based on timestamp (ignoring branches) would be sufficient for
any (of my) future needs.


The use case for all of this is disconnected repositories that really
shouldn't be.  We do `special' merging in subversion, so I do a lot of
trunk work via git-svn, and then I have backporting sessions where I
identify commits which should go on our release branches and put them
there.

Thanks for any ideas,

-tom

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: format-patch: numbered patches from a patch list?
  2009-07-22  2:25 format-patch: numbered patches from a patch list? tom fogal
@ 2009-07-22  2:43 ` Junio C Hamano
  2009-07-22  2:44 ` Jeff King
  2009-07-22  2:47 ` tom fogal
  2 siblings, 0 replies; 4+ messages in thread
From: Junio C Hamano @ 2009-07-22  2:43 UTC (permalink / raw)
  To: tfogal; +Cc: git

tom fogal <tfogal@alumni.unh.edu> writes:

> I have a need to generate a numbered sequence of patches from a sparse
> sprinkling of patches on a branch.  Is there a way to accomplish this?
>
> Basically I want to say, `for the patches at the heads of these sha1s,
> give me a numbered sequence.'  Currently I take the list of shas that I
> want, throw them in a file, and loop over each entry:
>
>   for sha in $(cat patches) ; do git format-patch -o a/ ${sha}^..${sha} ; done

You can pass --start-number to these invocations of format-patch; maintain
the parameter to give as an argument to the option inside your loop.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: format-patch: numbered patches from a patch list?
  2009-07-22  2:25 format-patch: numbered patches from a patch list? tom fogal
  2009-07-22  2:43 ` Junio C Hamano
@ 2009-07-22  2:44 ` Jeff King
  2009-07-22  2:47 ` tom fogal
  2 siblings, 0 replies; 4+ messages in thread
From: Jeff King @ 2009-07-22  2:44 UTC (permalink / raw)
  To: tfogal; +Cc: git

On Tue, Jul 21, 2009 at 08:25:52PM -0600, tom fogal wrote:

> I have a need to generate a numbered sequence of patches from a sparse
> sprinkling of patches on a branch.  Is there a way to accomplish this?
> 
> Basically I want to say, `for the patches at the heads of these sha1s,
> give me a numbered sequence.'  Currently I take the list of shas that I
> want, throw them in a file, and loop over each entry:
> 
>   for sha in $(cat patches) ; do git format-patch -o a/ ${sha}^..${sha} ; done
> 
> This is undesirable because each patch is the first patch in a series,
> e.g. "0001-...".  A desirable interface would be specifying multiple
> disconnected ranges via some separator, say ",".

Try

  git format-patch --no-walk $(cat patches)

-Peff

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: format-patch: numbered patches from a patch list?
  2009-07-22  2:25 format-patch: numbered patches from a patch list? tom fogal
  2009-07-22  2:43 ` Junio C Hamano
  2009-07-22  2:44 ` Jeff King
@ 2009-07-22  2:47 ` tom fogal
  2 siblings, 0 replies; 4+ messages in thread
From: tom fogal @ 2009-07-22  2:47 UTC (permalink / raw)
  To: git

Answering my own question.

tom fogal <tfogal@alumni.unh.edu> writes:
> I have a need to generate a numbered sequence of patches from
> a sparse sprinkling of patches on a branch.  Is there a way to
> accomplish this?

Yep.  Duh.

Just generate the patches as I did in my my first mail.  Then use
mtime.sh:

    #!/bin/sh

    for patch in $@ ; do
      commitdate=$(head -n 5 ${patch} | \
                   grep "^Date" | \
                   cut -d: -f 2-)
      touch -d "${commitdate}" ${patch}
      shortfn=$(echo "${patch}" | cut -b 1-30)
      echo "Changed ${shortfn} to ${commitdate}"
    done

to change the modification time of every patch I care about.  Now I can
list the files by modification time, achieving exactly what I want.

I really love a full posix environment sometimes.


Sorry for the noise,

-tom

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2009-07-22  2:46 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-07-22  2:25 format-patch: numbered patches from a patch list? tom fogal
2009-07-22  2:43 ` Junio C Hamano
2009-07-22  2:44 ` Jeff King
2009-07-22  2:47 ` tom fogal

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).