git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Junio C Hamano <junkio@cox.net>
To: Franck Bui-Huu <vagabon.xyz@gmail.com>
Cc: git@vger.kernel.org, Rene Scharfe <rene.scharfe@lsrfire.ath.cx>
Subject: [PATCH 2/2] Add --verbose to git-archive
Date: Sun, 10 Sep 2006 00:12:12 -0700	[thread overview]
Message-ID: <7vk64ctctv.fsf@assigned-by-dhcp.cox.net> (raw)
In-Reply-To: <7vpse4tcyc.fsf@assigned-by-dhcp.cox.net> (Junio C. Hamano's message of "Sun, 10 Sep 2006 00:09:31 -0700")

And teach backends about it.

Signed-off-by: Junio C Hamano <junkio@cox.net>
---
 * This is not interesting yet, and the output is discarded if
   you are running the remote archiver against git-daemon, but
   would be a useful progress indicator when we implement the
   side-band in git-archive protocol, which is probably a
   requirement before this "git-archive" series can graduate to
   "master" branch.

 archive.h          |    1 +
 builtin-archive.c  |    8 +++++++-
 builtin-tar-tree.c |    4 ++++
 builtin-zip-tree.c |    4 ++++
 4 files changed, 16 insertions(+), 1 deletions(-)

diff --git a/archive.h b/archive.h
index e0782b9..16dcdb8 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 c70488c..b78d6d8 100644
--- a/builtin-archive.c
+++ b/builtin-archive.c
@@ -12,7 +12,7 @@ #include "exec_cmd.h"
 #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 c
 	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 c
 				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 c
 			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 c20eb0e..fae2c0b 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 c
 		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_ar
 	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 4e79633..0ebd547 100644
--- a/builtin-zip-tree.c
+++ b/builtin-zip-tree.c
@@ -13,6 +13,7 @@ #include "archive.h"
 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 unsigne
 	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_ar
 
 	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 = strdup(args->base);
-- 
1.4.2.gc52f

  reply	other threads:[~2006-09-10  7:11 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-09-10  7:09 [PATCH 1/2] archive: allow remote to have more formats than we understand Junio C Hamano
2006-09-10  7:12 ` Junio C Hamano [this message]
2006-09-10 10:36   ` [PATCH 1/3] Move sideband client side support into reusable form Junio C Hamano
2006-09-10 19:15     ` Franck Bui-Huu
2006-09-10 10:37   ` [PATCH] Move sideband server " Junio C Hamano
2006-09-10 10:47   ` [PATCH 3/3] Add sideband status report to git-archive protocol Junio C Hamano
2006-09-10 15:58     ` [PATCH] git-upload-archive: add config option to allow only specified formats Rene Scharfe
2006-09-10 16:12       ` Rene Scharfe
2006-09-10 18:00       ` Junio C Hamano
2006-09-11 21:41         ` Rene Scharfe
2006-09-11 21:50           ` Jakub Narebski
2006-09-10 19:07       ` Franck Bui-Huu
2006-09-11 21:55         ` Rene Scharfe
2006-09-10 19:15     ` [PATCH 3/3] Add sideband status report to git-archive protocol Franck Bui-Huu
2006-09-10 20:31       ` Junio C Hamano
2006-09-11 10:34     ` Franck Bui-Huu
2006-09-12  7:24       ` Junio C Hamano
2006-09-12  8:17         ` Franck Bui-Huu
2006-09-12  8:45           ` Franck Bui-Huu
2006-09-12  9:00             ` [PATCH] connect.c: finish_connect(): allow null pid parameter Franck Bui-Huu
2006-09-13  4:48               ` Junio C Hamano
2006-09-13  8:26                 ` [PATCH] Test return value of finish_connect() Franck Bui-Huu
2006-09-13  8:32                 ` [PATCH] git_connect: change return type to pid_t Franck Bui-Huu
2006-09-12 23:44           ` [PATCH 3/3] Add sideband status report to git-archive protocol Junio C Hamano
2006-09-10 12:05 ` [PATCH 1/2] archive: allow remote to have more formats than we understand Rene Scharfe
2006-09-10 19:02 ` Franck Bui-Huu
2006-09-10 19:07   ` Junio C Hamano
2006-09-10 19:18     ` Franck Bui-Huu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=7vk64ctctv.fsf@assigned-by-dhcp.cox.net \
    --to=junkio@cox.net \
    --cc=git@vger.kernel.org \
    --cc=rene.scharfe@lsrfire.ath.cx \
    --cc=vagabon.xyz@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).