Merge branch 'sg/t7501-thinkofix'
authorJunio C Hamano <gitster@pobox.com>
Mon, 27 Aug 2018 21:33:48 +0000 (14:33 -0700)
committerJunio C Hamano <gitster@pobox.com>
Mon, 27 Aug 2018 21:33:48 +0000 (14:33 -0700)
Test fixes.

* sg/t7501-thinkofix:
t7501-commit: drop silly command substitution

1  2 
t/t7501-commit.sh
diff --combined t/t7501-commit.sh
index fb9337c708798edd411802251fa4b9cd39387140,cb6c5bdcb630ee3cb017ca0544487fc587e81388..4cae92804d11f75f24bdd6f6517a88c834e7cfc7
@@@ -18,7 -18,7 +18,7 @@@ test_expect_success 'initial status' 
        echo bongo bongo >file &&
        git add file &&
        git status >actual &&
 -      test_i18ngrep "Initial commit" actual
 +      test_i18ngrep "No commits yet" actual
  '
  
  test_expect_success 'fail initial amend' '
@@@ -47,23 -47,11 +47,23 @@@ test_expect_success 'paths and -a do no
  test_expect_success PERL 'can use paths with --interactive' '
        echo bong-o-bong >file &&
        # 2: update, 1:st path, that is all, 7: quit
 -      ( echo 2; echo 1; echo; echo 7 ) |
 +      test_write_lines 2 1 "" 7 |
        git commit -m foo --interactive file &&
        git reset --hard HEAD^
  '
  
 +test_expect_success 'removed files and relative paths' '
 +      test_when_finished "rm -rf foo" &&
 +      git init foo &&
 +      >foo/foo.txt &&
 +      git -C foo add foo.txt &&
 +      git -C foo commit -m first &&
 +      git -C foo rm foo.txt &&
 +
 +      mkdir -p foo/bar &&
 +      git -C foo/bar commit -m second ../foo.txt
 +'
 +
  test_expect_success 'using invalid commit with -C' '
        test_must_fail git commit --allow-empty -C bogus
  '
@@@ -167,15 -155,6 +167,15 @@@ test_expect_success 'amend --only ignor
        git diff --exit-code
  '
  
 +test_expect_success 'allow-empty --only ignores staged contents' '
 +      echo changed-again >file &&
 +      git add file &&
 +      git commit --allow-empty --only -m "empty" &&
 +      git cat-file blob HEAD:file >file.actual &&
 +      test_cmp file.expect file.actual &&
 +      git diff --exit-code
 +'
 +
  test_expect_success 'set up editor' '
        cat >editor <<-\EOF &&
        #!/bin/sh
@@@ -221,26 -200,6 +221,26 @@@ test_expect_success '--amend --edit of 
        test_cmp expect msg
  '
  
 +test_expect_success '--amend to set message to empty' '
 +      echo bata >file &&
 +      git add file &&
 +      git commit -m "unamended" &&
 +      git commit --amend --allow-empty-message -m "" &&
 +      git diff-tree -s --format=%s HEAD >msg &&
 +      echo "" >expect &&
 +      test_cmp expect msg
 +'
 +
 +test_expect_success '--amend to set empty message needs --allow-empty-message' '
 +      echo conga >file &&
 +      git add file &&
 +      git commit -m "unamended" &&
 +      test_must_fail git commit --amend -m "" &&
 +      git diff-tree -s --format=%s HEAD >msg &&
 +      echo "unamended" >expect &&
 +      test_cmp expect msg
 +'
 +
  test_expect_success '-m --edit' '
        echo amended >expect &&
        git commit --allow-empty -m buffer &&
@@@ -293,7 -252,7 +293,7 @@@ test_expect_success PERL 'interactive a
  test_expect_success PERL "commit --interactive doesn't change index if editor aborts" '
        echo zoo >file &&
        test_must_fail git diff --exit-code >diff1 &&
 -      (echo u ; echo "*" ; echo q) |
 +      test_write_lines u "*" q |
        (
                EDITOR=: &&
                export EDITOR &&
@@@ -411,8 -370,8 +411,8 @@@ test_expect_success 'sign off (1)' 
        git commit -s -m "thank you" &&
        git cat-file commit HEAD | sed -e "1,/^\$/d" >actual &&
        (
 -              echo thank you
 -              echo
 +              echo thank you &&
 +              echo &&
                git var GIT_COMMITTER_IDENT |
                sed -e "s/>.*/>/" -e "s/^/Signed-off-by: /"
        ) >expected &&
@@@ -430,9 -389,9 +430,9 @@@ test_expect_success 'sign off (2)' 
  $existing" &&
        git cat-file commit HEAD | sed -e "1,/^\$/d" >actual &&
        (
 -              echo thank you
 -              echo
 -              echo $existing
 +              echo thank you &&
 +              echo &&
 +              echo $existing &&
                git var GIT_COMMITTER_IDENT |
                sed -e "s/>.*/>/" -e "s/^/Signed-off-by: /"
        ) >expected &&
@@@ -450,9 -409,9 +450,9 @@@ test_expect_success 'signoff gap' 
  $alt" &&
        git cat-file commit HEAD | sed -e "1,/^\$/d" > actual &&
        (
 -              echo welcome
 -              echo
 -              echo $alt
 +              echo welcome &&
 +              echo &&
 +              echo $alt &&
                git var GIT_COMMITTER_IDENT |
                sed -e "s/>.*/>/" -e "s/^/Signed-off-by: /"
        ) >expected &&
@@@ -470,53 -429,17 +470,53 @@@ We have no
  $alt" &&
        git cat-file commit HEAD | sed -e "1,/^\$/d" > actual &&
        (
 -              echo welcome
 -              echo
 -              echo We have now
 -              echo $alt
 -              echo
 +              echo welcome &&
 +              echo &&
 +              echo We have now &&
 +              echo $alt &&
 +              echo &&
                git var GIT_COMMITTER_IDENT |
                sed -e "s/>.*/>/" -e "s/^/Signed-off-by: /"
        ) >expected &&
        test_cmp expected actual
  '
  
 +test_expect_success 'signoff respects trailer config' '
 +
 +      echo 5 >positive &&
 +      git add positive &&
 +      git commit -s -m "subject
 +
 +non-trailer line
 +Myfooter: x" &&
 +      git cat-file commit HEAD | sed -e "1,/^\$/d" > actual &&
 +      (
 +              echo subject &&
 +              echo &&
 +              echo non-trailer line &&
 +              echo Myfooter: x &&
 +              echo &&
 +              echo "Signed-off-by: $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL>"
 +      ) >expected &&
 +      test_cmp expected actual &&
 +
 +      echo 6 >positive &&
 +      git add positive &&
 +      git -c "trailer.Myfooter.ifexists=add" commit -s -m "subject
 +
 +non-trailer line
 +Myfooter: x" &&
 +      git cat-file commit HEAD | sed -e "1,/^\$/d" > actual &&
 +      (
 +              echo subject &&
 +              echo &&
 +              echo non-trailer line &&
 +              echo Myfooter: x &&
 +              echo "Signed-off-by: $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL>"
 +      ) >expected &&
 +      test_cmp expected actual
 +'
 +
  test_expect_success 'multiple -m' '
  
        >negative &&
        git commit -m "one" -m "two" -m "three" &&
        git cat-file commit HEAD | sed -e "1,/^\$/d" >actual &&
        (
 -              echo one
 -              echo
 -              echo two
 -              echo
 +              echo one &&
 +              echo &&
 +              echo two &&
 +              echo &&
                echo three
        ) >expected &&
        test_cmp expected actual
@@@ -582,11 -505,13 +582,11 @@@ test_expect_success 'same tree (merge a
  
        git merge -s ours side -m "empty ok" &&
        git diff HEAD^ HEAD >actual &&
 -      : >expected &&
 -      test_cmp expected actual &&
 +      test_must_be_empty actual &&
  
        git commit --amend -m "empty really ok" &&
        git diff HEAD^ HEAD >actual &&
 -      : >expected &&
 -      test_cmp expected actual
 +      test_must_be_empty actual
  
  '
  
@@@ -675,7 -600,7 +675,7 @@@ test_expect_success '--dry-run with con
        git checkout -b branch-2 HEAD^1 &&
        echo "commit-2-state" >test-file &&
        git commit -m "commit 2" -i test-file &&
-       ! $(git merge --no-commit commit-1) &&
+       test_must_fail git merge --no-commit commit-1 &&
        echo "commit-2-state" >test-file &&
        git add test-file &&
        git commit --dry-run &&