#!/bin/sh # # Copyright (c) 2006, Junio C Hamano # global test_description := ''fmt-merge-msg test'' source ./test-lib.sh test_expect_success setup ' echo one >one && git add one && test_tick && git commit -m "Initial" && git clone . remote && echo uno >one && echo dos >two && git add two && test_tick && git commit -a -m "Second" && git checkout -b left && echo "c1" >one && test_tick && git commit -a -m "Common #1" && echo "c2" >one && test_tick && git commit -a -m "Common #2" && git branch right && echo "l3" >two && test_tick && GIT_COMMITTER_NAME="Another Committer" \ GIT_AUTHOR_NAME="Another Author" git commit -a -m "Left #3" && echo "l4" >two && test_tick && GIT_COMMITTER_NAME="Another Committer" \ GIT_AUTHOR_NAME="Another Author" git commit -a -m "Left #4" && echo "l5" >two && test_tick && GIT_COMMITTER_NAME="Another Committer" \ GIT_AUTHOR_NAME="Another Author" git commit -a -m "Left #5" && git tag tag-l5 && git checkout right && echo "r3" >three && git add three && test_tick && git commit -a -m "Right #3" && git tag tag-r3 && echo "r4" >three && test_tick && git commit -a -m "Right #4" && echo "r5" >three && test_tick && git commit -a -m "Right #5" && git checkout -b long && i=0 && while test $i -lt 30 do test_commit $i one && i=$(($i+1)) done && git show-branch && apos="'''''" ' test_expect_success 'message for merging local branch' ' echo "Merge branch ${apos}left${apos}" >expected && git checkout master && git fetch . left && git fmt-merge-msg <.git/FETCH_HEAD >actual && test_cmp expected actual ' test_expect_success 'message for merging external branch' ' echo "Merge branch ${apos}left${apos} of $(pwd)" >expected && git checkout master && git fetch "$(pwd)" left && git fmt-merge-msg <.git/FETCH_HEAD >actual && test_cmp expected actual ' test_expect_success '[merge] summary/log configuration' ' cat >expected <<-EOF && Merge branch ${apos}left${apos} # By Another Author (3) and A U Thor (2) # Via Another Committer * left: Left #5 Left #4 Left #3 Common #2 Common #1 EOF test_config merge.log true && test_unconfig merge.summary && git checkout master && test_tick && git fetch . left && git fmt-merge-msg <.git/FETCH_HEAD >actual1 && test_unconfig merge.log && test_config merge.summary true && git checkout master && test_tick && git fetch . left && git fmt-merge-msg <.git/FETCH_HEAD >actual2 && test_cmp expected actual1 && test_cmp expected actual2 ' test_expect_success 'setup FETCH_HEAD' ' git checkout master && test_tick && git fetch . left ' test_expect_success 'merge.log=3 limits shortlog length' ' cat >expected <<-EOF && Merge branch ${apos}left${apos} # By Another Author (3) and A U Thor (2) # Via Another Committer * left: (5 commits) Left #5 Left #4 Left #3 ... EOF git -c merge.log=3 fmt-merge-msg <.git/FETCH_HEAD >actual && test_cmp expected actual ' test_expect_success 'merge.log=5 shows all 5 commits' ' cat >expected <<-EOF && Merge branch ${apos}left${apos} # By Another Author (3) and A U Thor (2) # Via Another Committer * left: Left #5 Left #4 Left #3 Common #2 Common #1 EOF git -c merge.log=5 fmt-merge-msg <.git/FETCH_HEAD >actual && test_cmp expected actual ' test_expect_success '--log=5 with custom comment character' ' cat >expected <<-EOF && Merge branch ${apos}left${apos} x By Another Author (3) and A U Thor (2) x Via Another Committer * left: Left #5 Left #4 Left #3 Common #2 Common #1 EOF git -c core.commentchar="x" fmt-merge-msg --log=5 <.git/FETCH_HEAD >actual && test_cmp expected actual ' test_expect_success 'merge.log=0 disables shortlog' ' echo "Merge branch ${apos}left${apos}" >expected && git -c merge.log=0 fmt-merge-msg <.git/FETCH_HEAD >actual && test_cmp expected actual ' test_expect_success '--log=3 limits shortlog length' ' cat >expected <<-EOF && Merge branch ${apos}left${apos} # By Another Author (3) and A U Thor (2) # Via Another Committer * left: (5 commits) Left #5 Left #4 Left #3 ... EOF git fmt-merge-msg --log=3 <.git/FETCH_HEAD >actual && test_cmp expected actual ' test_expect_success '--log=5 shows all 5 commits' ' cat >expected <<-EOF && Merge branch ${apos}left${apos} # By Another Author (3) and A U Thor (2) # Via Another Committer * left: Left #5 Left #4 Left #3 Common #2 Common #1 EOF git fmt-merge-msg --log=5 <.git/FETCH_HEAD >actual && test_cmp expected actual ' test_expect_success '--no-log disables shortlog' ' echo "Merge branch ${apos}left${apos}" >expected && git fmt-merge-msg --no-log <.git/FETCH_HEAD >actual && test_cmp expected actual ' test_expect_success '--log=0 disables shortlog' ' echo "Merge branch ${apos}left${apos}" >expected && git fmt-merge-msg --no-log <.git/FETCH_HEAD >actual && test_cmp expected actual ' test_expect_success 'fmt-merge-msg -m' ' echo "Sync with left" >expected && cat >expected.log <<-EOF && Sync with left # By Another Author (3) and A U Thor (2) # Via Another Committer * ${apos}left${apos} of $(pwd): Left #5 Left #4 Left #3 Common #2 Common #1 EOF test_unconfig merge.log && test_unconfig merge.summary && git checkout master && git fetch "$(pwd)" left && git fmt-merge-msg -m "Sync with left" <.git/FETCH_HEAD >actual && git fmt-merge-msg --log -m "Sync with left" \ <.git/FETCH_HEAD >actual.log && test_config merge.log true && git fmt-merge-msg -m "Sync with left" \ <.git/FETCH_HEAD >actual.log-config && git fmt-merge-msg --no-log -m "Sync with left" \ <.git/FETCH_HEAD >actual.nolog && test_cmp expected actual && test_cmp expected.log actual.log && test_cmp expected.log actual.log-config && test_cmp expected actual.nolog ' test_expect_success 'setup: expected shortlog for two branches' ' cat >expected <<-EOF Merge branches ${apos}left${apos} and ${apos}right${apos} # By Another Author (3) and A U Thor (2) # Via Another Committer * left: Left #5 Left #4 Left #3 Common #2 Common #1 * right: Right #5 Right #4 Right #3 Common #2 Common #1 EOF ' test_expect_success 'shortlog for two branches' ' test_config merge.log true && test_unconfig merge.summary && git checkout master && test_tick && git fetch . left right && git fmt-merge-msg <.git/FETCH_HEAD >actual1 && test_unconfig merge.log && test_config merge.summary true && git checkout master && test_tick && git fetch . left right && git fmt-merge-msg <.git/FETCH_HEAD >actual2 && test_config merge.log yes && test_unconfig merge.summary && git checkout master && test_tick && git fetch . left right && git fmt-merge-msg <.git/FETCH_HEAD >actual3 && test_unconfig merge.log && test_config merge.summary yes && git checkout master && test_tick && git fetch . left right && git fmt-merge-msg <.git/FETCH_HEAD >actual4 && test_cmp expected actual1 && test_cmp expected actual2 && test_cmp expected actual3 && test_cmp expected actual4 ' test_expect_success 'merge-msg -F' ' test_unconfig merge.log && test_config merge.summary yes && git checkout master && test_tick && git fetch . left right && git fmt-merge-msg -F .git/FETCH_HEAD >actual && test_cmp expected actual ' test_expect_success 'merge-msg -F in subdirectory' ' test_unconfig merge.log && test_config merge.summary yes && git checkout master && test_tick && git fetch . left right && mkdir sub && cp .git/FETCH_HEAD sub/FETCH_HEAD && ( cd sub && git fmt-merge-msg -F FETCH_HEAD >../actual ) && test_cmp expected actual ' test_expect_success 'merge-msg with nothing to merge' ' test_unconfig merge.log && test_config merge.summary yes && >empty && ( cd remote && git checkout -b unrelated && test_tick && git fetch origin && git fmt-merge-msg <.git/FETCH_HEAD >../actual ) && test_cmp empty actual ' test_expect_success 'merge-msg tag' ' cat >expected <<-EOF && Merge tag ${apos}tag-r3${apos} * tag ${apos}tag-r3${apos}: Right #3 Common #2 Common #1 EOF test_unconfig merge.log && test_config merge.summary yes && git checkout master && test_tick && git fetch . tag tag-r3 && git fmt-merge-msg <.git/FETCH_HEAD >actual && test_cmp expected actual ' test_expect_success 'merge-msg two tags' ' cat >expected <<-EOF && Merge tags ${apos}tag-r3${apos} and ${apos}tag-l5${apos} * tag ${apos}tag-r3${apos}: Right #3 Common #2 Common #1 # By Another Author (3) and A U Thor (2) # Via Another Committer * tag ${apos}tag-l5${apos}: Left #5 Left #4 Left #3 Common #2 Common #1 EOF test_unconfig merge.log && test_config merge.summary yes && git checkout master && test_tick && git fetch . tag tag-r3 tag tag-l5 && git fmt-merge-msg <.git/FETCH_HEAD >actual && test_cmp expected actual ' test_expect_success 'merge-msg tag and branch' ' cat >expected <<-EOF && Merge branch ${apos}left${apos}, tag ${apos}tag-r3${apos} * tag ${apos}tag-r3${apos}: Right #3 Common #2 Common #1 # By Another Author (3) and A U Thor (2) # Via Another Committer * left: Left #5 Left #4 Left #3 Common #2 Common #1 EOF test_unconfig merge.log && test_config merge.summary yes && git checkout master && test_tick && git fetch . tag tag-r3 left && git fmt-merge-msg <.git/FETCH_HEAD >actual && test_cmp expected actual ' test_expect_success 'merge-msg lots of commits' ' { cat <<-EOF && Merge branch ${apos}long${apos} * long: (35 commits) EOF i=29 && while test $i -gt 9 do echo " $i" && i=$(($i-1)) done && echo " ..." } >expected && test_config merge.summary yes && git checkout master && test_tick && git fetch . long && git fmt-merge-msg <.git/FETCH_HEAD >actual && test_cmp expected actual ' test_expect_success 'merge-msg with "merging" an annotated tag' ' test_config merge.log true && git checkout master^0 && git commit --allow-empty -m "One step ahead" && git tag -a -m "An annotated one" annote HEAD && git checkout master && git fetch . annote && git fmt-merge-msg <.git/FETCH_HEAD >actual && { cat <<-\EOF Merge tag '''''annote''''' An annotated one * tag '''''annote''''': One step ahead EOF } >expected && test_cmp expected actual && test_when_finished "git reset --hard" && annote=$(git rev-parse annote) && git merge --no-commit $annote && { cat <<-EOF Merge tag '''''$annote''''' An annotated one * tag '''''$annote''''': One step ahead EOF } >expected && test_cmp expected .git/MERGE_MSG ' test_done (CommandList children: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:test_description) op: Equal rhs: {(SQ <"fmt-merge-msg test">)} spids: [13] ) ] spids: [13] ) (C {(.)} {(./test-lib.sh)}) (C {(test_expect_success)} {(setup)} { (SQ <"\n"> <"\techo one >one &&\n"> <"\tgit add one &&\n"> <"\ttest_tick &&\n"> <"\tgit commit -m \"Initial\" &&\n"> <"\n"> <"\tgit clone . remote &&\n"> <"\n"> <"\techo uno >one &&\n"> <"\techo dos >two &&\n"> <"\tgit add two &&\n"> <"\ttest_tick &&\n"> <"\tgit commit -a -m \"Second\" &&\n"> <"\n"> <"\tgit checkout -b left &&\n"> <"\n"> <"\techo \"c1\" >one &&\n"> <"\ttest_tick &&\n"> <"\tgit commit -a -m \"Common #1\" &&\n"> <"\n"> <"\techo \"c2\" >one &&\n"> <"\ttest_tick &&\n"> <"\tgit commit -a -m \"Common #2\" &&\n"> <"\n"> <"\tgit branch right &&\n"> <"\n"> <"\techo \"l3\" >two &&\n"> <"\ttest_tick &&\n"> <"\tGIT_COMMITTER_NAME=\"Another Committer\" \\\n"> <"\tGIT_AUTHOR_NAME=\"Another Author\" git commit -a -m \"Left #3\" &&\n"> <"\n"> <"\techo \"l4\" >two &&\n"> <"\ttest_tick &&\n"> <"\tGIT_COMMITTER_NAME=\"Another Committer\" \\\n"> <"\tGIT_AUTHOR_NAME=\"Another Author\" git commit -a -m \"Left #4\" &&\n"> <"\n"> <"\techo \"l5\" >two &&\n"> <"\ttest_tick &&\n"> <"\tGIT_COMMITTER_NAME=\"Another Committer\" \\\n"> <"\tGIT_AUTHOR_NAME=\"Another Author\" git commit -a -m \"Left #5\" &&\n"> <"\tgit tag tag-l5 &&\n"> <"\n"> <"\tgit checkout right &&\n"> <"\n"> <"\techo \"r3\" >three &&\n"> <"\tgit add three &&\n"> <"\ttest_tick &&\n"> <"\tgit commit -a -m \"Right #3\" &&\n"> <"\tgit tag tag-r3 &&\n"> <"\n"> <"\techo \"r4\" >three &&\n"> <"\ttest_tick &&\n"> <"\tgit commit -a -m \"Right #4\" &&\n"> <"\n"> <"\techo \"r5\" >three &&\n"> <"\ttest_tick &&\n"> <"\tgit commit -a -m \"Right #5\" &&\n"> <"\n"> <"\tgit checkout -b long &&\n"> <"\ti=0 &&\n"> <"\twhile test $i -lt 30\n"> <"\tdo\n"> <"\t\ttest_commit $i one &&\n"> <"\t\ti=$(($i+1))\n"> <"\tdone &&\n"> <"\n"> <"\tgit show-branch &&\n"> <"\n"> <"\tapos=\""> ) (EscapedLiteralPart token:) (SQ <"\"\n">) } ) (C {(test_expect_success)} {(SQ <"message for merging local branch">)} { (SQ <"\n"> <"\techo \"Merge branch ${apos}left${apos}\" >expected &&\n"> <"\n"> <"\tgit checkout master &&\n"> <"\tgit fetch . left &&\n"> <"\n"> <"\tgit fmt-merge-msg <.git/FETCH_HEAD >actual &&\n"> <"\ttest_cmp expected actual\n"> ) } ) (C {(test_expect_success)} {(SQ <"message for merging external branch">)} { (SQ <"\n"> <"\techo \"Merge branch ${apos}left${apos} of $(pwd)\" >expected &&\n"> <"\n"> <"\tgit checkout master &&\n"> <"\tgit fetch \"$(pwd)\" left &&\n"> <"\n"> <"\tgit fmt-merge-msg <.git/FETCH_HEAD >actual &&\n"> <"\ttest_cmp expected actual\n"> ) } ) (C {(test_expect_success)} {(SQ <"[merge] summary/log configuration">)} { (SQ <"\n"> <"\tcat >expected <<-EOF &&\n"> <"\tMerge branch ${apos}left${apos}\n"> <"\n"> <"\t# By Another Author (3) and A U Thor (2)\n"> <"\t# Via Another Committer\n"> <"\t* left:\n"> <"\t Left #5\n"> <"\t Left #4\n"> <"\t Left #3\n"> <"\t Common #2\n"> <"\t Common #1\n"> <"\tEOF\n"> <"\n"> <"\ttest_config merge.log true &&\n"> <"\ttest_unconfig merge.summary &&\n"> <"\n"> <"\tgit checkout master &&\n"> <"\ttest_tick &&\n"> <"\tgit fetch . left &&\n"> <"\n"> <"\tgit fmt-merge-msg <.git/FETCH_HEAD >actual1 &&\n"> <"\n"> <"\ttest_unconfig merge.log &&\n"> <"\ttest_config merge.summary true &&\n"> <"\n"> <"\tgit checkout master &&\n"> <"\ttest_tick &&\n"> <"\tgit fetch . left &&\n"> <"\n"> <"\tgit fmt-merge-msg <.git/FETCH_HEAD >actual2 &&\n"> <"\n"> <"\ttest_cmp expected actual1 &&\n"> <"\ttest_cmp expected actual2\n"> ) } ) (C {(test_expect_success)} {(SQ <"setup FETCH_HEAD">)} {(SQ <"\n"> <"\tgit checkout master &&\n"> <"\ttest_tick &&\n"> <"\tgit fetch . left\n">)} ) (C {(test_expect_success)} {(SQ <"merge.log=3 limits shortlog length">)} { (SQ <"\n"> <"\tcat >expected <<-EOF &&\n"> <"\tMerge branch ${apos}left${apos}\n"> <"\n"> <"\t# By Another Author (3) and A U Thor (2)\n"> <"\t# Via Another Committer\n"> <"\t* left: (5 commits)\n"> <"\t Left #5\n"> <"\t Left #4\n"> <"\t Left #3\n"> <"\t ...\n"> <"\tEOF\n"> <"\n"> <"\tgit -c merge.log=3 fmt-merge-msg <.git/FETCH_HEAD >actual &&\n"> <"\ttest_cmp expected actual\n"> ) } ) (C {(test_expect_success)} {(SQ <"merge.log=5 shows all 5 commits">)} { (SQ <"\n"> <"\tcat >expected <<-EOF &&\n"> <"\tMerge branch ${apos}left${apos}\n"> <"\n"> <"\t# By Another Author (3) and A U Thor (2)\n"> <"\t# Via Another Committer\n"> <"\t* left:\n"> <"\t Left #5\n"> <"\t Left #4\n"> <"\t Left #3\n"> <"\t Common #2\n"> <"\t Common #1\n"> <"\tEOF\n"> <"\n"> <"\tgit -c merge.log=5 fmt-merge-msg <.git/FETCH_HEAD >actual &&\n"> <"\ttest_cmp expected actual\n"> ) } ) (C {(test_expect_success)} {(SQ <"--log=5 with custom comment character">)} { (SQ <"\n"> <"\tcat >expected <<-EOF &&\n"> <"\tMerge branch ${apos}left${apos}\n"> <"\n"> <"\tx By Another Author (3) and A U Thor (2)\n"> <"\tx Via Another Committer\n"> <"\t* left:\n"> <"\t Left #5\n"> <"\t Left #4\n"> <"\t Left #3\n"> <"\t Common #2\n"> <"\t Common #1\n"> <"\tEOF\n"> <"\n"> <"\tgit -c core.commentchar=\"x\" fmt-merge-msg --log=5 <.git/FETCH_HEAD >actual &&\n"> <"\ttest_cmp expected actual\n"> ) } ) (C {(test_expect_success)} {(SQ <"merge.log=0 disables shortlog">)} { (SQ <"\n"> <"\techo \"Merge branch ${apos}left${apos}\" >expected &&\n"> <"\tgit -c merge.log=0 fmt-merge-msg <.git/FETCH_HEAD >actual &&\n"> <"\ttest_cmp expected actual\n"> ) } ) (C {(test_expect_success)} {(SQ <"--log=3 limits shortlog length">)} { (SQ <"\n"> <"\tcat >expected <<-EOF &&\n"> <"\tMerge branch ${apos}left${apos}\n"> <"\n"> <"\t# By Another Author (3) and A U Thor (2)\n"> <"\t# Via Another Committer\n"> <"\t* left: (5 commits)\n"> <"\t Left #5\n"> <"\t Left #4\n"> <"\t Left #3\n"> <"\t ...\n"> <"\tEOF\n"> <"\n"> <"\tgit fmt-merge-msg --log=3 <.git/FETCH_HEAD >actual &&\n"> <"\ttest_cmp expected actual\n"> ) } ) (C {(test_expect_success)} {(SQ <"--log=5 shows all 5 commits">)} { (SQ <"\n"> <"\tcat >expected <<-EOF &&\n"> <"\tMerge branch ${apos}left${apos}\n"> <"\n"> <"\t# By Another Author (3) and A U Thor (2)\n"> <"\t# Via Another Committer\n"> <"\t* left:\n"> <"\t Left #5\n"> <"\t Left #4\n"> <"\t Left #3\n"> <"\t Common #2\n"> <"\t Common #1\n"> <"\tEOF\n"> <"\n"> <"\tgit fmt-merge-msg --log=5 <.git/FETCH_HEAD >actual &&\n"> <"\ttest_cmp expected actual\n"> ) } ) (C {(test_expect_success)} {(SQ <"--no-log disables shortlog">)} { (SQ <"\n"> <"\techo \"Merge branch ${apos}left${apos}\" >expected &&\n"> <"\tgit fmt-merge-msg --no-log <.git/FETCH_HEAD >actual &&\n"> <"\ttest_cmp expected actual\n"> ) } ) (C {(test_expect_success)} {(SQ <"--log=0 disables shortlog">)} { (SQ <"\n"> <"\techo \"Merge branch ${apos}left${apos}\" >expected &&\n"> <"\tgit fmt-merge-msg --no-log <.git/FETCH_HEAD >actual &&\n"> <"\ttest_cmp expected actual\n"> ) } ) (C {(test_expect_success)} {(SQ <"fmt-merge-msg -m">)} { (SQ <"\n"> <"\techo \"Sync with left\" >expected &&\n"> <"\tcat >expected.log <<-EOF &&\n"> <"\tSync with left\n"> <"\n"> <"\t# By Another Author (3) and A U Thor (2)\n"> <"\t# Via Another Committer\n"> <"\t* ${apos}left${apos} of $(pwd):\n"> <"\t Left #5\n"> <"\t Left #4\n"> <"\t Left #3\n"> <"\t Common #2\n"> <"\t Common #1\n"> <"\tEOF\n"> <"\n"> <"\ttest_unconfig merge.log &&\n"> <"\ttest_unconfig merge.summary &&\n"> <"\tgit checkout master &&\n"> <"\tgit fetch \"$(pwd)\" left &&\n"> <"\tgit fmt-merge-msg -m \"Sync with left\" <.git/FETCH_HEAD >actual &&\n"> <"\tgit fmt-merge-msg --log -m \"Sync with left\" \\\n"> <"\t\t\t\t\t<.git/FETCH_HEAD >actual.log &&\n"> <"\ttest_config merge.log true &&\n"> <"\tgit fmt-merge-msg -m \"Sync with left\" \\\n"> <"\t\t\t\t\t<.git/FETCH_HEAD >actual.log-config &&\n"> <"\tgit fmt-merge-msg --no-log -m \"Sync with left\" \\\n"> <"\t\t\t\t\t<.git/FETCH_HEAD >actual.nolog &&\n"> <"\n"> <"\ttest_cmp expected actual &&\n"> <"\ttest_cmp expected.log actual.log &&\n"> <"\ttest_cmp expected.log actual.log-config &&\n"> <"\ttest_cmp expected actual.nolog\n"> ) } ) (C {(test_expect_success)} {(SQ <"setup: expected shortlog for two branches">)} { (SQ <"\n"> <"\tcat >expected <<-EOF\n"> <"\tMerge branches ${apos}left${apos} and ${apos}right${apos}\n"> <"\n"> <"\t# By Another Author (3) and A U Thor (2)\n"> <"\t# Via Another Committer\n"> <"\t* left:\n"> <"\t Left #5\n"> <"\t Left #4\n"> <"\t Left #3\n"> <"\t Common #2\n"> <"\t Common #1\n"> <"\n"> <"\t* right:\n"> <"\t Right #5\n"> <"\t Right #4\n"> <"\t Right #3\n"> <"\t Common #2\n"> <"\t Common #1\n"> <"\tEOF\n"> ) } ) (C {(test_expect_success)} {(SQ <"shortlog for two branches">)} { (SQ <"\n"> <"\ttest_config merge.log true &&\n"> <"\ttest_unconfig merge.summary &&\n"> <"\tgit checkout master &&\n"> <"\ttest_tick &&\n"> <"\tgit fetch . left right &&\n"> <"\tgit fmt-merge-msg <.git/FETCH_HEAD >actual1 &&\n"> <"\n"> <"\ttest_unconfig merge.log &&\n"> <"\ttest_config merge.summary true &&\n"> <"\tgit checkout master &&\n"> <"\ttest_tick &&\n"> <"\tgit fetch . left right &&\n"> <"\tgit fmt-merge-msg <.git/FETCH_HEAD >actual2 &&\n"> <"\n"> <"\ttest_config merge.log yes &&\n"> <"\ttest_unconfig merge.summary &&\n"> <"\tgit checkout master &&\n"> <"\ttest_tick &&\n"> <"\tgit fetch . left right &&\n"> <"\tgit fmt-merge-msg <.git/FETCH_HEAD >actual3 &&\n"> <"\n"> <"\ttest_unconfig merge.log &&\n"> <"\ttest_config merge.summary yes &&\n"> <"\tgit checkout master &&\n"> <"\ttest_tick &&\n"> <"\tgit fetch . left right &&\n"> <"\tgit fmt-merge-msg <.git/FETCH_HEAD >actual4 &&\n"> <"\n"> <"\ttest_cmp expected actual1 &&\n"> <"\ttest_cmp expected actual2 &&\n"> <"\ttest_cmp expected actual3 &&\n"> <"\ttest_cmp expected actual4\n"> ) } ) (C {(test_expect_success)} {(SQ <"merge-msg -F">)} { (SQ <"\n"> <"\ttest_unconfig merge.log &&\n"> <"\ttest_config merge.summary yes &&\n"> <"\tgit checkout master &&\n"> <"\ttest_tick &&\n"> <"\tgit fetch . left right &&\n"> <"\tgit fmt-merge-msg -F .git/FETCH_HEAD >actual &&\n"> <"\ttest_cmp expected actual\n"> ) } ) (C {(test_expect_success)} {(SQ <"merge-msg -F in subdirectory">)} { (SQ <"\n"> <"\ttest_unconfig merge.log &&\n"> <"\ttest_config merge.summary yes &&\n"> <"\tgit checkout master &&\n"> <"\ttest_tick &&\n"> <"\tgit fetch . left right &&\n"> <"\tmkdir sub &&\n"> <"\tcp .git/FETCH_HEAD sub/FETCH_HEAD &&\n"> <"\t(\n"> <"\t\tcd sub &&\n"> <"\t\tgit fmt-merge-msg -F FETCH_HEAD >../actual\n"> <"\t) &&\n"> <"\ttest_cmp expected actual\n"> ) } ) (C {(test_expect_success)} {(SQ <"merge-msg with nothing to merge">)} { (SQ <"\n"> <"\ttest_unconfig merge.log &&\n"> <"\ttest_config merge.summary yes &&\n"> <"\n"> <"\t>empty &&\n"> <"\n"> <"\t(\n"> <"\t\tcd remote &&\n"> <"\t\tgit checkout -b unrelated &&\n"> <"\t\ttest_tick &&\n"> <"\t\tgit fetch origin &&\n"> <"\t\tgit fmt-merge-msg <.git/FETCH_HEAD >../actual\n"> <"\t) &&\n"> <"\n"> <"\ttest_cmp empty actual\n"> ) } ) (C {(test_expect_success)} {(SQ <"merge-msg tag">)} { (SQ <"\n"> <"\tcat >expected <<-EOF &&\n"> <"\tMerge tag ${apos}tag-r3${apos}\n"> <"\n"> <"\t* tag ${apos}tag-r3${apos}:\n"> <"\t Right #3\n"> <"\t Common #2\n"> <"\t Common #1\n"> <"\tEOF\n"> <"\n"> <"\ttest_unconfig merge.log &&\n"> <"\ttest_config merge.summary yes &&\n"> <"\n"> <"\tgit checkout master &&\n"> <"\ttest_tick &&\n"> <"\tgit fetch . tag tag-r3 &&\n"> <"\n"> <"\tgit fmt-merge-msg <.git/FETCH_HEAD >actual &&\n"> <"\ttest_cmp expected actual\n"> ) } ) (C {(test_expect_success)} {(SQ <"merge-msg two tags">)} { (SQ <"\n"> <"\tcat >expected <<-EOF &&\n"> <"\tMerge tags ${apos}tag-r3${apos} and ${apos}tag-l5${apos}\n"> <"\n"> <"\t* tag ${apos}tag-r3${apos}:\n"> <"\t Right #3\n"> <"\t Common #2\n"> <"\t Common #1\n"> <"\n"> <"\t# By Another Author (3) and A U Thor (2)\n"> <"\t# Via Another Committer\n"> <"\t* tag ${apos}tag-l5${apos}:\n"> <"\t Left #5\n"> <"\t Left #4\n"> <"\t Left #3\n"> <"\t Common #2\n"> <"\t Common #1\n"> <"\tEOF\n"> <"\n"> <"\ttest_unconfig merge.log &&\n"> <"\ttest_config merge.summary yes &&\n"> <"\n"> <"\tgit checkout master &&\n"> <"\ttest_tick &&\n"> <"\tgit fetch . tag tag-r3 tag tag-l5 &&\n"> <"\n"> <"\tgit fmt-merge-msg <.git/FETCH_HEAD >actual &&\n"> <"\ttest_cmp expected actual\n"> ) } ) (C {(test_expect_success)} {(SQ <"merge-msg tag and branch">)} { (SQ <"\n"> <"\tcat >expected <<-EOF &&\n"> <"\tMerge branch ${apos}left${apos}, tag ${apos}tag-r3${apos}\n"> <"\n"> <"\t* tag ${apos}tag-r3${apos}:\n"> <"\t Right #3\n"> <"\t Common #2\n"> <"\t Common #1\n"> <"\n"> <"\t# By Another Author (3) and A U Thor (2)\n"> <"\t# Via Another Committer\n"> <"\t* left:\n"> <"\t Left #5\n"> <"\t Left #4\n"> <"\t Left #3\n"> <"\t Common #2\n"> <"\t Common #1\n"> <"\tEOF\n"> <"\n"> <"\ttest_unconfig merge.log &&\n"> <"\ttest_config merge.summary yes &&\n"> <"\n"> <"\tgit checkout master &&\n"> <"\ttest_tick &&\n"> <"\tgit fetch . tag tag-r3 left &&\n"> <"\n"> <"\tgit fmt-merge-msg <.git/FETCH_HEAD >actual &&\n"> <"\ttest_cmp expected actual\n"> ) } ) (C {(test_expect_success)} {(SQ <"merge-msg lots of commits">)} { (SQ <"\n"> <"\t{\n"> <"\t\tcat <<-EOF &&\n"> <"\t\tMerge branch ${apos}long${apos}\n"> <"\n"> <"\t\t* long: (35 commits)\n"> <"\t\tEOF\n"> <"\n"> <"\t\ti=29 &&\n"> <"\t\twhile test $i -gt 9\n"> <"\t\tdo\n"> <"\t\t\techo \" $i\" &&\n"> <"\t\t\ti=$(($i-1))\n"> <"\t\tdone &&\n"> <"\t\techo \" ...\"\n"> <"\t} >expected &&\n"> <"\n"> <"\ttest_config merge.summary yes &&\n"> <"\n"> <"\tgit checkout master &&\n"> <"\ttest_tick &&\n"> <"\tgit fetch . long &&\n"> <"\n"> <"\tgit fmt-merge-msg <.git/FETCH_HEAD >actual &&\n"> <"\ttest_cmp expected actual\n"> ) } ) (C {(test_expect_success)} {(SQ <"merge-msg with \"merging\" an annotated tag">)} { (SQ <"\n"> <"\ttest_config merge.log true &&\n"> <"\n"> <"\tgit checkout master^0 &&\n"> <"\tgit commit --allow-empty -m \"One step ahead\" &&\n"> <"\tgit tag -a -m \"An annotated one\" annote HEAD &&\n"> <"\n"> <"\tgit checkout master &&\n"> <"\tgit fetch . annote &&\n"> <"\n"> <"\tgit fmt-merge-msg <.git/FETCH_HEAD >actual &&\n"> <"\t{\n"> <"\t\tcat <<-\\EOF\n"> <"\t\tMerge tag "> ) (EscapedLiteralPart token:) (SQ ) (EscapedLiteralPart token:) (SQ <"\n"> <"\n"> <"\t\tAn annotated one\n"> <"\n"> <"\t\t* tag ">) (EscapedLiteralPart token:) (SQ ) (EscapedLiteralPart token:) (SQ <":\n"> <"\t\t One step ahead\n"> <"\t\tEOF\n"> <"\t} >expected &&\n"> <"\ttest_cmp expected actual &&\n"> <"\n"> <"\ttest_when_finished \"git reset --hard\" &&\n"> <"\tannote=$(git rev-parse annote) &&\n"> <"\tgit merge --no-commit $annote &&\n"> <"\t{\n"> <"\t\tcat <<-EOF\n"> <"\t\tMerge tag "> ) (EscapedLiteralPart token:) (SQ <"$annote">) (EscapedLiteralPart token:) (SQ <"\n"> <"\n"> <"\t\tAn annotated one\n"> <"\n"> <"\t\t* tag ">) (EscapedLiteralPart token:) (SQ <"$annote">) (EscapedLiteralPart token:) (SQ <":\n"> <"\t\t One step ahead\n"> <"\t\tEOF\n"> <"\t} >expected &&\n"> <"\ttest_cmp expected .git/MERGE_MSG\n"> ) } ) (C {(test_done)}) ] )