summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJunio C Hamano <junkio@cox.net>2006-09-09 22:42:02 -0700
committerJunio C Hamano <junkio@cox.net>2006-09-10 13:39:25 -0700
commite0ffb24877d4530208905512f7c91dd8d71e2c95 (patch)
treedf9d8046b159c0b2418e2a04c9eacb007517a936
parent8142f603b9955648228549d2e83ace7fbe834114 (diff)
downloadgit-e0ffb24877d4530208905512f7c91dd8d71e2c95.tar.gz
Add --verbose to git-archive
And teach backends about it. Signed-off-by: Junio C Hamano <junkio@cox.net> (cherry picked from 9e2c44a2893ae90944a0b7c9f40a9d22b759b5c0 commit)
-rw-r--r--archive.h1
-rw-r--r--builtin-archive.c8
-rw-r--r--builtin-tar-tree.c4
-rw-r--r--builtin-zip-tree.c4
4 files changed, 16 insertions, 1 deletions
diff --git a/archive.h b/archive.h
index e0782b9dcf..16dcdb875c 100644
--- a/archive.h
+++ b/archive.h
@@ -10,6 +10,7 @@ struct archiver_args {
const unsigned char *commit_sha1;
time_t time;
const char **pathspec;
+ unsigned int verbose : 1;
void *extra;
};
diff --git a/builtin-archive.c b/builtin-archive.c
index 3a8be57e15..7544ad3ca1 100644
--- a/builtin-archive.c
+++ b/builtin-archive.c
@@ -12,7 +12,7 @@
#include "pkt-line.h"
static const char archive_usage[] = \
-"git-archive --format=<fmt> [--prefix=<prefix>/] [<extra>] <tree-ish> [path...]";
+"git-archive --format=<fmt> [--prefix=<prefix>/] [--verbose] [<extra>] <tree-ish> [path...]";
struct archiver archivers[] = {
{
@@ -148,6 +148,7 @@ int parse_archive_args(int argc, const char **argv, struct archiver *ar)
int extra_argc = 0;
const char *format = NULL; /* might want to default to "tar" */
const char *base = "";
+ int verbose = 0;
int i;
for (i = 1; i < argc; i++) {
@@ -158,6 +159,10 @@ int parse_archive_args(int argc, const char **argv, struct archiver *ar)
printf("%s\n", archivers[i].name);
exit(0);
}
+ if (!strcmp(arg, "--verbose") || !strcmp(arg, "-v")) {
+ verbose = 1;
+ continue;
+ }
if (!strncmp(arg, "--format=", 9)) {
format = arg + 9;
continue;
@@ -192,6 +197,7 @@ int parse_archive_args(int argc, const char **argv, struct archiver *ar)
die("%s", default_parse_extra(ar, extra_argv));
ar->args.extra = ar->parse_extra(extra_argc, extra_argv);
}
+ ar->args.verbose = verbose;
ar->args.base = base;
return i;
diff --git a/builtin-tar-tree.c b/builtin-tar-tree.c
index e8e492fa0f..f2679a8637 100644
--- a/builtin-tar-tree.c
+++ b/builtin-tar-tree.c
@@ -22,6 +22,7 @@ static unsigned long offset;
static time_t archive_time;
static int tar_umask;
+static int verbose;
/* writes out the whole block, but only if it is full */
static void write_if_needed(void)
@@ -169,6 +170,8 @@ static void write_entry(const unsigned char *sha1, struct strbuf *path,
mode = 0100666;
sprintf(header.name, "%s.paxheader", sha1_to_hex(sha1));
} else {
+ if (verbose)
+ fprintf(stderr, "%.*s\n", path->len, path->buf);
if (S_ISDIR(mode)) {
*header.typeflag = TYPEFLAG_DIR;
mode = (mode | 0777) & ~tar_umask;
@@ -385,6 +388,7 @@ int write_tar_archive(struct archiver_args *args)
git_config(git_tar_config);
archive_time = args->time;
+ verbose = args->verbose;
if (args->commit_sha1)
write_global_extended_header(args->commit_sha1);
diff --git a/builtin-zip-tree.c b/builtin-zip-tree.c
index fdac2bdd70..52d4b7a17e 100644
--- a/builtin-zip-tree.c
+++ b/builtin-zip-tree.c
@@ -13,6 +13,7 @@
static const char zip_tree_usage[] =
"git-zip-tree [-0|...|-9] <tree-ish> [ <base> ]";
+static int verbose;
static int zip_date;
static int zip_time;
@@ -164,6 +165,8 @@ static int write_zip_entry(const unsigned char *sha1,
crc = crc32(0, Z_NULL, 0);
path = construct_path(base, baselen, filename, S_ISDIR(mode), &pathlen);
+ if (verbose)
+ fprintf(stderr, "%s\n", path);
if (pathlen > 0xffff) {
error("path too long (%d chars, SHA1: %s): %s", pathlen,
sha1_to_hex(sha1), path);
@@ -361,6 +364,7 @@ int write_zip_archive(struct archiver_args *args)
zip_dir = xmalloc(ZIP_DIRECTORY_MIN_SIZE);
zip_dir_size = ZIP_DIRECTORY_MIN_SIZE;
+ verbose = args->verbose;
if (args->base && plen > 0 && args->base[plen - 1] == '/') {
char *base = xstrdup(args->base);