Commit cherry-picking

4 messages, 2 authors, 2016-06-15 · open the first message on its own page

Commit cherry-picking

From: Alberto Bertogli <hidden>
Date: 2016-06-15 22:43:02

Hi!

I often use darcs, and one feature I miss when I use git is the ability
to do cherry-picking on what I'm about to commit.

It allows me to do small changes to the code when I'm working on
something else, and don't do ugly commits.

I know the proper way to do this would be to have different branches and
all. But that means I have to switch between branches to do quick fixes,
which is an expensive operation in human terms, because I have to stop
thinking about the code and switch branches and so on.

So I wrote two small scripts to do that: git-pcp and git-commit-cp. The
former acts as a helper to the later. Both are attached.

git-pcp takes a diff file, and produces two files: one with the hunks to
apply, and another one with the ones to skip. It asks the user to
select, for each hunk, where to put it.

git-commit-cp is the command to use, which calls git-pcp to do the
cherrypicking, and then applies the corresponding patches.


The implementation of git-pcp should be better (the diff parsing is not
as strong as it should be, although it works for most cases; and the
user interaction sucks, because I don't like UI =), so it's working but
it needs some improvements.


I wanted to ask you if this was an acceptable command to add to git, and
if you had any recommendations or thoughts about the implementation.

Thanks a lot,
		Alberto


PS: Is there a way of telling git-diff how many context lines to use?

Re: Commit cherry-picking

From: Shawn O. Pearce <hidden>
Date: 2016-06-15 22:43:02

Alberto Bertogli [off-list ref] wrote:
I often use darcs, and one feature I miss when I use git is the ability
to do cherry-picking on what I'm about to commit.
Have you tried:

	git add -i
	git commit

?

The `git add -i` flag starts up an interactive tool that you can use
to add patch hunks to the index, staging them for the next commit.
Running commit with no arguments will then commit exactly what is
in the index, leaving the other hunks beind in the working directory.

Or did I miss something?  Note that `git add -i` was added as a
new feature in Git 1.5.0 (and later).

-- 
Shawn.

Re: Commit cherry-picking

From: Shawn O. Pearce <hidden>
Date: 2016-06-15 22:43:02

"Shawn O. Pearce" [off-list ref] wrote:
Alberto Bertogli [off-list ref] wrote:
quoted
I often use darcs, and one feature I miss when I use git is the ability
to do cherry-picking on what I'm about to commit.
Have you tried:

	git add -i
	git commit

?

The `git add -i` flag starts up an interactive tool that you can use
to add patch hunks to the index, staging them for the next commit.
Running commit with no arguments will then commit exactly what is
in the index, leaving the other hunks beind in the working directory.
Also `git gui` (or `git citool`) offers this hunk selection feature,
but in a Tcl/Tk based GUI format.  The hunk selection isn't as
powerful as I'd like it to be, but it works well enough that I
haven't bothered to improve upon it.
 
Or did I miss something?  Note that `git add -i` was added as a
new feature in Git 1.5.0 (and later).
git-gui also shipped in 1.5.0...

-- 
Shawn.

Re: Commit cherry-picking

From: Alberto Bertogli <hidden>
Date: 2016-06-15 22:43:02

On Tue, Apr 03, 2007 at 01:33:44AM -0400, Shawn O. Pearce wrote:
"Shawn O. Pearce" [off-list ref] wrote:
quoted
Alberto Bertogli [off-list ref] wrote:
quoted
I often use darcs, and one feature I miss when I use git is the ability
to do cherry-picking on what I'm about to commit.
Have you tried:

	git add -i
	git commit
[...]
Also `git gui` (or `git citool`) offers this hunk selection feature,
Argh, how can I have missed all that!

Sorry for the noise, and thanks for the suggestions.

		Alberto
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help