Test interaction between diff --check and --exit-code
Make sure that it works as advertised in the man page. Signed-off-by: Wincent Colaiuta <win@wincent.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Wincent Colaiuta committed
Dec 14, 2007 at 12:23 UTC
5973a07937f2c64b595c6784b06eb4441c07b5ef
1 file changed
+29
t/t4017-diff-retval.sh
+29
@@ -76,4 +76,33 @@ test_expect_success 'git diff-index --cached HEAD' '
76
}
77
'
78
79
+test_expect_success '--check --exit-code returns 0 for no difference' '
80
+
81
+ git diff --check --exit-code
82
+
83
+'
84
+
85
+test_expect_success '--check --exit-code returns 1 for a clean difference' '
86
+
87
+ echo "good" > a &&
88
+ git diff --check --exit-code
89
+ test $? = 1
90
+
91
+'
92
+
93
+test_expect_success '--check --exit-code returns 3 for a dirty difference' '
94
+
95
+ echo "bad " >> a &&
96
+ git diff --check --exit-code
97
+ test $? = 3
98
+
99
+'
100
+
101
+test_expect_success '--check with --no-pager returns 2 for dirty difference' '
102
+
103
+ git --no-pager diff --check
104
+ test $? = 2
105
+
106
+'
107
+
108
test_done