diff options
author | Kristian Høgsberg <krh@redhat.com> | 2007-07-31 15:37:30 -0400 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2007-07-31 23:10:26 -0700 |
commit | 12ace0b20de33d57100435a60e09bb3971420003 (patch) | |
tree | a1bed4a80b1575e9a64d76bb60e8627506efce8e /t/t7501-commit.sh | |
parent | 274e13e0e9c7e475bbc342a10d614dd40b0e4c15 (diff) | |
download | git-12ace0b20de33d57100435a60e09bb3971420003.tar.gz |
Add test case for basic commit functionality.
Signed-off-by: Kristian Høgsberg <krh@redhat.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't/t7501-commit.sh')
-rw-r--r-- | t/t7501-commit.sh | 134 |
1 files changed, 134 insertions, 0 deletions
diff --git a/t/t7501-commit.sh b/t/t7501-commit.sh new file mode 100644 index 0000000000..8cc2cd9e60 --- /dev/null +++ b/t/t7501-commit.sh @@ -0,0 +1,134 @@ +#!/bin/sh +# +# Copyright (c) 2007 Kristian Høgsberg <krh@redhat.com> +# + +# FIXME: Test the various index usages, -i and -o, test reflog, +# signoff, hooks + +test_description='git-commit' +. ./test-lib.sh + +test_tick + +test_expect_success \ + "initial status" \ + "echo 'bongo bongo' >file && + git-add file && \ + git-status | grep 'Initial commit'" + +test_expect_failure \ + "fail initial amend" \ + "git-commit --amend" + +test_expect_success \ + "initial commit" \ + "git-commit -m initial" + +test_expect_failure \ + "invalid options 1" \ + "git-commit --amend -F file" + +test_expect_failure \ + "invalid options 2" \ + "git-commit -C HEAD -m illegal" + +test_expect_failure \ + "using invalid commit with -C" \ + "git-commit -C bogus" + +test_expect_failure \ + "testing nothing to commit" \ + "git-commit -m initial" + +test_expect_success \ + "next commit" \ + "echo 'bongo bongo bongo' >file \ + git-commit -m next -a" + +test_expect_failure \ + "commit message from non-existing file" \ + "echo 'more bongo: bongo bongo bongo bongo' >file && \ + git-commit -F gah -a" + +# Empty except stray tabs and spaces on a few lines. +sed -e 's/@$//' >msg <<EOF + @ + + @ +Signed-off-by: hula +EOF +test_expect_failure \ + "empty commit message" \ + "git-commit -F msg -a" + +test_expect_success \ + "commit message from file" \ + "echo 'this is the commit message, coming from a file' >msg && \ + git-commit -F msg -a" + +cat >editor <<\EOF +#!/bin/sh +sed -i -e "s/a file/an amend commit/g" $1 +EOF +chmod 755 editor + +test_expect_success \ + "amend commit" \ + "VISUAL=./editor git-commit --amend" + +test_expect_failure \ + "passing --amend and -F" \ + "echo 'enough with the bongos' >file && \ + git-commit -F msg --amend ." + +test_expect_success \ + "using message from other commit" \ + "git-commit -C HEAD^ ." + +cat >editor <<\EOF +#!/bin/sh +sed -i -e "s/amend/older/g" $1 +EOF +chmod 755 editor + +test_expect_success \ + "editing message from other commit" \ + "echo 'hula hula' >file && \ + VISUAL=./editor git-commit -c HEAD^ -a" + +test_expect_success \ + "message from stdin" \ + "echo 'silly new contents' >file && \ + echo commit message from stdin | git-commit -F - -a" + +test_expect_success \ + "overriding author from command line" \ + "echo 'gak' >file && \ + git-commit -m 'author' --author 'Rubber Duck <rduck@convoy.org>' -a" + +test_expect_success \ + "interactive add" \ + "echo 7 | git-commit --interactive | grep 'What now'" + +test_expect_success \ + "showing committed revisions" \ + "git-rev-list HEAD >current" + +# We could just check the head sha1, but checking each commit makes it +# easier to isolate bugs. + +cat >expected <<\EOF +72c0dc9855b0c9dadcbfd5a31cab072e0cb774ca +9b88fc14ce6b32e3d9ee021531a54f18a5cf38a2 +3536bbb352c3a1ef9a420f5b4242d48578b92aa7 +d381ac431806e53f3dd7ac2f1ae0534f36d738b9 +4fd44095ad6334f3ef72e4c5ec8ddf108174b54a +402702b49136e7587daa9280e91e4bb7cb2179f7 +EOF + +test_expect_success \ + 'validate git-rev-list output.' \ + 'diff current expected' + +test_done |