Raw
1 #!/bin/sh
2 #
3 # Copyright (C) 2005 Rene Scharfe
4 #
5
6 test_description='git commit-tree options test
7
8 This test checks that git commit-tree can create a specific commit
9 object by defining all environment variables that it understands.
10
11 Also make sure that command line parser understands the normal
12 "flags first and then non flag arguments" command line.
13 '
14
15 . ./test-lib.sh
16
17 test_expect_success 'test preparation: write empty tree' '
18 cat >expected <<-EOF &&
19 tree $EMPTY_TREE
20 author Author Name <author@email> 1117148400 +0000
21 committer Committer Name <committer@email> 1117150200 +0000
22
23 comment text
24 EOF
25 git write-tree >treeid
26 '
27
28 test_expect_success 'construct commit' '
29 echo comment text |
30 GIT_AUTHOR_NAME="Author Name" \
31 GIT_AUTHOR_EMAIL="author@email" \
32 GIT_AUTHOR_DATE="2005-05-26 23:00" \
33 GIT_COMMITTER_NAME="Committer Name" \
34 GIT_COMMITTER_EMAIL="committer@email" \
35 GIT_COMMITTER_DATE="2005-05-26 23:30" \
36 TZ=GMT git commit-tree $(cat treeid) >commitid 2>/dev/null
37 '
38
39 test_expect_success 'read commit' '
40 git cat-file commit $(cat commitid) >commit
41 '
42
43 test_expect_success 'compare commit' '
44 test_cmp expected commit
45 '
46
47 test_expect_success 'flags and then non flags' '
48 test_tick &&
49 echo comment text |
50 git commit-tree $(cat treeid) >commitid &&
51 echo comment text |
52 git commit-tree $(cat treeid) -p $(cat commitid) >childid-1 &&
53 echo comment text |
54 git commit-tree -p $(cat commitid) $(cat treeid) >childid-2 &&
55 test_cmp childid-1 childid-2 &&
56 git commit-tree $(cat treeid) -m foo >childid-3 &&
57 git commit-tree -m foo $(cat treeid) >childid-4 &&
58 test_cmp childid-3 childid-4
59 '
60
61 test_done