Add --verbose to git-archive
And teach backends about it. Signed-off-by: Junio C Hamano <junkio@cox.net> (cherry picked from 9e2c44a2893ae90944a0b7c9f40a9d22b759b5c0 commit)
Junio C Hamano committed
Sep 9, 2006 at 22:42 UTC
e0ffb24877d4530208905512f7c91dd8d71e2c95
4 files changed
+16
-1
archive.h
+1
@@ -10,6 +10,7 @@ struct archiver_args {
10
const unsigned char *commit_sha1;
11
time_t time;
12
const char **pathspec;
13
+ unsigned int verbose : 1;
14
void *extra;
15
};
16
builtin-archive.c
+7
-1
@@ -12,7 +12,7 @@
12
#include "pkt-line.h"
13
14
static const char archive_usage[] = \
15
-"git-archive --format=<fmt> [--prefix=<prefix>/] [<extra>] <tree-ish> [path...]";
15
+"git-archive --format=<fmt> [--prefix=<prefix>/] [--verbose] [<extra>] <tree-ish> [path...]";
16
17
struct archiver archivers[] = {
18
{
@@ -148,6 +148,7 @@ int parse_archive_args(int argc, const char **argv, struct archiver *ar)
148
int extra_argc = 0;
149
const char *format = NULL; /* might want to default to "tar" */
150
const char *base = "";
151
+ int verbose = 0;
152
int i;
153
154
for (i = 1; i < argc; i++) {
@@ -158,6 +159,10 @@ int parse_archive_args(int argc, const char **argv, struct archiver *ar)
159
printf("%s\n", archivers[i].name);
160
exit(0);
161
}
162
+ if (!strcmp(arg, "--verbose") || !strcmp(arg, "-v")) {
163
+ verbose = 1;
164
+ continue;
165
+ }
166
if (!strncmp(arg, "--format=", 9)) {
167
format = arg + 9;
168
continue;
@@ -192,6 +197,7 @@ int parse_archive_args(int argc, const char **argv, struct archiver *ar)
197
die("%s", default_parse_extra(ar, extra_argv));
198
ar->args.extra = ar->parse_extra(extra_argc, extra_argv);
199
}
200
+ ar->args.verbose = verbose;
201
ar->args.base = base;
202
203
return i;
builtin-tar-tree.c
+4
@@ -22,6 +22,7 @@ static unsigned long offset;
22
23
static time_t archive_time;
24
static int tar_umask;
25
+static int verbose;
26
27
/* writes out the whole block, but only if it is full */
28
static void write_if_needed(void)
@@ -169,6 +170,8 @@ static void write_entry(const unsigned char *sha1, struct strbuf *path,
170
mode = 0100666;
171
sprintf(header.name, "%s.paxheader", sha1_to_hex(sha1));
172
} else {
173
+ if (verbose)
174
+ fprintf(stderr, "%.*s\n", path->len, path->buf);
175
if (S_ISDIR(mode)) {
176
*header.typeflag = TYPEFLAG_DIR;
177
mode = (mode | 0777) & ~tar_umask;
@@ -385,6 +388,7 @@ int write_tar_archive(struct archiver_args *args)
388
git_config(git_tar_config);
389
390
archive_time = args->time;
391
+ verbose = args->verbose;
392
393
if (args->commit_sha1)
394
write_global_extended_header(args->commit_sha1);
builtin-zip-tree.c
+4
@@ -13,6 +13,7 @@
13
static const char zip_tree_usage[] =
14
"git-zip-tree [-0|...|-9] <tree-ish> [ <base> ]";
15
16
+static int verbose;
17
static int zip_date;
18
static int zip_time;
19
@@ -164,6 +165,8 @@ static int write_zip_entry(const unsigned char *sha1,
165
crc = crc32(0, Z_NULL, 0);
166
167
path = construct_path(base, baselen, filename, S_ISDIR(mode), &pathlen);
168
+ if (verbose)
169
+ fprintf(stderr, "%s\n", path);
170
if (pathlen > 0xffff) {
171
error("path too long (%d chars, SHA1: %s): %s", pathlen,
172
sha1_to_hex(sha1), path);
@@ -361,6 +364,7 @@ int write_zip_archive(struct archiver_args *args)
364
365
zip_dir = xmalloc(ZIP_DIRECTORY_MIN_SIZE);
366
zip_dir_size = ZIP_DIRECTORY_MIN_SIZE;
367
+ verbose = args->verbose;
368
369
if (args->base && plen > 0 && args->base[plen - 1] == '/') {
370
char *base = xstrdup(args->base);