git-gui: actually show the choose repository dialog
[git/mingw/4msysgit/wingit-dll.git] / t / t7501-commit.sh
blobcfa67227e581abcfbcd7bbf5dbe6b820626f89c4
1 #!/bin/sh
3 # Copyright (c) 2007 Kristian Høgsberg <krh@redhat.com>
6 # FIXME: Test the various index usages, -i and -o, test reflog,
7 # signoff, hooks
9 test_description='git-commit'
10 . ./test-lib.sh
12 test_tick
14 test_expect_success \
15 "initial status" \
16 "echo 'bongo bongo' >file &&
17 git-add file && \
18 git-status | grep 'Initial commit'"
20 test_expect_failure \
21 "fail initial amend" \
22 "git-commit --amend"
24 test_expect_success \
25 "initial commit" \
26 "git-commit -m initial"
28 test_expect_failure \
29 "invalid options 1" \
30 "git-commit -m foo -m bar -F file"
32 test_expect_failure \
33 "invalid options 2" \
34 "git-commit -C HEAD -m illegal"
36 test_expect_failure \
37 "using invalid commit with -C" \
38 "git-commit -C bogus"
40 test_expect_failure \
41 "testing nothing to commit" \
42 "git-commit -m initial"
44 test_expect_success \
45 "next commit" \
46 "echo 'bongo bongo bongo' >file \
47 git-commit -m next -a"
49 test_expect_failure \
50 "commit message from non-existing file" \
51 "echo 'more bongo: bongo bongo bongo bongo' >file && \
52 git-commit -F gah -a"
54 # Empty except stray tabs and spaces on a few lines.
55 sed -e 's/@$//' >msg <<EOF
59 Signed-off-by: hula
60 EOF
61 test_expect_failure \
62 "empty commit message" \
63 "git-commit -F msg -a"
65 test_expect_success \
66 "commit message from file" \
67 "echo 'this is the commit message, coming from a file' >msg && \
68 git-commit -F msg -a"
70 cat >editor <<\EOF
71 #!/bin/sh
72 sed -e "s/a file/an amend commit/g" $1 > $1.new
73 mv $1.new $1
74 EOF
75 chmod 755 editor
77 test_expect_success \
78 "amend commit" \
79 "VISUAL=./editor git-commit --amend"
81 test_expect_failure \
82 "passing -m and -F" \
83 "echo 'enough with the bongos' >file && \
84 git-commit -F msg -m amending ."
86 test_expect_success \
87 "using message from other commit" \
88 "git-commit -C HEAD^ ."
90 cat >editor <<\EOF
91 #!/bin/sh
92 sed -e "s/amend/older/g" $1 > $1.new
93 mv $1.new $1
94 EOF
95 chmod 755 editor
97 test_expect_success \
98 "editing message from other commit" \
99 "echo 'hula hula' >file && \
100 VISUAL=./editor git-commit -c HEAD^ -a"
102 test_expect_success \
103 "message from stdin" \
104 "echo 'silly new contents' >file && \
105 echo commit message from stdin | git-commit -F - -a"
107 test_expect_success \
108 "overriding author from command line" \
109 "echo 'gak' >file && \
110 git-commit -m 'author' --author 'Rubber Duck <rduck@convoy.org>' -a"
112 test_expect_success \
113 "interactive add" \
114 "echo 7 | git-commit --interactive | grep 'What now'"
116 test_expect_success \
117 "showing committed revisions" \
118 "git-rev-list HEAD >current"
120 # We could just check the head sha1, but checking each commit makes it
121 # easier to isolate bugs.
123 cat >expected <<\EOF
124 72c0dc9855b0c9dadcbfd5a31cab072e0cb774ca
125 9b88fc14ce6b32e3d9ee021531a54f18a5cf38a2
126 3536bbb352c3a1ef9a420f5b4242d48578b92aa7
127 d381ac431806e53f3dd7ac2f1ae0534f36d738b9
128 4fd44095ad6334f3ef72e4c5ec8ddf108174b54a
129 402702b49136e7587daa9280e91e4bb7cb2179f7
132 test_expect_success \
133 'validate git-rev-list output.' \
134 'diff current expected'
136 test_done