#!/bin/sh global test_description := ''git merge Testing merge when using a custom message for the merge commit.'' source ./test-lib.sh proc create_merge_msgs { echo >exp.subject "custom message>exp.subject "custom message" cp exp.subject exp.log && echo >>exp.log "" && echo >>exp.log "* tag 'c2':>>exp.log "* tag 'c2':" && echo >>exp.log " c2>>exp.log " c2" } test_expect_success 'setup' ' echo c0 > c0.c && git add c0.c && git commit -m c0 && git tag c0 && echo c1 > c1.c && git add c1.c && git commit -m c1 && git tag c1 && git reset --hard c0 && echo c2 > c2.c && git add c2.c && git commit -m c2 && git tag c2 && create_merge_msgs ' test_expect_success 'merge c2 with a custom message' ' git reset --hard c1 && git merge -m "$(cat exp.subject)" c2 && git cat-file commit HEAD | sed -e "1,/^$/d" >actual && test_cmp exp.subject actual ' test_expect_success 'merge --log appends to custom message' ' git reset --hard c1 && git merge --log -m "$(cat exp.subject)" c2 && git cat-file commit HEAD | sed -e "1,/^$/d" >actual && test_cmp exp.log actual ' test_done (CommandList children: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:test_description) op: Equal rhs: { (SQ <"git merge\n"> <"\n"> <"Testing merge when using a custom message for the merge commit."> ) } spids: [4] ) ] spids: [4] ) (C {(.)} {(./test-lib.sh)}) (FuncDef name: create_merge_msgs body: (BraceGroup children: [ (SimpleCommand words: [{(echo)} {(DQ ("custom message"))}] redirects: [(Redir op_id:Redir_Great fd:-1 arg_word:{(exp.subject)} spids:[26])] ) (AndOr children: [ (C {(cp)} {(exp.subject)} {(exp.log)}) (AndOr children: [ (SimpleCommand words: [{(echo)} {(DQ )}] redirects: [(Redir op_id:Redir_DGreat fd:-1 arg_word:{(exp.log)} spids:[46])] ) (AndOr children: [ (SimpleCommand words: [{(echo)} {(DQ ("* tag 'c2':"))}] redirects: [ (Redir op_id: Redir_DGreat fd: -1 arg_word: {(exp.log)} spids: [57] ) ] ) (SimpleCommand words: [{(echo)} {(DQ (" c2"))}] redirects: [ (Redir op_id: Redir_DGreat fd: -1 arg_word: {(exp.log)} spids: [69] ) ] ) ] op_id: Op_DAmp ) ] op_id: Op_DAmp ) ] op_id: Op_DAmp ) ] spids: [21] ) spids: [17 20] ) (C {(test_expect_success)} {(SQ )} { (SQ <"\n"> <"\techo c0 > c0.c &&\n"> <"\tgit add c0.c &&\n"> <"\tgit commit -m c0 &&\n"> <"\tgit tag c0 &&\n"> <"\techo c1 > c1.c &&\n"> <"\tgit add c1.c &&\n"> <"\tgit commit -m c1 &&\n"> <"\tgit tag c1 &&\n"> <"\tgit reset --hard c0 &&\n"> <"\techo c2 > c2.c &&\n"> <"\tgit add c2.c &&\n"> <"\tgit commit -m c2 &&\n"> <"\tgit tag c2 &&\n"> <"\tcreate_merge_msgs\n"> ) } ) (C {(test_expect_success)} {(SQ <"merge c2 with a custom message">)} { (SQ <"\n"> <"\tgit reset --hard c1 &&\n"> <"\tgit merge -m \"$(cat exp.subject)\" c2 &&\n"> <"\tgit cat-file commit HEAD | sed -e \"1,/^$/d\" >actual &&\n"> <"\ttest_cmp exp.subject actual\n"> ) } ) (C {(test_expect_success)} {(SQ <"merge --log appends to custom message">)} { (SQ <"\n"> <"\tgit reset --hard c1 &&\n"> <"\tgit merge --log -m \"$(cat exp.subject)\" c2 &&\n"> <"\tgit cat-file commit HEAD | sed -e \"1,/^$/d\" >actual &&\n"> <"\ttest_cmp exp.log actual\n"> ) } ) (C {(test_done)}) ] )