@@ -146,85 +146,73 @@ test_expect_success 'Check invalid format specifiers are errors' '
146
146
test_must_fail git for-each-ref --format="%(authordate:INVALID)" refs/heads
147
147
'
148
148
149
- cat > expected << \EOF
150
- 'refs/heads/master' 'Mon Jul 3 17:18:43 2006 +0200' 'Mon Jul 3 17:18:44 2006 +0200'
151
- 'refs/tags/testtag' 'Mon Jul 3 17:18:45 2006 +0200'
152
- EOF
149
+ test_date () {
150
+ f=$1 &&
151
+ committer_date=$2 &&
152
+ author_date=$3 &&
153
+ tagger_date=$4 &&
154
+ cat > expected << -EOF &&
155
+ 'refs/heads/master' '$committer_date ' '$author_date '
156
+ 'refs/tags/testtag' '$tagger_date '
157
+ EOF
158
+ (
159
+ git for-each-ref --shell \
160
+ --format=" %(refname) %(committerdate${f: +: $f } ) %(authordate${f: +: $f } )" \
161
+ refs/heads &&
162
+ git for-each-ref --shell \
163
+ --format=" %(refname) %(taggerdate${f: +: $f } )" \
164
+ refs/tags
165
+ ) > actual &&
166
+ test_cmp expected actual
167
+ }
153
168
154
169
test_expect_success ' Check unformatted date fields output' '
155
- (git for-each-ref --shell --format="%(refname) %(committerdate) %(authordate)" refs/heads &&
156
- git for-each-ref --shell --format="%(refname) %(taggerdate)" refs/tags) >actual &&
157
- test_cmp expected actual
170
+ test_date "" \
171
+ "Mon Jul 3 17:18:43 2006 +0200" \
172
+ "Mon Jul 3 17:18:44 2006 +0200" \
173
+ "Mon Jul 3 17:18:45 2006 +0200"
158
174
'
159
175
160
176
test_expect_success ' Check format "default" formatted date fields output' '
161
- f= default &&
162
- (git for-each-ref --shell --format="%(refname) %(committerdate:$f) %(authordate:$f)" refs/heads &&
163
- git for-each-ref --shell --format="%(refname) %(taggerdate:$f)" refs/tags) >actual &&
164
- test_cmp expected actual
177
+ test_date default \
178
+ "Mon Jul 3 17:18:43 2006 +0200" \
179
+ "Mon Jul 3 17:18:44 2006 +0200" \
180
+ "Mon Jul 3 17:18:45 2006 +0200"
165
181
'
166
182
167
183
# Don't know how to do relative check because I can't know when this script
168
184
# is going to be run and can't fake the current time to git, and hence can't
169
185
# provide expected output. Instead, I'll just make sure that "relative"
170
186
# doesn't exit in error
171
- #
172
- # cat >expected <<\EOF
173
- #
174
- # EOF
175
- #
176
187
test_expect_success ' Check format "relative" date fields output' '
177
188
f=relative &&
178
189
(git for-each-ref --shell --format="%(refname) %(committerdate:$f) %(authordate:$f)" refs/heads &&
179
190
git for-each-ref --shell --format="%(refname) %(taggerdate:$f)" refs/tags) >actual
180
191
'
181
192
182
- cat > expected << \EOF
183
- 'refs/heads/master' '2006-07-03' '2006-07-03'
184
- 'refs/tags/testtag' '2006-07-03'
185
- EOF
186
-
187
193
test_expect_success ' Check format "short" date fields output' '
188
- f=short &&
189
- (git for-each-ref --shell --format="%(refname) %(committerdate:$f) %(authordate:$f)" refs/heads &&
190
- git for-each-ref --shell --format="%(refname) %(taggerdate:$f)" refs/tags) >actual &&
191
- test_cmp expected actual
194
+ test_date short 2006-07-03 2006-07-03 2006-07-03
192
195
'
193
196
194
- cat > expected << \EOF
195
- 'refs/heads/master' 'Mon Jul 3 15:18:43 2006' 'Mon Jul 3 15:18:44 2006'
196
- 'refs/tags/testtag' 'Mon Jul 3 15:18:45 2006'
197
- EOF
198
-
199
197
test_expect_success ' Check format "local" date fields output' '
200
- f= local &&
201
- (git for-each-ref --shell --format="%(refname) %(committerdate:$f) %(authordate:$f)" refs/heads &&
202
- git for-each-ref --shell --format="%(refname) %(taggerdate:$f)" refs/tags) >actual &&
203
- test_cmp expected actual
198
+ test_date local \
199
+ "Mon Jul 3 15:18:43 2006" \
200
+ "Mon Jul 3 15:18:44 2006" \
201
+ "Mon Jul 3 15:18:45 2006"
204
202
'
205
203
206
- cat > expected << \EOF
207
- 'refs/heads/master' '2006-07-03 17:18:43 +0200' '2006-07-03 17:18:44 +0200'
208
- 'refs/tags/testtag' '2006-07-03 17:18:45 +0200'
209
- EOF
210
-
211
204
test_expect_success ' Check format "iso8601" date fields output' '
212
- f= iso8601 &&
213
- (git for-each-ref --shell --format="%(refname) %(committerdate:$f) %(authordate:$f)" refs/heads &&
214
- git for-each-ref --shell --format="%(refname) %(taggerdate:$f)" refs/tags) >actual &&
215
- test_cmp expected actual
205
+ test_date iso8601 \
206
+ "2006-07-03 17:18:43 +0200" \
207
+ "2006-07-03 17:18:44 +0200" \
208
+ "2006-07-03 17:18:45 +0200"
216
209
'
217
210
218
- cat > expected << \EOF
219
- 'refs/heads/master' 'Mon, 3 Jul 2006 17:18:43 +0200' 'Mon, 3 Jul 2006 17:18:44 +0200'
220
- 'refs/tags/testtag' 'Mon, 3 Jul 2006 17:18:45 +0200'
221
- EOF
222
-
223
211
test_expect_success ' Check format "rfc2822" date fields output' '
224
- f= rfc2822 &&
225
- (git for-each-ref --shell --format="%(refname) %(committerdate:$f) %(authordate:$f)" refs/heads &&
226
- git for-each-ref --shell --format="%(refname) %(taggerdate:$f)" refs/tags) >actual &&
227
- test_cmp expected actual
212
+ test_date rfc2822 \
213
+ "Mon, 3 Jul 2006 17:18:43 +0200" \
214
+ "Mon, 3 Jul 2006 17:18:44 +0200" \
215
+ "Mon, 3 Jul 2006 17:18:45 +0200"
228
216
'
229
217
230
218
test_expect_success ' Check format of strftime date fields' '
0 commit comments