@@ -52,6 +52,46 @@ test_expect_success 'diff.context honored by "log"' '
52
52
test_grep "^ firstline" output
53
53
'
54
54
55
+ test_expect_success ' diff.context honored by "add"' '
56
+ git add -p >output &&
57
+ test_grep ! firstline output &&
58
+ test_config diff.context 8 &&
59
+ git log -1 -p >output &&
60
+ test_grep "^ firstline" output
61
+ '
62
+
63
+ test_expect_success ' diff.context honored by "commit"' '
64
+ ! git commit -p >output &&
65
+ test_grep ! firstline output &&
66
+ test_config diff.context 8 &&
67
+ ! git commit -p >output &&
68
+ test_grep "^ firstline" output
69
+ '
70
+
71
+ test_expect_success ' diff.context honored by "checkout"' '
72
+ git checkout -p >output &&
73
+ test_grep ! firstline output &&
74
+ test_config diff.context 8 &&
75
+ git checkout -p >output &&
76
+ test_grep "^ firstline" output
77
+ '
78
+
79
+ test_expect_success ' diff.context honored by "stash"' '
80
+ ! git stash -p >output &&
81
+ test_grep ! firstline output &&
82
+ test_config diff.context 8 &&
83
+ ! git stash -p >output &&
84
+ test_grep "^ firstline" output
85
+ '
86
+
87
+ test_expect_success ' diff.context honored by "restore"' '
88
+ git restore -p >output &&
89
+ test_grep ! firstline output &&
90
+ test_config diff.context 8 &&
91
+ git restore -p >output &&
92
+ test_grep "^ firstline" output
93
+ '
94
+
55
95
test_expect_success ' The -U option overrides diff.context' '
56
96
test_config diff.context 8 &&
57
97
git log -U4 -1 >output &&
@@ -82,6 +122,36 @@ test_expect_success 'negative integer config parsing' '
82
122
test_grep "bad config variable" output
83
123
'
84
124
125
+ test_expect_success ' negative integer config parsing by "add"' '
126
+ test_config diff.context -1 &&
127
+ test_must_fail git add -p 2>output &&
128
+ test_grep "diff.context cannot be negative" output
129
+ '
130
+
131
+ test_expect_success ' negative integer config parsing by "commit"' '
132
+ test_config diff.context -1 &&
133
+ test_must_fail git commit -p 2>output &&
134
+ test_grep "bad config variable" output
135
+ '
136
+
137
+ test_expect_success ' negative integer config parsing by "checkout"' '
138
+ test_config diff.context -1 &&
139
+ test_must_fail git checkout -p 2>output &&
140
+ test_grep "diff.context cannot be negative" output
141
+ '
142
+
143
+ test_expect_success ' negative integer config parsing by "stash"' '
144
+ test_config diff.context -1 &&
145
+ test_must_fail git stash -p 2>output &&
146
+ test_grep "diff.context cannot be negative" output
147
+ '
148
+
149
+ test_expect_success ' negative integer config parsing by "restore"' '
150
+ test_config diff.context -1 &&
151
+ test_must_fail git restore -p 2>output &&
152
+ test_grep "diff.context cannot be negative" output
153
+ '
154
+
85
155
test_expect_success ' -U0 is valid, so is diff.context=0' '
86
156
test_config diff.context 0 &&
87
157
git diff >output &&
0 commit comments