Skip to content

Conversation

@bfonta
Copy link
Contributor

@bfonta bfonta commented Sep 23, 2025

Added an option to create a new branch before cherry-picking.

This is quite a common operation, for instance whenever starting from a clean release, in order not to loose the original clean from-CMSSW_... branch. The -c flag was chosen to replicate what git switch -c <branch> does. On top, AFAICT from the git cherry-pick documentation, the -c flag has no meaning for git cherry-pick.

The code contains logic to delete the new branch in case any later operation fails.

Tested manually under CMSSW_15_1_0_pre5. Validating it with a random non-existing commit activates the trap, and works as expected:

bfontana@sess-mi300x:/shared/PF_Validation/src  (PF_Sim_Validation) $ /afs/cern.ch/user/b/bfontana/cms-git-tools/git-cms-cherry-pick -C NEW_BRANCH 111111111   
Switched to a new branch 'NEW_BRANCH'
fatal: ambiguous argument '111111111': unknown revision or path not in the working tree.
Use '--' to separate paths from revisions, like this:
'git <command> [<revision>...] -- [<file>...]'
fatal: bad revision '111111111'
Switched to branch 'PF_Sim_Validation'
Deleted branch NEW_BRANCH (was 337299c6945).

@cmsbuild
Copy link

A new Pull Request was created by @bfonta for branch master.

@akritkbehera, @cmsbuild, @iarspider, @smuzaffar can you please review it and eventually sign? Thanks.
@ftenchini, @mandrenguyen, @sextonkennedy you are the release manager for this.
cms-bot commands are listed here

@cmsbuild
Copy link

cmsbuild commented Sep 23, 2025

cms-bot internal usage

@bfonta
Copy link
Contributor Author

bfonta commented Sep 23, 2025

type ngt

@cmsbuild cmsbuild added the ngt label Sep 23, 2025
@fwyzard
Copy link
Contributor

fwyzard commented Sep 23, 2025

How about using -b and -B like git checkout ?

@cmsbuild
Copy link

Pull request #131 was updated.

@bfonta
Copy link
Contributor Author

bfonta commented Sep 24, 2025

@fwyzard The -c choice was intentional: git currently favours the use of git switch and git restore over git checkout, and -c is the flag used in git switch to create a new branch.
On the other hand, I had not included the git switch -C option (equivalent to git checkout -B), which was now added.

@fwyzard
Copy link
Contributor

fwyzard commented Sep 24, 2025

man git switch
...
THIS COMMAND IS EXPERIMENTAL. THE BEHAVIOR MAY CHANGE.

@bfonta
Copy link
Contributor Author

bfonta commented Sep 24, 2025

@fwyzard I saw it, but it was already introduced in 2.23 (the latest is 2.51.0), and I feel the command is there to stay. Ultimately, it's a matter of preference, and I'm open to change it if needed.

@fwyzard
Copy link
Contributor

fwyzard commented Sep 24, 2025

No need to change it - I'm anyway not the target audience of this and most other cms-git tools, since I prefer to use the underlying git tools, since I know what they actually do :-)

@bfonta
Copy link
Contributor Author

bfonta commented Oct 1, 2025

@smuzaffar Could you please open a cmsdist for tests?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants