@@ -4,8 +4,76 @@ test_description='git commit porcelain-ish'
4
4
5
5
. ./test-lib.sh
6
6
7
+ # Arguments: [<prefix] [<commit message>] [<commit options>]
8
+ check_summary_oneline () {
9
+ test_tick &&
10
+ git commit ${3+" $3 " } -m " $2 " | head -1 > act &&
11
+
12
+ # branch name
13
+ SUMMARY_PREFIX=" $( git name-rev --name-only HEAD) " &&
14
+
15
+ # append the "special" prefix, like "root-commit", "detached HEAD"
16
+ if test -n " $1 "
17
+ then
18
+ SUMMARY_PREFIX=" $SUMMARY_PREFIX ($1 )"
19
+ fi
20
+
21
+ # abbrev SHA-1
22
+ SUMMARY_POSTFIX=" $( git log -1 --pretty=' format:%h' ) "
23
+ echo " [$SUMMARY_PREFIX $SUMMARY_POSTFIX ] $2 " > exp &&
24
+
25
+ test_cmp exp act
26
+ }
27
+
28
+ test_expect_success ' output summary format' '
29
+
30
+ echo new >file1 &&
31
+ git add file1 &&
32
+ check_summary_oneline "root-commit" "initial" &&
33
+
34
+ echo change >>file1 &&
35
+ git add file1 &&
36
+ check_summary_oneline "" "a change"
37
+ '
38
+
39
+ test_expect_success ' output summary format for commit with an empty diff' '
40
+
41
+ check_summary_oneline "" "empty" "--allow-empty"
42
+ '
43
+
44
+ test_expect_success ' output summary format for merges' '
45
+
46
+ git checkout -b recursive-base &&
47
+ test_commit base file1 &&
48
+
49
+ git checkout -b recursive-a recursive-base &&
50
+ test_commit commit-a file1 &&
51
+
52
+ git checkout -b recursive-b recursive-base &&
53
+ test_commit commit-b file1 &&
54
+
55
+ # conflict
56
+ git checkout recursive-a &&
57
+ test_must_fail git merge recursive-b &&
58
+ # resolve the conflict
59
+ echo commit-a > file1 &&
60
+ git add file1 &&
61
+ check_summary_oneline "" "Merge"
62
+ '
63
+
64
+ output_tests_cleanup () {
65
+ # this is needed for "do not fire editor in the presence of conflicts"
66
+ git checkout master &&
67
+
68
+ # this is needed for the "partial removal" test to pass
69
+ git rm file1 &&
70
+ git commit -m " cleanup"
71
+ }
72
+
7
73
test_expect_success ' the basics' '
8
74
75
+ output_tests_cleanup &&
76
+
9
77
echo doing partial >"commit is" &&
10
78
mkdir not &&
11
79
echo very much encouraged but we should >not/forbid &&
0 commit comments