File tree Expand file tree Collapse file tree 3 files changed +51
-0
lines changed Expand file tree Collapse file tree 3 files changed +51
-0
lines changed Original file line number Diff line number Diff line change @@ -110,6 +110,9 @@ tar.<format>.command::
110
110
to the command (e.g., "-9"). An output file with the same
111
111
extension as `<format>` will be use this format if no other
112
112
format is given.
113
+ +
114
+ The "tar.gz" and "tgz" formats are defined automatically and default to
115
+ `gzip -cn`. You may override them with custom commands.
113
116
114
117
ATTRIBUTES
115
118
----------
@@ -143,6 +146,14 @@ git archive --format=tar --prefix=git-1.4.0/ v1.4.0 | gzip >git-1.4.0.tar.gz::
143
146
144
147
Create a compressed tarball for v1.4.0 release.
145
148
149
+ git archive --format=tar.gz --prefix=git-1.4.0/ v1.4.0 >git-1.4.0.tar.gz::
150
+
151
+ Same as above, but using the builtin tar.gz handling.
152
+
153
+ git archive --prefix=git-1.4.0/ -o git-1.4.0.tar.gz v1.4.0::
154
+
155
+ Same as above, but the format is inferred from the output file.
156
+
146
157
git archive --format=tar --prefix=git-1.4.0/ v1.4.0{caret}\{tree\} | gzip >git-1.4.0.tar.gz::
147
158
148
159
Create a compressed tarball for v1.4.0 release, but without a
Original file line number Diff line number Diff line change @@ -357,6 +357,8 @@ void init_tar_archiver(void)
357
357
int i ;
358
358
register_archiver (& tar_archiver );
359
359
360
+ tar_filter_config ("tar.tgz.command" , "gzip -cn" , NULL );
361
+ tar_filter_config ("tar.tar.gz.command" , "gzip -cn" , NULL );
360
362
git_config (git_tar_config , NULL );
361
363
for (i = 0 ; i < nr_tar_filters ; i ++ ) {
362
364
/* omit any filters that never had a command configured */
Original file line number Diff line number Diff line change @@ -26,6 +26,8 @@ commit id embedding:
26
26
27
27
. ./test-lib.sh
28
28
UNZIP=${UNZIP:- unzip}
29
+ GZIP=${GZIP:- gzip}
30
+ GUNZIP=${GUNZIP:- gzip -d}
29
31
30
32
SUBSTFORMAT=%H%n
31
33
@@ -295,4 +297,40 @@ test_expect_success 'extension matching requires dot' '
295
297
test_cmp b.tar config-implicittar.foo
296
298
'
297
299
300
+ if $GZIP --version > /dev/null 2>&1 ; then
301
+ test_set_prereq GZIP
302
+ else
303
+ say " Skipping some tar.gz tests because gzip not found"
304
+ fi
305
+
306
+ test_expect_success GZIP ' git archive --format=tgz' '
307
+ git archive --format=tgz HEAD >j.tgz
308
+ '
309
+
310
+ test_expect_success GZIP ' git archive --format=tar.gz' '
311
+ git archive --format=tar.gz HEAD >j1.tar.gz &&
312
+ test_cmp j.tgz j1.tar.gz
313
+ '
314
+
315
+ test_expect_success GZIP ' infer tgz from .tgz filename' '
316
+ git archive --output=j2.tgz HEAD &&
317
+ test_cmp j.tgz j2.tgz
318
+ '
319
+
320
+ test_expect_success GZIP ' infer tgz from .tar.gz filename' '
321
+ git archive --output=j3.tar.gz HEAD &&
322
+ test_cmp j.tgz j3.tar.gz
323
+ '
324
+
325
+ if $GUNZIP --version > /dev/null 2>&1 ; then
326
+ test_set_prereq GUNZIP
327
+ else
328
+ say " Skipping some tar.gz tests because gunzip was not found"
329
+ fi
330
+
331
+ test_expect_success GZIP,GUNZIP ' extract tgz file' '
332
+ $GUNZIP -c <j.tgz >j.tar &&
333
+ test_cmp b.tar j.tar
334
+ '
335
+
298
336
test_done
You can’t perform that action at this time.
0 commit comments