aboutsummaryrefslogtreecommitdiffstats
path: root/t
diff options
context:
space:
mode:
authorNicolas Guichard <nicolas@guichard.eu>2024-10-09 07:58:20 +0000
committerJunio C Hamano <gitster@pobox.com>2024-10-09 10:52:46 -0700
commit436892123dd9d442fe4f534bba6f7ead635db06c (patch)
tree332a50ff257c0fe795279b8ed6717cca666ee22e /t
parent68c9fcb027b4bd2e5d10618829937ee50503c281 (diff)
downloadgit-436892123dd9d442fe4f534bba6f7ead635db06c.tar.gz
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>
Diffstat (limited to 't')
-rwxr-xr-xt/t3404-rebase-interactive.sh4
-rwxr-xr-xt/t3430-rebase-merges.sh12
2 files changed, 8 insertions, 8 deletions
diff --git a/t/t3404-rebase-interactive.sh b/t/t3404-rebase-interactive.sh
index f171af3061..4896a801ee 100755
--- a/t/t3404-rebase-interactive.sh
+++ b/t/t3404-rebase-interactive.sh
@@ -1870,7 +1870,7 @@ test_expect_success '--update-refs adds commands with --rebase-merges' '
pick $(git log -1 --format=%h branch2~1) F
pick $(git log -1 --format=%h branch2) I
update-ref refs/heads/branch2
- label merge
+ label branch2
reset onto
pick $(git log -1 --format=%h refs/heads/second) J
update-ref refs/heads/second
@@ -1881,7 +1881,7 @@ test_expect_success '--update-refs adds commands with --rebase-merges' '
update-ref refs/heads/third
pick $(git log -1 --format=%h HEAD~2) M
update-ref refs/heads/no-conflict-branch
- merge -C $(git log -1 --format=%h HEAD~1) merge # merge
+ merge -C $(git log -1 --format=%h HEAD~1) branch2 # merge
update-ref refs/heads/merge-branch
EOF
diff --git a/t/t3430-rebase-merges.sh b/t/t3430-rebase-merges.sh
index 2aa8593f77..cb891eeb5f 100755
--- a/t/t3430-rebase-merges.sh
+++ b/t/t3430-rebase-merges.sh
@@ -108,19 +108,19 @@ test_expect_success 'generate correct todo list' '
reset onto
pick $b B
- label E
+ label first
reset onto
pick $c C
label branch-point
pick $f F
pick $g G
- label H
+ label second
reset branch-point # C
pick $d D
- merge -C $e E # E
- merge -C $h H # H
+ merge -C $e first # E
+ merge -C $h second # H
EOF
@@ -462,11 +462,11 @@ test_expect_success 'A root commit can be a cousin, treat it that way' '
'
test_expect_success 'labels that are object IDs are rewritten' '
- git checkout -b third B &&
+ git checkout --detach B &&
test_commit I &&
third=$(git rev-parse HEAD) &&
git checkout -b labels main &&
- git merge --no-commit third &&
+ git merge --no-commit $third &&
test_tick &&
git commit -m "Merge commit '\''$third'\'' into labels" &&
echo noop >script-from-scratch &&