teach send-pack about --[no-]progress
authorJeff King <peff@peff.net>
Tue, 1 May 2012 08:42:24 +0000 (04:42 -0400)
committerJunio C Hamano <gitster@pobox.com>
Tue, 1 May 2012 16:40:30 +0000 (09:40 -0700)
The send_pack function gets a "progress" flag saying "yes,
definitely show progress" or "no, definitely do not show
progress". This gets set properly by transport_push when
send_pack is called directly.

However, when the send-pack command is executed separately
(as it is for the remote-curl helper), there is no way to
tell it "definitely do this". As a result, we do not
properly respect "git push --no-progress" for smart-http
remotes; you will still get progress if stderr is a tty.

This patch teaches send-pack --progress and --no-progress,
and teaches remote-curl to pass the appropriate option to
override send-pack's isatty check. This fixes the
--no-progress case above, and as a bonus, also makes "git
push --progress" work when stderr is not a tty.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/send-pack.c
remote-curl.c
index 7d2271563016528c07b581a77ccdc63f8d98799c..d5d7105ba2debde9fa6f2f33171d84cc7c25339a 100644 (file)
@@ -410,6 +410,7 @@ int cmd_send_pack(int argc, const char **argv, const char *prefix)
        const char *receivepack = "git-receive-pack";
        int flags;
        int nonfastforward = 0;
+       int progress = -1;
 
        argv++;
        for (i = 1; i < argc; i++, argv++) {
@@ -452,6 +453,14 @@ int cmd_send_pack(int argc, const char **argv, const char *prefix)
                                args.verbose = 1;
                                continue;
                        }
+                       if (!strcmp(arg, "--progress")) {
+                               progress = 1;
+                               continue;
+                       }
+                       if (!strcmp(arg, "--no-progress")) {
+                               progress = 0;
+                               continue;
+                       }
                        if (!strcmp(arg, "--thin")) {
                                args.use_thin_pack = 1;
                                continue;
@@ -492,8 +501,9 @@ int cmd_send_pack(int argc, const char **argv, const char *prefix)
                }
        }
 
-       if (!args.quiet)
-               args.progress = isatty(2);
+       if (progress == -1)
+               progress = !args.quiet && isatty(2);
+       args.progress = progress;
 
        if (args.stateless_rpc) {
                conn = NULL;
index d159fe7f3433ccf6e8c8908961736951e42b9c35..e5e9490be7b246e06a849b3d35485fc3a9903abe 100644 (file)
@@ -774,6 +774,7 @@ static int push_git(struct discovery *heads, int nr_spec, char **specs)
                argv[argc++] = "--quiet";
        else if (options.verbosity > 1)
                argv[argc++] = "--verbose";
+       argv[argc++] = options.progress ? "--progress" : "--no-progress";
        argv[argc++] = url;
        for (i = 0; i < nr_spec; i++)
                argv[argc++] = specs[i];