Skip to contentSkip to conversation

git-archive: make tar the default format

PATCH New René Scharfe 1 participant 1 message Jun 15, 2016 Documentation

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 git-archive: make tar the default format

As noted by Junio, --format=tar should be assumed if no format was specified.

---
 Documentation/git-archive.txt |    3 ++-
 builtin-archive.c             |    4 +---
 t/t5000-tar-tree.sh           |   10 +++++++++-
 3 files changed, 12 insertions(+), 5 deletions(-)
Documentation/git-archive.txt +2 -1
index 493474b..8d10415 100644
@@ -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.
builtin-archive.c +1 -3
index 8ea6cb1..7f4e409 100644
@@ -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);
 
t/t5000-tar-tree.sh +9 -1
index b4359df..e223c07 100755
@@ -50,8 +50,16 @@ test_expect_success \
      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' \
Signature · 1 line
1.5.1.53.g77e6f