All of lore.kernel.org
 help / color / mirror / Atom feed
* git-cherries
@ 2012-02-27 10:56 Thien-Thi Nguyen
  2012-02-27 19:27 ` git-cherries Jeff King
  0 siblings, 1 reply; 3+ messages in thread
From: Thien-Thi Nguyen @ 2012-02-27 10:56 UTC (permalink / raw)
  To: git

[-- Attachment #1: Type: text/plain, Size: 385 bytes --]

For my personal use, i wrote git-cherries, attached.
It commits each hunk of every modified file separately
(creating cherries to cherry-pick later, you see).

I am writing to ask if this is already in Git somewhere,
and if not, for tips on how to make it faster / more elegant.

Please cc me in replies, as i am not subscribed.

Thanks!

_____________________________________________

[-- Attachment #2: git-cherries --]
[-- Type: application/octet-stream, Size: 454 bytes --]

#!/bin/sh
blurb="${1-cherry}"
git status --short \
    | sed '/^ M /!d;s///' \
    | while read filename
do
    printf '\nprocessing: %s\n' $filename
    n=0
    while [ "$(git status --short -- $filename)" ]
    do
        n=$(expr 1 + $n)
        printf 'y\nq\n' | git add --patch $filename >/dev/null
        printf '%5d -- ' $n
        git commit -m"$n $filename ($blurb)" \
            | sed '1d;s/.* changed, //;s/[^0-9,]//g;s/,/& /'
    done
done

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

* Re: git-cherries
  2012-02-27 10:56 git-cherries Thien-Thi Nguyen
@ 2012-02-27 19:27 ` Jeff King
  2012-03-02 11:19   ` git-cherries Thien-Thi Nguyen
  0 siblings, 1 reply; 3+ messages in thread
From: Jeff King @ 2012-02-27 19:27 UTC (permalink / raw)
  To: Thien-Thi Nguyen; +Cc: git

On Mon, Feb 27, 2012 at 11:56:19AM +0100, Thien-Thi Nguyen wrote:

> For my personal use, i wrote git-cherries, attached.
> It commits each hunk of every modified file separately
> (creating cherries to cherry-pick later, you see).
> 
> I am writing to ask if this is already in Git somewhere,
> and if not, for tips on how to make it faster / more elegant.

So if I understand correctly, this just creates a series of commits, one
per hunk, of what's in your working tree. And the commit messages won't
be useful, so this is really about recording the work somewhere so that
you can pick it out later using "git cherry-pick --no-commit", make a
real commit from some subset of the cherries, and then throw away the
cherries?

I think you could do this more simply by putting everything in a single
throw-away commit, then using "git checkout -p $throwaway" to pick the
individual cherries from the single commit. You don't grab the commit
message from $throwaway as you might with cherry-pick, but by definition
it's not a very good commit message anyway.

-Peff

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

* Re: git-cherries
  2012-02-27 19:27 ` git-cherries Jeff King
@ 2012-03-02 11:19   ` Thien-Thi Nguyen
  0 siblings, 0 replies; 3+ messages in thread
From: Thien-Thi Nguyen @ 2012-03-02 11:19 UTC (permalink / raw)
  To: Jeff King; +Cc: git

() Jeff King <peff@peff.net>
() Mon, 27 Feb 2012 14:27:46 -0500

   So if I understand correctly, this just creates a series of commits, one
   per hunk, of what's in your working tree. And the commit messages won't
   be useful, so this is really about recording the work somewhere so that
   you can pick it out later using "git cherry-pick --no-commit", make a
   real commit from some subset of the cherries, and then throw away the
   cherries?

   I think you could do this more simply by putting everything in a single
   throw-away commit, then using "git checkout -p $throwaway" to pick the
   individual cherries from the single commit. You don't grab the commit
   message from $throwaway as you might with cherry-pick, but by definition
   it's not a very good commit message anyway.

Cool; "git checkout -p" was what i was missing.  Thanks for the tip!

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

end of thread, other threads:[~2012-03-02 11:20 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-02-27 10:56 git-cherries Thien-Thi Nguyen
2012-02-27 19:27 ` git-cherries Jeff King
2012-03-02 11:19   ` git-cherries Thien-Thi Nguyen

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.