Easier cherry-picking

124 views
Skip to first unread message

Torsten Ihben

unread,
Feb 11, 2022, 7:38:33 AM2/11/22
to Repo and Gerrit Discussion
Hi!
Our mode of working requires that we need to do cherry-picks from gerrit quite often. However this is "hidden" in the Download dialog, between several other download options. I wondered if there's an easier way for me to get my cherry-picks.

I also searched for a Greasemonkey script, since this tool would allow such a help without the need to modify gerrit itself, but I didn't find anything.

Are you aware of something that allows e.g. to get the cherry-pick commandline via a button directly on a patch set, without the download dialog? Or would it be feasible to add a configuration to remove the unneeded download options from the Download dialog?

Thanks!
Torsten

Sven Selberg

unread,
Feb 11, 2022, 7:50:44 AM2/11/22
to Repo and Gerrit Discussion
You could try to install the ref-copy plugin [1], together with a small git alias you should have what you need.
~/.gitconfig
-------------------------
[alias]
    cpu = !sh -c 'git fetch origin $1 && git checkout FETCH_HEAD' -
-------------------------

1. Copy the $PATCHSET_REF from the change-screen.
2 Commandline in your local copy of the git project:
$ git cpu $PATCHSET_REF



Thanks!
Torsten

Sven Selberg

unread,
Feb 11, 2022, 7:52:44 AM2/11/22
to Repo and Gerrit Discussion
On Friday, February 11, 2022 at 1:50:44 PM UTC+1 Sven Selberg wrote:
On Friday, February 11, 2022 at 1:38:33 PM UTC+1 torste...@gmail.com wrote:
Hi!
Our mode of working requires that we need to do cherry-picks from gerrit quite often. However this is "hidden" in the Download dialog, between several other download options. I wondered if there's an easier way for me to get my cherry-picks.

I also searched for a Greasemonkey script, since this tool would allow such a help without the need to modify gerrit itself, but I didn't find anything.

Are you aware of something that allows e.g. to get the cherry-pick commandline via a button directly on a patch set, without the download dialog? Or would it be feasible to add a configuration to remove the unneeded download options from the Download dialog?

You could try to install the ref-copy plugin [1], together with a small git alias you should have what you need.
~/.gitconfig
-------------------------
[alias]
    cpu = !sh -c 'git fetch origin $1 && git checkout FETCH_HEAD' -
Sorry muscle-memory...it should be 
    cpu = !sh -c 'git fetch origin $1 && git cherry-pick FETCH_HEAD' -

Oswald Buddenhagen

unread,
Feb 11, 2022, 7:54:24 AM2/11/22
to repo-d...@googlegroups.com
On Wed, Feb 09, 2022 at 06:20:37AM -0800, Torsten Ihben wrote:
>Are you aware of something that allows e.g. to get the cherry-pick
>commandline via a button directly on a patch set, without the download
>dialog? Or would it be feasible to add a configuration to remove the
>unneeded download options from the Download dialog?
>
the git-gpick script you'll find referenced in
https://wiki.qt.io/Git-gpush-scripts is rather smart.

Björn Pedersen

unread,
Feb 14, 2022, 2:22:07 AM2/14/22
to Repo and Gerrit Discussion
At least in gerrit 3.3 the " ... " menu on a change has "cherry-pick" in it and it works as long as the cherry-pick is conflict-free.

Björn

Torsten Ihben

unread,
Feb 14, 2022, 3:09:39 AM2/14/22
to Repo and Gerrit Discussion
Hi all!
Thanks for the nice suggestions. The one provided by Oswald currently seems to be the most promising one, the only downside is: Every user needs to download the script locally. I'd love to have some server-side solution so that everyone could benefit from.
@Björn, I see the cherry-pick command also in our version (3.2.8) in the "..." menu - however this opens a dialog to cherry-pick the change into another remote branch, not into my local working branch. Is this different in version 3.3?
@Sven, the documentation of the ref-copy plugin is not that verbose. Can you comment on where this plugin provides the ref on the UI? A colleague mentioned that this is added to the Download dialog, so instead of making cherry-picking easier by reducing the clutter around this command, it adds even more clutter to it.
Thanks,
Torsten

Sven Selberg

unread,
Feb 14, 2022, 3:45:37 AM2/14/22
to Repo and Gerrit Discussion
On Monday, February 14, 2022 at 9:09:39 AM UTC+1 torste...@gmail.com wrote:
Hi all!
Thanks for the nice suggestions. The one provided by Oswald currently seems to be the most promising one, the only downside is: Every user needs to download the script locally. I'd love to have some server-side solution so that everyone could benefit from.
@Björn, I see the cherry-pick command also in our version (3.2.8) in the "..." menu - however this opens a dialog to cherry-pick the change into another remote branch, not into my local working branch. Is this different in version 3.3?
@Sven, the documentation of the ref-copy plugin is not that verbose. Can you comment on where this plugin provides the ref on the UI? A colleague mentioned that this is added to the Download dialog, so instead of making cherry-picking easier by reducing the clutter around this command, it adds even more clutter to it.

It's a very small plugin, not much to document ;-). But as is stated in the terse documentation [1] it also adds a copyable input as a change-metadata-item which is located below the commit/change data and the file-list.
I suggest that you install the plugin locally and decide for yourself if it is a good fit for your needs or not.

/Sven

[1]

Torsten Ihben

unread,
Feb 14, 2022, 5:31:21 AM2/14/22
to Repo and Gerrit Discussion
Hi Sven!

I cannot simpy try out the plugin since I don't have a local instance of gerrit. I could ask our admins to do so, but that's not that easy.

Best regards,
Torsten

Torsten Ihben

unread,
Feb 18, 2022, 5:55:38 AM2/18/22
to Repo and Gerrit Discussion
Hi all!

So as far as I understand, there no plugin for gerrit that provides an easy direct way to get the cherry-pick command. The gpick command Oswald suggested works fine at least for a local solution. Also no one is aware of an external extension, e.g. a GreaseMonkey script which could provide this command.

Thanks all!
Torsten

Reply all
Reply to author
Forward
0 new messages