Discussion:
git MFC/cherry-pick question
Rick Macklem
2021-06-04 02:11:41 UTC
Permalink
Hi,

I am trying to MFC a commit to stable/12.
The cherry-pick works, but the resultant code
is not correct and won't build.
--> I broke the build yesterday and manually
reverted the breakage.

So, how do I do this?

Do I have to manually edit the file after the
cherry-pick and then do something like a
git commit -a
to get the edited change in, or is there a
way to tell it to add it to the cherry-pick or ??

Thanks anyone, for help with this, rick
Alan Somers
2021-06-04 02:28:18 UTC
Permalink
Post by Rick Macklem
Hi,
I am trying to MFC a commit to stable/12.
The cherry-pick works, but the resultant code
is not correct and won't build.
--> I broke the build yesterday and manually
reverted the breakage.
So, how do I do this?
Do I have to manually edit the file after the
cherry-pick and then do something like a
git commit -a
to get the edited change in, or is there a
way to tell it to add it to the cherry-pick or ??
Thanks anyone, for help with this, rick
Is the resulting code incorrect because of a git merge error, or because
stable/13 requires slightly different code than main? If it's the latter,
then after the "git cherry-pick", you should edit the file manually and do
a "git commit -a --amend". That will produce the right result. You don't
have to worry about screwing up merge history by using "--amend", because
"git cherry-pick" already screws up merge history. If your problem is the
former, then the same solution will work, although you might be able to
solve it by using some fancy git merge options instead.

-Alan
Warner Losh
2021-06-04 03:06:20 UTC
Permalink
Post by Alan Somers
Post by Rick Macklem
Hi,
I am trying to MFC a commit to stable/12.
The cherry-pick works, but the resultant code
is not correct and won't build.
--> I broke the build yesterday and manually
reverted the breakage.
So, how do I do this?
Do I have to manually edit the file after the
cherry-pick and then do something like a
git commit -a
to get the edited change in, or is there a
way to tell it to add it to the cherry-pick or ??
Thanks anyone, for help with this, rick
Is the resulting code incorrect because of a git merge error, or because
stable/13 requires slightly different code than main? If it's the latter,
then after the "git cherry-pick", you should edit the file manually and do
a "git commit -a --amend". That will produce the right result. You don't
have to worry about screwing up merge history by using "--amend", because
"git cherry-pick" already screws up merge history. If your problem is the
former, then the same solution will work, although you might be able to
solve it by using some fancy git merge options instead.
git cherry-pick does not screw up merge history. The hashes of the diffs
are used
by git to know what's been merged and what hasn't. git commit --amend to fix
things up screws up this mechanism a bit. That's why we do the
'git cherry-pick -x' which records the hash as a backup. git log
--cherry-pick can
help find changes to merge. There's been some scripts offered to also help
find things...

And usually when git cherry-pick doesn't produce working code, it's because
other things weren't cherry-pucked that the code depends on. Sometimes you
can
find the changes to cherry-pick it, other times you have to do a manual
fixup.

Warner

Loading...