#!/bin/sh global test_description := ''test subject preservation with format-patch | am'' source ./test-lib.sh proc make_patches { global type := $1 global subject := $2 test_expect_success "create patches with $type subject" ' git reset --hard baseline && echo $type >file && git commit -a -m "$subject" && git format-patch -1 --stdout >$type.patch && git format-patch -1 --stdout -k >$type-k.patch ' } proc check_subject { git reset --hard baseline && git am $2 $1.patch && git log -1 --pretty=format:%B >actual && test_cmp expect actual } test_expect_success 'setup baseline commit' ' test_commit baseline file ' global SHORT_SUBJECT := ''short subject'' make_patches short $SHORT_SUBJECT global LONG_SUBJECT1 := ''this is a long subject that is virtually guaranteed'' global LONG_SUBJECT2 := ''to require wrapping via format-patch if it is all'' global LONG_SUBJECT3 := ''going to appear on a single line'' global LONG_SUBJECT := ""$LONG_SUBJECT1 $LONG_SUBJECT2 $LONG_SUBJECT3"" make_patches long $LONG_SUBJECT global MULTILINE_SUBJECT := ""$LONG_SUBJECT1 $LONG_SUBJECT2 $LONG_SUBJECT3"" make_patches multiline $MULTILINE_SUBJECT echo $SHORT_SUBJECT >expect test_expect_success 'short subject preserved (format-patch | am)' ' check_subject short ' test_expect_success 'short subject preserved (format-patch -k | am)' ' check_subject short-k ' test_expect_success 'short subject preserved (format-patch -k | am -k)' ' check_subject short-k -k ' echo $LONG_SUBJECT >expect test_expect_success 'long subject preserved (format-patch | am)' ' check_subject long ' test_expect_success 'long subject preserved (format-patch -k | am)' ' check_subject long-k ' test_expect_success 'long subject preserved (format-patch -k | am -k)' ' check_subject long-k -k ' echo $LONG_SUBJECT >expect test_expect_success 'multiline subject unwrapped (format-patch | am)' ' check_subject multiline ' test_expect_success 'multiline subject unwrapped (format-patch -k | am)' ' check_subject multiline-k ' echo $MULTILINE_SUBJECT >expect test_expect_success 'multiline subject preserved (format-patch -k | am -k)' ' check_subject multiline-k -k ' test_done (CommandList children: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:test_description) op: Equal rhs: {(SQ <"test subject preservation with format-patch | am">)} spids: [4] ) ] spids: [4] ) (C {(.)} {(./test-lib.sh)}) (FuncDef name: make_patches body: (BraceGroup children: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:type) op: Equal rhs: {($ VSub_Number "$1")} spids: [21] ) ] spids: [21] ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:subject) op: Equal rhs: {($ VSub_Number "$2")} spids: [25] ) ] spids: [25] ) (C {(test_expect_success)} {(DQ ("create patches with ") ($ VSub_Name "$type") (" subject"))} { (SQ <"\n"> <"\t\tgit reset --hard baseline &&\n"> <"\t\techo $type >file &&\n"> <"\t\tgit commit -a -m \"$subject\" &&\n"> <"\t\tgit format-patch -1 --stdout >$type.patch &&\n"> <"\t\tgit format-patch -1 --stdout -k >$type-k.patch\n"> <"\t"> ) } ) ] spids: [18] ) spids: [14 17] ) (FuncDef name: check_subject body: (BraceGroup children: [ (AndOr children: [ (C {(git)} {(reset)} {(--hard)} {(baseline)}) (AndOr children: [ (C {(git)} {(am)} {($ VSub_Number "$2")} {($ VSub_Number "$1") (.patch)}) (AndOr children: [ (SimpleCommand words: [ {(git)} {(log)} {(-1)} {(--pretty) (Lit_Other "=") (format) (Lit_Other ":") (Lit_Other "%") (B)} ] redirects: [(Redir op_id:Redir_Great fd:-1 arg_word:{(actual)} spids:[93])] ) (C {(test_cmp)} {(expect)} {(actual)}) ] op_id: Op_DAmp ) ] op_id: Op_DAmp ) ] op_id: Op_DAmp ) ] spids: [54] ) spids: [50 53] ) (C {(test_expect_success)} {(SQ <"setup baseline commit">)} {(SQ <"\n"> <"\ttest_commit baseline file\n">)} ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:SHORT_SUBJECT) op: Equal rhs: {(SQ <"short subject">)} spids: [120] ) ] spids: [120] ) (C {(make_patches)} {(short)} {(DQ ($ VSub_Name "$SHORT_SUBJECT"))}) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:LONG_SUBJECT1) op: Equal rhs: {(SQ <"this is a long subject that is virtually guaranteed">)} spids: [134] ) ] spids: [134] ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:LONG_SUBJECT2) op: Equal rhs: {(SQ <"to require wrapping via format-patch if it is all">)} spids: [139] ) ] spids: [139] ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:LONG_SUBJECT3) op: Equal rhs: {(SQ <"going to appear on a single line">)} spids: [144] ) ] spids: [144] ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:LONG_SUBJECT) op: Equal rhs: { (DQ ($ VSub_Name "$LONG_SUBJECT1") (" ") ($ VSub_Name "$LONG_SUBJECT2") (" ") ($ VSub_Name "$LONG_SUBJECT3") ) } spids: [149] ) ] spids: [149] ) (C {(make_patches)} {(long)} {(DQ ($ VSub_Name "$LONG_SUBJECT"))}) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:MULTILINE_SUBJECT) op: Equal rhs: { (DQ ($ VSub_Name "$LONG_SUBJECT1") ("\n") ($ VSub_Name "$LONG_SUBJECT2") ("\n") ($ VSub_Name "$LONG_SUBJECT3") ) } spids: [167] ) ] spids: [167] ) (C {(make_patches)} {(multiline)} {(DQ ($ VSub_Name "$MULTILINE_SUBJECT"))}) (SimpleCommand words: [{(echo)} {(DQ ($ VSub_Name "$SHORT_SUBJECT"))}] redirects: [(Redir op_id:Redir_Great fd:-1 arg_word:{(expect)} spids:[191])] ) (C {(test_expect_success)} {(SQ <"short subject preserved (format-patch | am)">)} {(SQ <"\n"> <"\tcheck_subject short\n">)} ) (C {(test_expect_success)} {(SQ <"short subject preserved (format-patch -k | am)">)} {(SQ <"\n"> <"\tcheck_subject short-k\n">)} ) (C {(test_expect_success)} {(SQ <"short subject preserved (format-patch -k | am -k)">)} {(SQ <"\n"> <"\tcheck_subject short-k -k\n">)} ) (SimpleCommand words: [{(echo)} {(DQ ($ VSub_Name "$LONG_SUBJECT"))}] redirects: [(Redir op_id:Redir_Great fd:-1 arg_word:{(expect)} spids:[234])] ) (C {(test_expect_success)} {(SQ <"long subject preserved (format-patch | am)">)} {(SQ <"\n"> <"\tcheck_subject long\n">)} ) (C {(test_expect_success)} {(SQ <"long subject preserved (format-patch -k | am)">)} {(SQ <"\n"> <"\tcheck_subject long-k\n">)} ) (C {(test_expect_success)} {(SQ <"long subject preserved (format-patch -k | am -k)">)} {(SQ <"\n"> <"\tcheck_subject long-k -k\n">)} ) (SimpleCommand words: [{(echo)} {(DQ ($ VSub_Name "$LONG_SUBJECT"))}] redirects: [(Redir op_id:Redir_Great fd:-1 arg_word:{(expect)} spids:[277])] ) (C {(test_expect_success)} {(SQ <"multiline subject unwrapped (format-patch | am)">)} {(SQ <"\n"> <"\tcheck_subject multiline\n">)} ) (C {(test_expect_success)} {(SQ <"multiline subject unwrapped (format-patch -k | am)">)} {(SQ <"\n"> <"\tcheck_subject multiline-k\n">)} ) (SimpleCommand words: [{(echo)} {(DQ ($ VSub_Name "$MULTILINE_SUBJECT"))}] redirects: [(Redir op_id:Redir_Great fd:-1 arg_word:{(expect)} spids:[308])] ) (C {(test_expect_success)} {(SQ <"multiline subject preserved (format-patch -k | am -k)">)} {(SQ <"\n"> <"\tcheck_subject multiline-k -k\n">)} ) (C {(test_done)}) ] )