git cherry-pick

David Wolfskill david at catwhisker.org
Sat May 1 01:35:36 UTC 2021


On Sat, May 01, 2021 at 02:09:29AM +0100, tech-lists wrote:
> git newbie here. If one has the full git /usr/src repo, and wants to
> build for stable/13, what are the commands to "cherry-pick" a commit from main
> and apply it to (local) stable/13? 
> 
> thanks,
> -- 
> J.

I strongly suspect that the most correct succinct answer will be "it
depends."  Unfortunately, that's not especially useful.

So: here is *a* way that worked in this specific set of circumstances:

| g1-55(12.2-S)[9] cd /bkp/tmp/
| g1-55(12.2-S)[10] ls -F
| ...
| g1-55(12.2-S)[11] mkdir src

So: I switched over to a place where I had some scratch space (as I have
no plans to keep this repository).

| g1-55(12.2-S)[12] git clone file:///repo/git/freebsd/src.git src
| Cloning into 'src'...

I keep a local private mirror of the FreeBSD.org git repo.  <shrug>  I
could have used "https://git.freebsd.org/src.git", but it would have
taken longer, and might have interfered with Spouse's streaming video.

| remote: Enumerating objects: 429434, done.
| remote: Counting objects: 100% (429434/429434), done.
| remote: Compressing objects: 100% (45509/45509), done.
| Receiving objects: 100% (3874077/3874077), 1.19 GiB | 32.66 MiB/s, done.
| remote: Total 3874077 (delta 411617), reused 386363 (delta 383799), pack-reused 3444643
| Resolving deltas: 100% (3066950/3066950), done.
| Updating files: 100% (86557/86557), done.
| g1-55(12.2-S)[13] cd src
| g1-55(12.2-S)[14] git branch | cat
| * main

So this repo is currently using branch "main".  I'll find a commit to
cherry-pick.

| g1-55(12.2-S)[15] git log -n 1 | cat
| commit 388c0cde10293d9a3434e99146bf391aec6878a3
| Author: Kristof Provost <kp at FreeBSD.org>
| Date:   Tue Apr 27 18:46:03 2021 +0200
| 
|     pf tests: Test scrub fragment reassemble on interfaces with different MTU
|     
|     There's a problem with pf's reassembly code where it produces incorrect
|     checksums when reassembling across interfaces with different MTUs.
|     Test this.
|     
|     PR:             255432
|     Reviewed by:    donner
|     MFC after:      1 week
|     Sponsored by:   Rubicon Communications, LLC ("Netgate")
|     Differential Revision:  https://reviews.freebsd.org/D30013

OK; that seems like a reasonable candidate....

| g1-55(12.2-S)[16] git checkout stable/13
| Branch 'stable/13' set up to track remote branch 'stable/13' from 'origin'.
| Switched to a new branch 'stable/13'

I switched to stable/13.

| g1-55(12.2-S)[17] git cherry-pick 388c0cde10293d9a3434e99146bf391aec6878a3
| [stable/13 419302f5369] pf tests: Test scrub fragment reassemble on interfaces with different MTU
|  Author: Kristof Provost <kp at FreeBSD.org>
|  Date: Tue Apr 27 18:46:03 2021 +0200
|  1 file changed, 49 insertions(+)
| g1-55(12.2-S)[18] 

And that was the cherry-pick.

Mind, there exist ... nuances, I suppose.  If the commit to be
cherry-picked is a merge commit, you will need to provide some
addiitonal information (as detailed in the output of "git help
cherry-pick").

Caveat: While I do use some of this at work, I am by no means an
"expert."  I suspect that there may well be "sharp edges" in some of
this stuff.

I suggest that if you have the resources to do so, you experiment with
an expendable copy of your repo first.

Oh: after all that:

| g1-55(12.2-S)[18] git status 
| On branch stable/13
| Your branch is ahead of 'origin/stable/13' by 1 commit.
|   (use "git push" to publish your local commits)
| 
| nothing to commit, working tree clean
| g1-55(12.2-S)[19] 

Peace,
david
-- 
David H. Wolfskill                              david at catwhisker.org
"some of the terminology that was used, like 'hugs and kisses,' and 'very
fine people,' is like very different from what I experienced and what my
co-workers experienced on the 6th." - Michael Fanone, DC Metro Police Officer

See https://www.catwhisker.org/~david/publickey.gpg for my public key.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 618 bytes
Desc: not available
URL: <http://lists.freebsd.org/pipermail/freebsd-git/attachments/20210430/3369cc23/attachment.sig>


More information about the freebsd-git mailing list