Skip to content

feat: Use git cherry-pick instead of git am ( = use mergiraf)#87

Open
rvalyi wants to merge 1 commit intoOCA:mainfrom
akretion:feature/use-cherry-pick
Open

feat: Use git cherry-pick instead of git am ( = use mergiraf)#87
rvalyi wants to merge 1 commit intoOCA:mainfrom
akretion:feature/use-cherry-pick

Conversation

@rvalyi
Copy link
Member

@rvalyi rvalyi commented Sep 9, 2025

as I explained here #60, oca-port is currently not taking advantage of a killer merge conflict resolution tool: mergiraf.

This can change if we use git cherry-pick instead of git am in oca-port because cherry-pick has more merging context so mergiraf is kickin'in.

I used it this way for my last porting PRs in OCA/l10n-brazil. But if you prefer I can also craft is as an option. What do you think?

cc @sebalix @simahawk @sbidoul @renatonlima @sebastienbeau @hparfr

@rvalyi rvalyi force-pushed the feature/use-cherry-pick branch from 521140f to cf2cf46 Compare September 9, 2025 14:23
@rvalyi rvalyi changed the title feat: Use git cherry-pick instead of git am feat: Use git cherry-pick instead of git am ( = use mergiraf) Sep 9, 2025
@sebalix
Copy link
Collaborator

sebalix commented Sep 11, 2025

git am is used instead of git cherry-pick because it allows to focus on the module (the path) you want to migrate/port.
If a commit is updating several modules at once, trying a cherry-pick of it on a target branch that doesn't contain all these modules will fail (that's also one of the reason the OCA Migration guide makes use of git format-patch + git am, to focus on a given module path).

But maybe there is an option with git cherry-pick to limit its scope to a given path/git tree?

NOTE: still didn't checked this mergiraf tool!

@rvalyi
Copy link
Member Author

rvalyi commented Sep 11, 2025

thanks for these explanations.

Note that we avoid having a commit change several modules at once in the OCA in general...

But indeed mergiraf doesn't work with git am an it seems unlikely it will work with it. Using git am for migration is not an issue as there is no conflict during the migration. But I'm afraid, on the other hand, porting commits means dealing with lots of conflicts...

You should absolutely try mergiraf, it typically fixed 50% of my conflicts in my daily Odoo routine. That's a BIG deal...

We also have to think about the big picture: the ability to lower the cost of maintaining modules in many branches. In the very close future LLMs will have the ability to migrate 50% of OCA modules and automate the conflict resolution of ports. That means we could have a port bot with modules opting it for auto port. But I feel mergiraf is the 1st step for that...

Would you accept my cherry-pick PR if I craft it as an option?

@rvalyi
Copy link
Member Author

rvalyi commented Sep 11, 2025

@sebalix as for limiting the effect of git cherry-pick to a specific path, Gemini AI just suggested:

git cherry-pick --no-commit <commit-hash>
git reset  #  unstage all the applied changes
git add module_path
git commit

I'll look further if it can be applied to this PR...

@sebalix
Copy link
Collaborator

sebalix commented Sep 13, 2025

I totally agree that resolving conflicts automatically will be a big deal.
I was thinking of another trick to limit the scope and still benefit from git cherry-pick:

  1. apply the patches with git am in a temporary branch (so the commit is ported only for the given module path)
  2. then use git cherry-pick from this temporary branch on the destination branch

Should it fix the workflow with mergiraf?

@rvalyi

This comment was marked as resolved.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants