]> git.ipfire.org Git - thirdparty/git.git/commit
rebase-merges: try and use branch names as labels
authorNicolas Guichard <nicolas@guichard.eu>
Wed, 9 Oct 2024 07:58:20 +0000 (07:58 +0000)
committerJunio C Hamano <gitster@pobox.com>
Wed, 9 Oct 2024 17:52:46 +0000 (10:52 -0700)
commit436892123dd9d442fe4f534bba6f7ead635db06c
tree332a50ff257c0fe795279b8ed6717cca666ee22e
parent68c9fcb027b4bd2e5d10618829937ee50503c281
rebase-merges: try and use branch names as labels

When interactively rebasing merge commits, the commit message is parsed to
extract a probably meaningful label name. For instance if the merge commit
is “Merge branch 'feature0'”, then the rebase script will have thes lines:
```
label feature0

merge -C $sha feature0 # “Merge branch 'feature0'
```

This heuristic fails in the case of octopus merges or when the merge commit
message is actually unrelated to the parent commits.

An example that combines both is:
```
*---.   967bfa4 (HEAD -> integration) Integration
|\ \ \
| | | * 2135be1 (feature2, feat2) Feature 2
| |_|/
|/| |
| | * c88b01a Feature 1
| |/
|/|
| * 75f3139 (feat0) Feature 0
|/
25c86d0 (main) Initial commit
```
yields the labels Integration, Integration-2 and Integration-3.

Fix this by using a branch name for each merge commit's parent that is the
tip of at least one branch, and falling back to a label derived from the
merge commit message otherwise.
In the example above, the labels become feat0, Integration and feature2.

Signed-off-by: Nicolas Guichard <nicolas@guichard.eu>
Acked-by: Phillip Wood <phillip.wood@dunelm.org.uk>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
sequencer.c
t/t3404-rebase-interactive.sh
t/t3430-rebase-merges.sh