git-archive: make tar the default format
authorRené Scharfe <rene.scharfe@lsrfire.ath.cx>
Mon, 9 Apr 2007 15:12:53 +0000 (17:12 +0200)
committerJunio C Hamano <junkio@cox.net>
Tue, 10 Apr 2007 01:51:40 +0000 (18:51 -0700)
As noted by Junio, --format=tar should be assumed if no format
was specified.

Signed-off-by: Rene Scharfe <rene.scharfe@lsrfire.ath.cx>
Signed-off-by: Junio C Hamano <junkio@cox.net>
Documentation/git-archive.txt
builtin-archive.c
t/t5000-tar-tree.sh
index 493474b2eeabb2f7928b0e9f91cfd1ff64763a6d..8d1041598e566a3ffc87cbe294c7800be1ab0c60 100644 (file)
@@ -30,7 +30,8 @@ OPTIONS
 -------
 
 --format=<fmt>::
-       Format of the resulting archive: 'tar', 'zip'...
+       Format of the resulting archive: 'tar', 'zip'...  The default
+       is 'tar'.
 
 --list::
        Show all available formats.
index 8ea6cb1efc4f988fb09051852f9e51fc88b5efd7..7f4e409c998ba4a864bd39032556d71693ff6793 100644 (file)
@@ -149,7 +149,7 @@ int parse_archive_args(int argc, const char **argv, struct archiver *ar)
 {
        const char *extra_argv[MAX_EXTRA_ARGS];
        int extra_argc = 0;
-       const char *format = NULL; /* might want to default to "tar" */
+       const char *format = "tar";
        const char *base = "";
        int verbose = 0;
        int i;
@@ -190,8 +190,6 @@ int parse_archive_args(int argc, const char **argv, struct archiver *ar)
        /* We need at least one parameter -- tree-ish */
        if (argc - 1 < i)
                usage(archive_usage);
-       if (!format)
-               die("You must specify an archive format");
        if (init_archiver(format, ar) < 0)
                die("Unknown archive format '%s'", format);
 
index b4359df795483691e61452366add69a212347723..e223c074f043571ff868a2f4783c7cc155185004 100755 (executable)
@@ -49,9 +49,17 @@ test_expect_success \
      git-update-ref HEAD $(TZ=GMT GIT_COMMITTER_DATE="2005-05-27 22:00:00" \
      git-commit-tree $treeid </dev/null)'
 
+test_expect_success \
+    'git-archive' \
+    'git-archive HEAD >b.tar'
+
 test_expect_success \
     'git-tar-tree' \
-    'git-tar-tree HEAD >b.tar'
+    'git-tar-tree HEAD >b2.tar'
+
+test_expect_success \
+    'git-archive vs. git-tar-tree' \
+    'diff b.tar b2.tar'
 
 test_expect_success \
     'validate file modification time' \