(List (= scope=<EAssignScope.GLOBAL 1> flags=0 words=[] bindings=[('test_description', {[SQ <LIT_CHARS "git commit">]})]) (Com {[LIT_CHARS .]} {[LIT_CHARS ./test-lib.sh]} ) (Com {[LIT_CHARS .]} {[DQ [VarSub TEST_DIRECTORY][LIT_CHARS /diff-lib.sh]]} ) (= scope=<EAssignScope.GLOBAL 1> flags=0 words=[] bindings=[('author', {[SQ <LIT_CHARS "The Real Author <someguy@his.email.org>">]})]) (Com {[LIT_CHARS test_tick]} ) (Com {[LIT_CHARS test_expect_success]} {[SQ <LIT_CHARS "initial status">]} {[SQ <LIT_CHARS "\n"> <LIT_CHARS "\techo bongo bongo >file &&\n"> <LIT_CHARS "\tgit add file &&\n"> <LIT_CHARS "\tgit status >actual &&\n"> <LIT_CHARS "\ttest_i18ngrep \"Initial commit\" actual\n">]} ) (Com {[LIT_CHARS test_expect_success]} {[SQ <LIT_CHARS "fail initial amend">]} {[SQ <LIT_CHARS "\n"> <LIT_CHARS "\ttest_must_fail git commit --amend\n">]} ) (Com {[LIT_CHARS test_expect_success]} {[SQ <LIT_CHARS "setup: initial commit">]} {[SQ <LIT_CHARS "\n"> <LIT_CHARS "\tgit commit -m initial\n">]} ) (Com {[LIT_CHARS test_expect_success]} {[SQ <LIT_CHARS "-m and -F do not mix">]} {[SQ <LIT_CHARS "\n"> <LIT_CHARS "\tgit checkout HEAD file && echo >>file && git add file &&\n"> <LIT_CHARS "\ttest_must_fail git commit -m foo -m bar -F file\n">]} ) (Com {[LIT_CHARS test_expect_success]} {[SQ <LIT_CHARS "-m and -C do not mix">]} {[SQ <LIT_CHARS "\n"> <LIT_CHARS "\tgit checkout HEAD file && echo >>file && git add file &&\n"> <LIT_CHARS "\ttest_must_fail git commit -C HEAD -m illegal\n">]} ) (Com {[LIT_CHARS test_expect_success]} {[SQ <LIT_CHARS "paths and -a do not mix">]} {[SQ <LIT_CHARS "\n"> <LIT_CHARS "\techo King of the bongo >file &&\n"> <LIT_CHARS "\ttest_must_fail git commit -m foo -a file\n">]} ) (Com {[LIT_CHARS test_expect_success]} {[LIT_CHARS PERL]} {[SQ <LIT_CHARS "can use paths with --interactive">]} {[SQ <LIT_CHARS "\n"> <LIT_CHARS "\techo bong-o-bong >file &&\n"> <LIT_CHARS "\t# 2: update, 1:st path, that is all, 7: quit\n"> <LIT_CHARS "\t( echo 2; echo 1; echo; echo 7 ) |\n"> <LIT_CHARS "\tgit commit -m foo --interactive file &&\n"> <LIT_CHARS "\tgit reset --hard HEAD^\n">]} ) (Com {[LIT_CHARS test_expect_success]} {[SQ <LIT_CHARS "using invalid commit with -C">]} {[SQ <LIT_CHARS "\n"> <LIT_CHARS "\ttest_must_fail git commit -C bogus\n">]} ) (Com {[LIT_CHARS test_expect_success]} {[SQ <LIT_CHARS "nothing to commit">]} {[SQ <LIT_CHARS "\n"> <LIT_CHARS "\ttest_must_fail git commit -m initial\n">]} ) (Com {[LIT_CHARS test_expect_success]} {[SQ <LIT_CHARS "setup: non-initial commit">]} {[SQ <LIT_CHARS "\n"> <LIT_CHARS "\techo bongo bongo bongo >file &&\n"> <LIT_CHARS "\tgit commit -m next -a\n">]} ) (Com {[LIT_CHARS test_expect_success]} {[SQ <LIT_CHARS "commit message from non-existing file">]} {[SQ <LIT_CHARS "\n"> <LIT_CHARS "\techo more bongo: bongo bongo bongo bongo >file &&\n"> <LIT_CHARS "\ttest_must_fail git commit -F gah -a\n">]} ) (Com {[LIT_CHARS test_expect_success]} {[SQ <LIT_CHARS "empty commit message">]} {[SQ <LIT_CHARS "\n"> <LIT_CHARS "\t# Empty except stray tabs and spaces on a few lines.\n"> <LIT_CHARS "\tsed -e \"s/@//g\" >msg <<-\\EOF &&\n"> <LIT_CHARS "\t\t@\t\t@\n"> <LIT_CHARS "\t\t@@\n"> <LIT_CHARS "\t\t@ @\n"> <LIT_CHARS "\t\t@Signed-off-by: hula@\n"> <LIT_CHARS "\tEOF\n"> <LIT_CHARS "\ttest_must_fail git commit -F msg -a\n">]} ) (Com {[LIT_CHARS test_expect_success]} {[SQ <LIT_CHARS "template \"emptyness\" check does not kick in with -F">]} {[SQ <LIT_CHARS "\n"> <LIT_CHARS "\tgit checkout HEAD file && echo >>file && git add file &&\n"> <LIT_CHARS "\tgit commit -t file -F file\n">]} ) (Com {[LIT_CHARS test_expect_success]} {[SQ <LIT_CHARS "template \"emptyness\" check">]} {[SQ <LIT_CHARS "\n"> <LIT_CHARS "\tgit checkout HEAD file && echo >>file && git add file &&\n"> <LIT_CHARS "\ttest_must_fail git commit -t file 2>err &&\n"> <LIT_CHARS "\ttest_i18ngrep \"did not edit\" err\n">]} ) (Com {[LIT_CHARS test_expect_success]} {[SQ <LIT_CHARS "setup: commit message from file">]} {[SQ <LIT_CHARS "\n"> <LIT_CHARS "\tgit checkout HEAD file && echo >>file && git add file &&\n"> <LIT_CHARS "\techo this is the commit message, coming from a file >msg &&\n"> <LIT_CHARS "\tgit commit -F msg -a\n">]} ) (Com {[LIT_CHARS test_expect_success]} {[SQ <LIT_CHARS "amend commit">]} {[SQ <LIT_CHARS "\n"> <LIT_CHARS "\tcat >editor <<-\\EOF &&\n"> <LIT_CHARS "\t#!/bin/sh\n"> <LIT_CHARS "\tsed -e \"s/a file/an amend commit/g\" < \"$1\" > \"$1-\"\n"> <LIT_CHARS "\tmv \"$1-\" \"$1\"\n"> <LIT_CHARS "\tEOF\n"> <LIT_CHARS "\tchmod 755 editor &&\n"> <LIT_CHARS "\tEDITOR=./editor git commit --amend\n">]} ) (Com {[LIT_CHARS test_expect_success]} {[SQ <LIT_CHARS "amend --only ignores staged contents">]} {[SQ <LIT_CHARS "\n"> <LIT_CHARS "\tcp file file.expect &&\n"> <LIT_CHARS "\techo changed >file &&\n"> <LIT_CHARS "\tgit add file &&\n"> <LIT_CHARS "\tgit commit --no-edit --amend --only &&\n"> <LIT_CHARS "\tgit cat-file blob HEAD:file >file.actual &&\n"> <LIT_CHARS "\ttest_cmp file.expect file.actual &&\n"> <LIT_CHARS "\tgit diff --exit-code\n">]} ) (Com {[LIT_CHARS test_expect_success]} {[SQ <LIT_CHARS "set up editor">]} {[SQ <LIT_CHARS "\n"> <LIT_CHARS "\tcat >editor <<-\\EOF &&\n"> <LIT_CHARS "\t#!/bin/sh\n"> <LIT_CHARS "\tsed -e \"s/unamended/amended/g\" <\"$1\" >\"$1-\"\n"> <LIT_CHARS "\tmv \"$1-\" \"$1\"\n"> <LIT_CHARS "\tEOF\n"> <LIT_CHARS "\tchmod 755 editor\n">]} ) (Com {[LIT_CHARS test_expect_success]} {[SQ <LIT_CHARS "amend without launching editor">]} {[SQ <LIT_CHARS "\n"> <LIT_CHARS "\techo unamended >expect &&\n"> <LIT_CHARS "\tgit commit --allow-empty -m \"unamended\" &&\n"> <LIT_CHARS "\techo needs more bongo >file &&\n"> <LIT_CHARS "\tgit add file &&\n"> <LIT_CHARS "\tEDITOR=./editor git commit --no-edit --amend &&\n"> <LIT_CHARS "\tgit diff --exit-code HEAD -- file &&\n"> <LIT_CHARS "\tgit diff-tree -s --format=%s HEAD >msg &&\n"> <LIT_CHARS "\ttest_cmp expect msg\n">]} ) (Com {[LIT_CHARS test_expect_success]} {[SQ <LIT_CHARS "--amend --edit">]} {[SQ <LIT_CHARS "\n"> <LIT_CHARS "\techo amended >expect &&\n"> <LIT_CHARS "\tgit commit --allow-empty -m \"unamended\" &&\n"> <LIT_CHARS "\techo bongo again >file &&\n"> <LIT_CHARS "\tgit add file &&\n"> <LIT_CHARS "\tEDITOR=./editor git commit --edit --amend &&\n"> <LIT_CHARS "\tgit diff-tree -s --format=%s HEAD >msg &&\n"> <LIT_CHARS "\ttest_cmp expect msg\n">]} ) (Com {[LIT_CHARS test_expect_success]} {[SQ <LIT_CHARS "--amend --edit of empty message">]} {[SQ <LIT_CHARS "\n"> <LIT_CHARS "\tcat >replace <<-\\EOF &&\n"> <LIT_CHARS "\t#!/bin/sh\n"> <LIT_CHARS "\techo \"amended\" >\"$1\"\n"> <LIT_CHARS "\tEOF\n"> <LIT_CHARS "\tchmod 755 replace &&\n"> <LIT_CHARS "\tgit commit --allow-empty --allow-empty-message -m \"\" &&\n"> <LIT_CHARS "\techo more bongo >file &&\n"> <LIT_CHARS "\tgit add file &&\n"> <LIT_CHARS "\tEDITOR=./replace git commit --edit --amend &&\n"> <LIT_CHARS "\tgit diff-tree -s --format=%s HEAD >msg &&\n"> <LIT_CHARS "\t./replace expect &&\n"> <LIT_CHARS "\ttest_cmp expect msg\n">]} ) (Com {[LIT_CHARS test_expect_success]} {[SQ <LIT_CHARS "-m --edit">]} {[SQ <LIT_CHARS "\n"> <LIT_CHARS "\techo amended >expect &&\n"> <LIT_CHARS "\tgit commit --allow-empty -m buffer &&\n"> <LIT_CHARS "\techo bongo bongo >file &&\n"> <LIT_CHARS "\tgit add file &&\n"> <LIT_CHARS "\tEDITOR=./editor git commit -m unamended --edit &&\n"> <LIT_CHARS "\tgit diff-tree -s --format=%s HEAD >msg &&\n"> <LIT_CHARS "\ttest_cmp expect msg\n">]} ) (Com {[LIT_CHARS test_expect_success]} {[SQ <LIT_CHARS "-m and -F do not mix">]} {[SQ <LIT_CHARS "\n"> <LIT_CHARS "\techo enough with the bongos >file &&\n"> <LIT_CHARS "\ttest_must_fail git commit -F msg -m amending .\n">]} ) (Com {[LIT_CHARS test_expect_success]} {[SQ <LIT_CHARS "using message from other commit">]} {[SQ <LIT_CHARS "\n"> <LIT_CHARS "\tgit commit -C HEAD^ .\n">]} ) (Com {[LIT_CHARS test_expect_success]} {[SQ <LIT_CHARS "editing message from other commit">]} {[SQ <LIT_CHARS "\n"> <LIT_CHARS "\tcat >editor <<-\\EOF &&\n"> <LIT_CHARS "\t#!/bin/sh\n"> <LIT_CHARS "\tsed -e \"s/amend/older/g\" < \"$1\" > \"$1-\"\n"> <LIT_CHARS "\tmv \"$1-\" \"$1\"\n"> <LIT_CHARS "\tEOF\n"> <LIT_CHARS "\tchmod 755 editor &&\n"> <LIT_CHARS "\techo hula hula >file &&\n"> <LIT_CHARS "\tEDITOR=./editor git commit -c HEAD^ -a\n">]} ) (Com {[LIT_CHARS test_expect_success]} {[SQ <LIT_CHARS "message from stdin">]} {[SQ <LIT_CHARS "\n"> <LIT_CHARS "\techo silly new contents >file &&\n"> <LIT_CHARS "\techo commit message from stdin |\n"> <LIT_CHARS "\tgit commit -F - -a\n">]} ) (Com {[LIT_CHARS test_expect_success]} {[SQ <LIT_CHARS "overriding author from command line">]} {[SQ <LIT_CHARS "\n"> <LIT_CHARS "\techo gak >file &&\n"> <LIT_CHARS "\tgit commit -m author \\\n"> <LIT_CHARS "\t\t--author \"Rubber Duck <rduck@convoy.org>\" -a >output 2>&1 &&\n"> <LIT_CHARS "\tgrep Rubber.Duck output\n">]} ) (Com {[LIT_CHARS test_expect_success]} {[LIT_CHARS PERL]} {[SQ <LIT_CHARS "interactive add">]} {[SQ <LIT_CHARS "\n"> <LIT_CHARS "\techo 7 |\n"> <LIT_CHARS "\tgit commit --interactive |\n"> <LIT_CHARS "\tgrep \"What now\"\n">]} ) (Com {[LIT_CHARS test_expect_success]} {[LIT_CHARS PERL]} {[DQ [LIT_CHARS "commit --interactive doesn't change index if editor aborts"]]} {[SQ <LIT_CHARS "\n"> <LIT_CHARS "\techo zoo >file &&\n"> <LIT_CHARS "\ttest_must_fail git diff --exit-code >diff1 &&\n"> <LIT_CHARS "\t(echo u ; echo \"*\" ; echo q) |\n"> <LIT_CHARS "\t(\n"> <LIT_CHARS "\t\tEDITOR=: &&\n"> <LIT_CHARS "\t\texport EDITOR &&\n"> <LIT_CHARS "\t\ttest_must_fail git commit --interactive\n"> <LIT_CHARS "\t) &&\n"> <LIT_CHARS "\tgit diff >diff2 &&\n"> <LIT_CHARS "\tcompare_diff_patch diff1 diff2\n">]} ) (Com {[LIT_CHARS test_expect_success]} {[SQ <LIT_CHARS "editor not invoked if -F is given">]} {[SQ <LIT_CHARS "\n"> <LIT_CHARS "\tcat >editor <<-\\EOF &&\n"> <LIT_CHARS "\t#!/bin/sh\n"> <LIT_CHARS "\tsed -e s/good/bad/g <\"$1\" >\"$1-\"\n"> <LIT_CHARS "\tmv \"$1-\" \"$1\"\n"> <LIT_CHARS "\tEOF\n"> <LIT_CHARS "\tchmod 755 editor &&\n"> <LIT_CHARS "\n"> <LIT_CHARS "\techo A good commit message. >msg &&\n"> <LIT_CHARS "\techo moo >file &&\n"> <LIT_CHARS "\n"> <LIT_CHARS "\tEDITOR=./editor git commit -a -F msg &&\n"> <LIT_CHARS "\tgit show -s --pretty=format:%s >subject &&\n"> <LIT_CHARS "\tgrep -q good subject &&\n"> <LIT_CHARS "\n"> <LIT_CHARS "\techo quack >file &&\n"> <LIT_CHARS "\techo Another good message. |\n"> <LIT_CHARS "\tEDITOR=./editor git commit -a -F - &&\n"> <LIT_CHARS "\tgit show -s --pretty=format:%s >subject &&\n"> <LIT_CHARS "\tgrep -q good subject\n">]} ) (Com {[LIT_CHARS test_expect_success]} {[SQ <LIT_CHARS "partial commit that involves removal (1)">]} {[SQ <LIT_CHARS "\n"> <LIT_CHARS "\n"> <LIT_CHARS "\tgit rm --cached file &&\n"> <LIT_CHARS "\tmv file elif &&\n"> <LIT_CHARS "\tgit add elif &&\n"> <LIT_CHARS "\tgit commit -m \"Partial: add elif\" elif &&\n"> <LIT_CHARS "\tgit diff-tree --name-status HEAD^ HEAD >current &&\n"> <LIT_CHARS "\techo \"A\telif\" >expected &&\n"> <LIT_CHARS "\ttest_cmp expected current\n"> <LIT_CHARS "\n">]} ) (Com {[LIT_CHARS test_expect_success]} {[SQ <LIT_CHARS "partial commit that involves removal (2)">]} {[SQ <LIT_CHARS "\n"> <LIT_CHARS "\n"> <LIT_CHARS "\tgit commit -m \"Partial: remove file\" file &&\n"> <LIT_CHARS "\tgit diff-tree --name-status HEAD^ HEAD >current &&\n"> <LIT_CHARS "\techo \"D\tfile\" >expected &&\n"> <LIT_CHARS "\ttest_cmp expected current\n"> <LIT_CHARS "\n">]} ) (Com {[LIT_CHARS test_expect_success]} {[SQ <LIT_CHARS "partial commit that involves removal (3)">]} {[SQ <LIT_CHARS "\n"> <LIT_CHARS "\n"> <LIT_CHARS "\tgit rm --cached elif &&\n"> <LIT_CHARS "\techo elif >elif &&\n"> <LIT_CHARS "\tgit commit -m \"Partial: modify elif\" elif &&\n"> <LIT_CHARS "\tgit diff-tree --name-status HEAD^ HEAD >current &&\n"> <LIT_CHARS "\techo \"M\telif\" >expected &&\n"> <LIT_CHARS "\ttest_cmp expected current\n"> <LIT_CHARS "\n">]} ) (Com {[LIT_CHARS test_expect_success]} {[SQ <LIT_CHARS "amend commit to fix author">]} {[SQ <LIT_CHARS "\n"> <LIT_CHARS "\n"> <LIT_CHARS "\toldtick=$GIT_AUTHOR_DATE &&\n"> <LIT_CHARS "\ttest_tick &&\n"> <LIT_CHARS "\tgit reset --hard &&\n"> <LIT_CHARS "\tgit cat-file -p HEAD |\n"> <LIT_CHARS "\tsed -e \"s/author.*/author $author $oldtick/\" \\\n"> <LIT_CHARS "\t\t-e \"s/^\\(committer.*> \\).*$/\\1$GIT_COMMITTER_DATE/\" > \\\n"> <LIT_CHARS "\t\texpected &&\n"> <LIT_CHARS "\tgit commit --amend --author=\"$author\" &&\n"> <LIT_CHARS "\tgit cat-file -p HEAD > current &&\n"> <LIT_CHARS "\ttest_cmp expected current\n"> <LIT_CHARS "\n">]} ) (Com {[LIT_CHARS test_expect_success]} {[SQ <LIT_CHARS "amend commit to fix date">]} {[SQ <LIT_CHARS "\n"> <LIT_CHARS "\n"> <LIT_CHARS "\ttest_tick &&\n"> <LIT_CHARS "\tnewtick=$GIT_AUTHOR_DATE &&\n"> <LIT_CHARS "\tgit reset --hard &&\n"> <LIT_CHARS "\tgit cat-file -p HEAD |\n"> <LIT_CHARS "\tsed -e \"s/author.*/author $author $newtick/\" \\\n"> <LIT_CHARS "\t\t-e \"s/^\\(committer.*> \\).*$/\\1$GIT_COMMITTER_DATE/\" > \\\n"> <LIT_CHARS "\t\texpected &&\n"> <LIT_CHARS "\tgit commit --amend --date=\"$newtick\" &&\n"> <LIT_CHARS "\tgit cat-file -p HEAD > current &&\n"> <LIT_CHARS "\ttest_cmp expected current\n"> <LIT_CHARS "\n">]} ) (Com {[LIT_CHARS test_expect_success]} {[SQ <LIT_CHARS "commit complains about bogus date">]} {[SQ <LIT_CHARS "\n"> <LIT_CHARS "\ttest_must_fail git commit --amend --date=10.11.2010\n">]} ) (Com {[LIT_CHARS test_expect_success]} {[SQ <LIT_CHARS "sign off (1)">]} {[SQ <LIT_CHARS "\n"> <LIT_CHARS "\n"> <LIT_CHARS "\techo 1 >positive &&\n"> <LIT_CHARS "\tgit add positive &&\n"> <LIT_CHARS "\tgit commit -s -m \"thank you\" &&\n"> <LIT_CHARS "\tgit cat-file commit HEAD | sed -e \"1,/^\\$/d\" >actual &&\n"> <LIT_CHARS "\t(\n"> <LIT_CHARS "\t\techo thank you\n"> <LIT_CHARS "\t\techo\n"> <LIT_CHARS "\t\tgit var GIT_COMMITTER_IDENT |\n"> <LIT_CHARS "\t\tsed -e \"s/>.*/>/\" -e \"s/^/Signed-off-by: /\"\n"> <LIT_CHARS "\t) >expected &&\n"> <LIT_CHARS "\ttest_cmp expected actual\n"> <LIT_CHARS "\n">]} ) (Com {[LIT_CHARS test_expect_success]} {[SQ <LIT_CHARS "sign off (2)">]} {[SQ <LIT_CHARS "\n"> <LIT_CHARS "\n"> <LIT_CHARS "\techo 2 >positive &&\n"> <LIT_CHARS "\tgit add positive &&\n"> <LIT_CHARS "\texisting=\"Signed-off-by: Watch This <watchthis@example.com>\" &&\n"> <LIT_CHARS "\tgit commit -s -m \"thank you\n"> <LIT_CHARS "\n"> <LIT_CHARS "$existing\" &&\n"> <LIT_CHARS "\tgit cat-file commit HEAD | sed -e \"1,/^\\$/d\" >actual &&\n"> <LIT_CHARS "\t(\n"> <LIT_CHARS "\t\techo thank you\n"> <LIT_CHARS "\t\techo\n"> <LIT_CHARS "\t\techo $existing\n"> <LIT_CHARS "\t\tgit var GIT_COMMITTER_IDENT |\n"> <LIT_CHARS "\t\tsed -e \"s/>.*/>/\" -e \"s/^/Signed-off-by: /\"\n"> <LIT_CHARS "\t) >expected &&\n"> <LIT_CHARS "\ttest_cmp expected actual\n"> <LIT_CHARS "\n">]} ) (Com {[LIT_CHARS test_expect_success]} {[SQ <LIT_CHARS "signoff gap">]} {[SQ <LIT_CHARS "\n"> <LIT_CHARS "\n"> <LIT_CHARS "\techo 3 >positive &&\n"> <LIT_CHARS "\tgit add positive &&\n"> <LIT_CHARS "\talt=\"Alt-RFC-822-Header: Value\" &&\n"> <LIT_CHARS "\tgit commit -s -m \"welcome\n"> <LIT_CHARS "\n"> <LIT_CHARS "$alt\" &&\n"> <LIT_CHARS "\tgit cat-file commit HEAD | sed -e \"1,/^\\$/d\" > actual &&\n"> <LIT_CHARS "\t(\n"> <LIT_CHARS "\t\techo welcome\n"> <LIT_CHARS "\t\techo\n"> <LIT_CHARS "\t\techo $alt\n"> <LIT_CHARS "\t\tgit var GIT_COMMITTER_IDENT |\n"> <LIT_CHARS "\t\tsed -e \"s/>.*/>/\" -e \"s/^/Signed-off-by: /\"\n"> <LIT_CHARS "\t) >expected &&\n"> <LIT_CHARS "\ttest_cmp expected actual\n">]} ) (Com {[LIT_CHARS test_expect_success]} {[SQ <LIT_CHARS "signoff gap 2">]} {[SQ <LIT_CHARS "\n"> <LIT_CHARS "\n"> <LIT_CHARS "\techo 4 >positive &&\n"> <LIT_CHARS "\tgit add positive &&\n"> <LIT_CHARS "\talt=\"fixed: 34\" &&\n"> <LIT_CHARS "\tgit commit -s -m \"welcome\n"> <LIT_CHARS "\n"> <LIT_CHARS "We have now\n"> <LIT_CHARS "$alt\" &&\n"> <LIT_CHARS "\tgit cat-file commit HEAD | sed -e \"1,/^\\$/d\" > actual &&\n"> <LIT_CHARS "\t(\n"> <LIT_CHARS "\t\techo welcome\n"> <LIT_CHARS "\t\techo\n"> <LIT_CHARS "\t\techo We have now\n"> <LIT_CHARS "\t\techo $alt\n"> <LIT_CHARS "\t\techo\n"> <LIT_CHARS "\t\tgit var GIT_COMMITTER_IDENT |\n"> <LIT_CHARS "\t\tsed -e \"s/>.*/>/\" -e \"s/^/Signed-off-by: /\"\n"> <LIT_CHARS "\t) >expected &&\n"> <LIT_CHARS "\ttest_cmp expected actual\n">]} ) (Com {[LIT_CHARS test_expect_success]} {[SQ <LIT_CHARS "multiple -m">]} {[SQ <LIT_CHARS "\n"> <LIT_CHARS "\n"> <LIT_CHARS "\t>negative &&\n"> <LIT_CHARS "\tgit add negative &&\n"> <LIT_CHARS "\tgit commit -m \"one\" -m \"two\" -m \"three\" &&\n"> <LIT_CHARS "\tgit cat-file commit HEAD | sed -e \"1,/^\\$/d\" >actual &&\n"> <LIT_CHARS "\t(\n"> <LIT_CHARS "\t\techo one\n"> <LIT_CHARS "\t\techo\n"> <LIT_CHARS "\t\techo two\n"> <LIT_CHARS "\t\techo\n"> <LIT_CHARS "\t\techo three\n"> <LIT_CHARS "\t) >expected &&\n"> <LIT_CHARS "\ttest_cmp expected actual\n"> <LIT_CHARS "\n">]} ) (Com {[LIT_CHARS test_expect_success]} {[SQ <LIT_CHARS "amend commit to fix author">]} {[SQ <LIT_CHARS "\n"> <LIT_CHARS "\n"> <LIT_CHARS "\toldtick=$GIT_AUTHOR_DATE &&\n"> <LIT_CHARS "\ttest_tick &&\n"> <LIT_CHARS "\tgit reset --hard &&\n"> <LIT_CHARS "\tgit cat-file -p HEAD |\n"> <LIT_CHARS "\tsed -e \"s/author.*/author $author $oldtick/\" \\\n"> <LIT_CHARS "\t\t-e \"s/^\\(committer.*> \\).*$/\\1$GIT_COMMITTER_DATE/\" > \\\n"> <LIT_CHARS "\t\texpected &&\n"> <LIT_CHARS "\tgit commit --amend --author=\"$author\" &&\n"> <LIT_CHARS "\tgit cat-file -p HEAD > current &&\n"> <LIT_CHARS "\ttest_cmp expected current\n"> <LIT_CHARS "\n">]} ) (Com {[LIT_CHARS test_expect_success]} {[SQ <LIT_CHARS "git commit <file> with dirty index">]} {[SQ <LIT_CHARS "\n"> <LIT_CHARS "\techo tacocat > elif &&\n"> <LIT_CHARS "\techo tehlulz > chz &&\n"> <LIT_CHARS "\tgit add chz &&\n"> <LIT_CHARS "\tgit commit elif -m \"tacocat is a palindrome\" &&\n"> <LIT_CHARS "\tgit show --stat | grep elif &&\n"> <LIT_CHARS "\tgit diff --cached | grep chz\n">]} ) (Com {[LIT_CHARS test_expect_success]} {[SQ <LIT_CHARS "same tree (single parent)">]} {[SQ <LIT_CHARS "\n"> <LIT_CHARS "\n"> <LIT_CHARS "\tgit reset --hard &&\n"> <LIT_CHARS "\ttest_must_fail git commit -m empty\n"> <LIT_CHARS "\n">]} ) (Com {[LIT_CHARS test_expect_success]} {[SQ <LIT_CHARS "same tree (single parent) --allow-empty">]} {[SQ <LIT_CHARS "\n"> <LIT_CHARS "\n"> <LIT_CHARS "\tgit commit --allow-empty -m \"forced empty\" &&\n"> <LIT_CHARS "\tgit cat-file commit HEAD | grep forced\n"> <LIT_CHARS "\n">]} ) (Com {[LIT_CHARS test_expect_success]} {[SQ <LIT_CHARS "same tree (merge and amend merge)">]} {[SQ <LIT_CHARS "\n"> <LIT_CHARS "\n"> <LIT_CHARS "\tgit checkout -b side HEAD^ &&\n"> <LIT_CHARS "\techo zero >zero &&\n"> <LIT_CHARS "\tgit add zero &&\n"> <LIT_CHARS "\tgit commit -m \"add zero\" &&\n"> <LIT_CHARS "\tgit checkout master &&\n"> <LIT_CHARS "\n"> <LIT_CHARS "\tgit merge -s ours side -m \"empty ok\" &&\n"> <LIT_CHARS "\tgit diff HEAD^ HEAD >actual &&\n"> <LIT_CHARS "\t: >expected &&\n"> <LIT_CHARS "\ttest_cmp expected actual &&\n"> <LIT_CHARS "\n"> <LIT_CHARS "\tgit commit --amend -m \"empty really ok\" &&\n"> <LIT_CHARS "\tgit diff HEAD^ HEAD >actual &&\n"> <LIT_CHARS "\t: >expected &&\n"> <LIT_CHARS "\ttest_cmp expected actual\n"> <LIT_CHARS "\n">]} ) (Com {[LIT_CHARS test_expect_success]} {[SQ <LIT_CHARS "amend using the message from another commit">]} {[SQ <LIT_CHARS "\n"> <LIT_CHARS "\n"> <LIT_CHARS "\tgit reset --hard &&\n"> <LIT_CHARS "\ttest_tick &&\n"> <LIT_CHARS "\tgit commit --allow-empty -m \"old commit\" &&\n"> <LIT_CHARS "\told=$(git rev-parse --verify HEAD) &&\n"> <LIT_CHARS "\ttest_tick &&\n"> <LIT_CHARS "\tgit commit --allow-empty -m \"new commit\" &&\n"> <LIT_CHARS "\tnew=$(git rev-parse --verify HEAD) &&\n"> <LIT_CHARS "\ttest_tick &&\n"> <LIT_CHARS "\tgit commit --allow-empty --amend -C \"$old\" &&\n"> <LIT_CHARS "\tgit show --pretty=\"format:%ad %s\" \"$old\" >expected &&\n"> <LIT_CHARS "\tgit show --pretty=\"format:%ad %s\" HEAD >actual &&\n"> <LIT_CHARS "\ttest_cmp expected actual\n"> <LIT_CHARS "\n">]} ) (Com {[LIT_CHARS test_expect_success]} {[SQ <LIT_CHARS "amend using the message from a commit named with tag">]} {[SQ <LIT_CHARS "\n"> <LIT_CHARS "\n"> <LIT_CHARS "\tgit reset --hard &&\n"> <LIT_CHARS "\ttest_tick &&\n"> <LIT_CHARS "\tgit commit --allow-empty -m \"old commit\" &&\n"> <LIT_CHARS "\told=$(git rev-parse --verify HEAD) &&\n"> <LIT_CHARS "\tgit tag -a -m \"tag on old\" tagged-old HEAD &&\n"> <LIT_CHARS "\ttest_tick &&\n"> <LIT_CHARS "\tgit commit --allow-empty -m \"new commit\" &&\n"> <LIT_CHARS "\tnew=$(git rev-parse --verify HEAD) &&\n"> <LIT_CHARS "\ttest_tick &&\n"> <LIT_CHARS "\tgit commit --allow-empty --amend -C tagged-old &&\n"> <LIT_CHARS "\tgit show --pretty=\"format:%ad %s\" \"$old\" >expected &&\n"> <LIT_CHARS "\tgit show --pretty=\"format:%ad %s\" HEAD >actual &&\n"> <LIT_CHARS "\ttest_cmp expected actual\n"> <LIT_CHARS "\n">]} ) (Com {[LIT_CHARS test_expect_success]} {[SQ <LIT_CHARS "amend can copy notes">]} {[SQ <LIT_CHARS "\n"> <LIT_CHARS "\n"> <LIT_CHARS "\tgit config notes.rewrite.amend true &&\n"> <LIT_CHARS "\tgit config notes.rewriteRef \"refs/notes/*\" &&\n"> <LIT_CHARS "\ttest_commit foo &&\n"> <LIT_CHARS "\tgit notes add -m\"a note\" &&\n"> <LIT_CHARS "\ttest_tick &&\n"> <LIT_CHARS "\tgit commit --amend -m\"new foo\" &&\n"> <LIT_CHARS "\ttest \"$(git notes show)\" = \"a note\"\n"> <LIT_CHARS "\n">]} ) (Com {[LIT_CHARS test_expect_success]} {[SQ <LIT_CHARS "commit a file whose name is a dash">]} {[SQ <LIT_CHARS "\n"> <LIT_CHARS "\tgit reset --hard &&\n"> <LIT_CHARS "\tfor i in 1 2 3 4 5\n"> <LIT_CHARS "\tdo\n"> <LIT_CHARS "\t\techo $i\n"> <LIT_CHARS "\tdone >./- &&\n"> <LIT_CHARS "\tgit add ./- &&\n"> <LIT_CHARS "\ttest_tick &&\n"> <LIT_CHARS "\tgit commit -m \"add dash\" >output </dev/null &&\n"> <LIT_CHARS "\ttest_i18ngrep \" changed, 5 insertions\" output\n">]} ) (Com {[LIT_CHARS test_done]} ) )