]> asedeno.scripts.mit.edu Git - git.git/blob - t/t7502-commit.sh
Merge branch 'kh/fetch-optparse'
[git.git] / t / t7502-commit.sh
1 #!/bin/sh
2
3 test_description='git commit porcelain-ish'
4
5 . ./test-lib.sh
6
7 test_expect_success 'the basics' '
8
9         echo doing partial >"commit is" &&
10         mkdir not &&
11         echo very much encouraged but we should >not/forbid &&
12         git add "commit is" not &&
13         echo update added "commit is" file >"commit is" &&
14         echo also update another >not/forbid &&
15         test_tick &&
16         git commit -a -m "initial with -a" &&
17
18         git cat-file blob HEAD:"commit is" >current.1 &&
19         git cat-file blob HEAD:not/forbid >current.2 &&
20
21         cmp current.1 "commit is" &&
22         cmp current.2 not/forbid
23
24 '
25
26 test_expect_success 'partial' '
27
28         echo another >"commit is" &&
29         echo another >not/forbid &&
30         test_tick &&
31         git commit -m "partial commit to handle a file" "commit is" &&
32
33         changed=$(git diff-tree --name-only HEAD^ HEAD) &&
34         test "$changed" = "commit is"
35
36 '
37
38 test_expect_success 'partial modification in a subdirecotry' '
39
40         test_tick &&
41         git commit -m "partial commit to subdirectory" not &&
42
43         changed=$(git diff-tree -r --name-only HEAD^ HEAD) &&
44         test "$changed" = "not/forbid"
45
46 '
47
48 test_expect_success 'partial removal' '
49
50         git rm not/forbid &&
51         git commit -m "partial commit to remove not/forbid" not &&
52
53         changed=$(git diff-tree -r --name-only HEAD^ HEAD) &&
54         test "$changed" = "not/forbid" &&
55         remain=$(git ls-tree -r --name-only HEAD) &&
56         test "$remain" = "commit is"
57
58 '
59
60 test_expect_success 'sign off' '
61
62         >positive &&
63         git add positive &&
64         git commit -s -m "thank you" &&
65         actual=$(git cat-file commit HEAD | sed -ne "s/Signed-off-by: //p") &&
66         expected=$(git var GIT_COMMITTER_IDENT | sed -e "s/>.*/>/") &&
67         test "z$actual" = "z$expected"
68
69 '
70
71 test_expect_success 'multiple -m' '
72
73         >negative &&
74         git add negative &&
75         git commit -m "one" -m "two" -m "three" &&
76         actual=$(git cat-file commit HEAD | sed -e "1,/^\$/d") &&
77         expected=$(echo one; echo; echo two; echo; echo three) &&
78         test "z$actual" = "z$expected"
79
80 '
81
82 test_expect_success 'verbose' '
83
84         echo minus >negative &&
85         git add negative &&
86         git status -v | sed -ne "/^diff --git /p" >actual &&
87         echo "diff --git a/negative b/negative" >expect &&
88         diff -u expect actual
89
90 '
91
92 test_done