diff options
author | Junio C Hamano <gitster@pobox.com> | 2022-01-05 14:01:29 -0800 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2022-01-05 14:01:30 -0800 |
commit | bb14cfdfd74c37f4319405eaebce0691c5b51db0 (patch) | |
tree | ff830f599931dd6952e354ffd1ba0b2bedea8a76 /t | |
parent | Merge branch 'km/help-prompt-fix' (diff) | |
parent | merge: allow to pretend a merge is made into a different branch (diff) | |
download | tgif-bb14cfdfd74c37f4319405eaebce0691c5b51db0.tar.xz |
Merge branch 'jc/merge-detached-head-name'
The default merge message prepared by "git merge" records the name
of the current branch; the name can be overridden with a new option
to allow users to pretend a merge is made on a different branch.
* jc/merge-detached-head-name:
merge: allow to pretend a merge is made into a different branch
Diffstat (limited to 't')
-rwxr-xr-x | t/t6200-fmt-merge-msg.sh | 42 |
1 files changed, 41 insertions, 1 deletions
diff --git a/t/t6200-fmt-merge-msg.sh b/t/t6200-fmt-merge-msg.sh index a4c02d7b88..7544245f90 100755 --- a/t/t6200-fmt-merge-msg.sh +++ b/t/t6200-fmt-merge-msg.sh @@ -633,7 +633,35 @@ test_expect_success 'merge-msg with "merging" an annotated tag' ' test_cmp expected .git/MERGE_MSG ' +test_expect_success 'merge --into-name=<name>' ' + test_when_finished "git checkout main" && + git checkout -B side main && + git commit --allow-empty -m "One step ahead" && + + git checkout --detach main && + git merge --no-ff side && + git show -s --format="%s" >full.0 && + head -n1 full.0 >actual && + # expect that HEAD is shown as-is + grep -e "Merge branch .side. into HEAD$" actual && + + git reset --hard main && + git merge --no-ff --into-name=main side && + git show -s --format="%s" >full.1 && + head -n1 full.1 >actual && + # expect that we pretend to be merging to main, that is suppressed + grep -e "Merge branch .side.$" actual && + + git checkout -b throwaway main && + git merge --no-ff --into-name=main side && + git show -s --format="%s" >full.2 && + head -n1 full.2 >actual && + # expect that we pretend to be merging to main, that is suppressed + grep -e "Merge branch .side.$" actual +' + test_expect_success 'merge.suppressDest configuration' ' + test_when_finished "git checkout main" && git checkout -B side main && git commit --allow-empty -m "One step ahead" && git checkout main && @@ -650,7 +678,19 @@ test_expect_success 'merge.suppressDest configuration' ' git -c merge.suppressDest="ma?*[rn]" fmt-merge-msg <.git/FETCH_HEAD >full.3 && head -n1 full.3 >actual && grep -e "Merge branch .side." actual && - ! grep -e " into main$" actual + ! grep -e " into main$" actual && + + git checkout --detach HEAD && + git -c merge.suppressDest="main" fmt-merge-msg <.git/FETCH_HEAD >full.4 && + head -n1 full.4 >actual && + grep -e "Merge branch .side. into HEAD$" actual && + + git -c merge.suppressDest="main" fmt-merge-msg \ + --into-name=main <.git/FETCH_HEAD >full.5 && + head -n1 full.5 >actual && + grep -e "Merge branch .side." actual && + ! grep -e " into main$" actual && + ! grep -e " into HEAD$" actual ' test_done |