contrib: add "git-backport-merge" script for backporting merge commits in NetworkManager

On the main branch, we commonly rebase our WIP branches to latest HEAD,
before merging them with "--no-ff". The effect is to have a merge commit
that acts as a parentheses around the set of patches.

When backporting such a branch, we should preserve that structure and
take the merge commit too. We should must use `git cherry-pick -x` to
record the commit IDs of the original patch.

This script helps with that.

Also hook it up in "contrib/scripts/nm-setup-git.sh" to create an alias
for it. This alias has the advantage, of fetching the latest version of
the script from "main" or "origin/main", so it also works on older
branches.
This commit is contained in:
Thomas Haller
2023-02-02 18:24:36 +01:00
parent c8c2e51916
commit 0ee784f1f0
2 changed files with 59 additions and 0 deletions

View File

@@ -109,6 +109,7 @@ git_config_reset blame.markUnblamableLines true
git_config_add notes.displayref 'refs/notes/bugs'
git_config_add remote.origin.fetch 'refs/notes/bugs:refs/notes/bugs'
git_config_reset remote.origin.pushurl 'git@gitlab.freedesktop.org:NetworkManager/NetworkManager.git'
git_config_add 'alias.backport-merge' '! (git show main:contrib/scripts/git-backport-merge || git show origin/main:contrib/scripts/git-backport-merge) | bash -s -'
if [ "$NO_TEST" != 1 ]; then
printf "Run with \"--no-test\" or see \"-h\"\n" >&2