Merge branch 'maint'
[gitweb.git] / t / t7501-commit.sh
old mode 100644 (file)
new mode 100755 (executable)
index 6bd3c9e..9dba104
@@ -33,6 +33,16 @@ test_expect_failure \
        "invalid options 2" \
        "git-commit -C HEAD -m illegal"
 
+test_expect_failure \
+       "using paths with -a" \
+       "echo King of the bongo >file &&
+       git-commit -m foo -a file"
+
+test_expect_failure \
+       "using paths with --interactive" \
+       "echo bong-o-bong >file &&
+       echo 7 | git-commit -m foo --interactive file"
+
 test_expect_failure \
        "using invalid commit with -C" \
        "git-commit -C bogus"
@@ -131,4 +141,105 @@ test_expect_success \
     'validate git-rev-list output.' \
     'diff current expected'
 
+test_expect_success 'partial commit that involves removal (1)' '
+
+       git rm --cached file &&
+       mv file elif &&
+       git add elif &&
+       git commit -m "Partial: add elif" elif &&
+       git diff-tree --name-status HEAD^ HEAD >current &&
+       echo "A elif" >expected &&
+       diff expected current
+
+'
+
+test_expect_success 'partial commit that involves removal (2)' '
+
+       git commit -m "Partial: remove file" file &&
+       git diff-tree --name-status HEAD^ HEAD >current &&
+       echo "D file" >expected &&
+       diff expected current
+
+'
+
+test_expect_success 'partial commit that involves removal (3)' '
+
+       git rm --cached elif &&
+       echo elif >elif &&
+       git commit -m "Partial: modify elif" elif &&
+       git diff-tree --name-status HEAD^ HEAD >current &&
+       echo "M elif" >expected &&
+       diff expected current
+
+'
+
+author="The Real Author <someguy@his.email.org>"
+test_expect_success 'amend commit to fix author' '
+
+       oldtick=$GIT_AUTHOR_DATE &&
+       test_tick &&
+       git reset --hard &&
+       git cat-file -p HEAD |
+       sed -e "s/author.*/author $author $oldtick/" \
+               -e "s/^\(committer.*> \).*$/\1$GIT_COMMITTER_DATE/" > \
+               expected &&
+       git commit --amend --author="$author" &&
+       git cat-file -p HEAD > current &&
+       diff expected current
+
+'
+
+test_expect_success 'sign off (1)' '
+
+       echo 1 >positive &&
+       git add positive &&
+       git commit -s -m "thank you" &&
+       git cat-file commit HEAD | sed -e "1,/^\$/d" >actual &&
+       (
+               echo thank you
+               echo
+               git var GIT_COMMITTER_IDENT |
+               sed -e "s/>.*/>/" -e "s/^/Signed-off-by: /"
+       ) >expected &&
+       diff -u expected actual
+
+'
+
+test_expect_success 'sign off (2)' '
+
+       echo 2 >positive &&
+       git add positive &&
+       existing="Signed-off-by: Watch This <watchthis@example.com>" &&
+       git commit -s -m "thank you
+
+$existing" &&
+       git cat-file commit HEAD | sed -e "1,/^\$/d" >actual &&
+       (
+               echo thank you
+               echo
+               echo $existing
+               git var GIT_COMMITTER_IDENT |
+               sed -e "s/>.*/>/" -e "s/^/Signed-off-by: /"
+       ) >expected &&
+       diff -u expected actual
+
+'
+
+test_expect_success 'multiple -m' '
+
+       >negative &&
+       git add 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 three
+       ) >expected &&
+       diff -u expected actual
+
+'
+
 test_done