Skip to content

Commit 8ff21b1

Browse files
René ScharfeJunio C Hamano
authored andcommitted
git-archive: make tar the default format
As noted by Junio, --format=tar should be assumed if no format was specified. Signed-off-by: Rene Scharfe <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 5bcbc7f commit 8ff21b1

File tree

3 files changed

+12
-5
lines changed

3 files changed

+12
-5
lines changed

Documentation/git-archive.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@ OPTIONS
3030
-------
3131

3232
--format=<fmt>::
33-
Format of the resulting archive: 'tar', 'zip'...
33+
Format of the resulting archive: 'tar', 'zip'... The default
34+
is 'tar'.
3435

3536
--list::
3637
Show all available formats.

builtin-archive.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ int parse_archive_args(int argc, const char **argv, struct archiver *ar)
149149
{
150150
const char *extra_argv[MAX_EXTRA_ARGS];
151151
int extra_argc = 0;
152-
const char *format = NULL; /* might want to default to "tar" */
152+
const char *format = "tar";
153153
const char *base = "";
154154
int verbose = 0;
155155
int i;
@@ -190,8 +190,6 @@ int parse_archive_args(int argc, const char **argv, struct archiver *ar)
190190
/* We need at least one parameter -- tree-ish */
191191
if (argc - 1 < i)
192192
usage(archive_usage);
193-
if (!format)
194-
die("You must specify an archive format");
195193
if (init_archiver(format, ar) < 0)
196194
die("Unknown archive format '%s'", format);
197195

t/t5000-tar-tree.sh

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,17 @@ test_expect_success \
4949
git-update-ref HEAD $(TZ=GMT GIT_COMMITTER_DATE="2005-05-27 22:00:00" \
5050
git-commit-tree $treeid </dev/null)'
5151

52+
test_expect_success \
53+
'git-archive' \
54+
'git-archive HEAD >b.tar'
55+
5256
test_expect_success \
5357
'git-tar-tree' \
54-
'git-tar-tree HEAD >b.tar'
58+
'git-tar-tree HEAD >b2.tar'
59+
60+
test_expect_success \
61+
'git-archive vs. git-tar-tree' \
62+
'diff b.tar b2.tar'
5563

5664
test_expect_success \
5765
'validate file modification time' \

0 commit comments

Comments
 (0)