@matheusbsbs / matheus-bagliano / commits / 83a5ad6126
Fork 0

fetch & clone: do not output progress when not on a tty

This adds the option "--no-progress" to fetch-pack and upload-pack, and makes fetch and clone pass this option when stdout is not a tty. While at documenting that option, also document --strict and --timeout options for upload-pack. Signed-off-by: Johannes Schindelin <Johannes.Schindelin@gmx.de> Signed-off-by: Junio C Hamano <junkio@cox.net>

Johannes Schindelin committed Feb 20, 2007 at 03:01 UTC 83a5ad61268bbfea7e0d3180528366690f951554
6 files changed +55 -13
Documentation/git-fetch-pack.txt
+4 -1
@@ -8,7 +8,7 @@ git-fetch-pack - Receive missing objects from another repository
8
9 SYNOPSIS
10 --------
11 -'git-fetch-pack' [--all] [--quiet|-q] [--keep|-k] [--thin] [--upload-pack=<git-upload-pack>] [--depth=<n>] [-v] [<host>:]<directory> [<refs>...]
11 +'git-fetch-pack' [--all] [--quiet|-q] [--keep|-k] [--thin] [--upload-pack=<git-upload-pack>] [--depth=<n>] [--no-progress] [-v] [<host>:]<directory> [<refs>...]
12
13 DESCRIPTION
14 -----------
@@ -63,6 +63,9 @@ OPTIONS
63 \--depth=<n>::
64 Limit fetching to ancestor-chains not longer than n.
65
66 +\--no-progress::
67 + Do not show the progress.
68 +
69 \-v::
70 Run verbosely.
71
Documentation/git-upload-pack.txt
+11 -1
@@ -8,7 +8,7 @@ git-upload-pack - Send objects packed back to git-fetch-pack
8
9 SYNOPSIS
10 --------
11 -'git-upload-pack' <directory>
11 +'git-upload-pack' [--strict] [--timeout=<n>] [--no-progress] <directory>
12
13 DESCRIPTION
14 -----------
@@ -23,6 +23,16 @@ repository. For push operations, see 'git-send-pack'.
23
24 OPTIONS
25 -------
26 +
27 +\--strict::
28 + Do not try <directory>/.git/ if <directory> is no git directory.
29 +
30 +\--timeout=<n>::
31 + Interrupt transfer after <n> seconds of inactivity.
32 +
33 +\--no-progress::
34 + Do not show the progress.
35 +
36 <directory>::
37 The repository to sync from.
38
fetch-pack.c
+13 -3
@@ -15,8 +15,9 @@ static int quiet;
15 static int verbose;
16 static int fetch_all;
17 static int depth;
18 +static int no_progress;
19 static const char fetch_pack_usage[] =
19 -"git-fetch-pack [--all] [--quiet|-q] [--keep|-k] [--thin] [--upload-pack=<git-upload-pack>] [--depth=<n>] [-v] [<host>:]<directory> [<refs>...]";
20 +"git-fetch-pack [--all] [--quiet|-q] [--keep|-k] [--thin] [--upload-pack=<git-upload-pack>] [--depth=<n>] [--no-progress] [-v] [<host>:]<directory> [<refs>...]";
21 static const char *uploadpack = "git-upload-pack";
22
23 #define COMPLETE (1U << 0)
@@ -521,7 +522,7 @@ static int get_pack(int xd[2])
522 if (do_keep) {
523 *av++ = "index-pack";
524 *av++ = "--stdin";
524 - if (!quiet)
525 + if (!quiet && !no_progress)
526 *av++ = "-v";
527 if (use_thin_pack)
528 *av++ = "--fix-thin";
@@ -718,6 +719,10 @@ int main(int argc, char **argv)
719 st.st_mtime = 0;
720 continue;
721 }
722 + if (!strcmp("--no-progress", arg)) {
723 + no_progress = 1;
724 + continue;
725 + }
726 usage(fetch_pack_usage);
727 }
728 dest = arg;
@@ -727,7 +732,12 @@ int main(int argc, char **argv)
732 }
733 if (!dest)
734 usage(fetch_pack_usage);
730 - pid = git_connect(fd, dest, uploadpack);
735 + if (no_progress) {
736 + char buf[256];
737 + snprintf(buf, sizeof(buf), "%s --no-progress", uploadpack);
738 + pid = git_connect(fd, dest, buf);
739 + } else
740 + pid = git_connect(fd, dest, uploadpack);
741 if (pid < 0)
742 return 1;
743 if (heads && nr_heads)
git-clone.sh
+4 -2
@@ -79,6 +79,8 @@ origin=
79 origin_override=
80 use_separate_remote=t
81 depth=
82 +no_progress=
83 +test -t 1 || no_progress=--no-progress
84 while
85 case "$#,$1" in
86 0,*) break ;;
@@ -290,8 +292,8 @@ yes,yes)
292 ;;
293 *)
294 case "$upload_pack" in
293 - '') git-fetch-pack --all -k $quiet $depth "$repo" ;;
294 - *) git-fetch-pack --all -k $quiet "$upload_pack" $depth "$repo" ;;
295 + '') git-fetch-pack --all -k $quiet $depth $no_progress "$repo";;
296 + *) git-fetch-pack --all -k $quiet "$upload_pack" $depth $no_progress "$repo" ;;
297 esac >"$GIT_DIR/CLONE_HEAD" ||
298 die "fetch-pack from '$repo' failed."
299 ;;
git-fetch.sh
+4 -1
@@ -24,6 +24,8 @@ update_head_ok=
24 exec=
25 keep=
26 shallow_depth=
27 +no_progress=
28 +test -t 1 || no_progress=--no-progress
29 while case "$#" in 0) break ;; esac
30 do
31 case "$1" in
@@ -377,7 +379,8 @@ fetch_main () {
379 ( : subshell because we muck with IFS
380 IFS=" $LF"
381 (
380 - git-fetch-pack --thin $exec $keep $shallow_depth "$remote" $rref ||
382 + git-fetch-pack --thin $exec $keep $shallow_depth $no_progress \
383 + "$remote" $rref ||
384 echo failed "$remote"
385 ) |
386 (
upload-pack.c
+19 -5
@@ -10,7 +10,7 @@
10 #include "revision.h"
11 #include "list-objects.h"
12
13 -static const char upload_pack_usage[] = "git-upload-pack [--strict] [--timeout=nn] <dir>";
13 +static const char upload_pack_usage[] = "git-upload-pack [--strict] [--timeout=nn] [--no-progress] <dir>";
14
15 /* bits #0..7 in revision.h, #8..10 in commit.c */
16 #define THEY_HAVE (1u << 11)
@@ -26,7 +26,7 @@ static const char upload_pack_usage[] = "git-upload-pack [--strict] [--timeout=n
26 static unsigned long oldest_have;
27
28 static int multi_ack, nr_our_refs;
29 -static int use_thin_pack, use_ofs_delta;
29 +static int use_thin_pack, use_ofs_delta, no_progress;
30 static struct object_array have_obj;
31 static struct object_array want_obj;
32 static unsigned int timeout;
@@ -164,6 +164,9 @@ static void create_pack_file(void)
164 die("git-upload-pack: unable to fork git-pack-objects");
165 }
166 if (!pid_pack_objects) {
167 + const char *argv[10];
168 + int i = 0;
169 +
170 dup2(lp_pipe[0], 0);
171 dup2(pu_pipe[1], 1);
172 dup2(pe_pipe[1], 2);
@@ -174,9 +177,16 @@ static void create_pack_file(void)
177 close(pu_pipe[1]);
178 close(pe_pipe[0]);
179 close(pe_pipe[1]);
177 - execl_git_cmd("pack-objects", "--stdout", "--progress",
178 - use_ofs_delta ? "--delta-base-offset" : NULL,
179 - NULL);
180 +
181 + argv[i++] = "pack-objects";
182 + argv[i++] = "--stdout";
183 + if (!no_progress)
184 + argv[i++] = "--progress";
185 + if (use_ofs_delta)
186 + argv[i++] = "--delta-base-offset";
187 + argv[i++] = NULL;
188 +
189 + execv_git_cmd(argv);
190 kill(pid_rev_list, SIGKILL);
191 die("git-upload-pack: unable to exec git-pack-objects");
192 }
@@ -660,6 +670,10 @@ int main(int argc, char **argv)
670 timeout = atoi(arg+10);
671 continue;
672 }
673 + if (!strcmp(arg, "--no-progress")) {
674 + no_progress = 1;
675 + continue;
676 + }
677 if (!strcmp(arg, "--")) {
678 i++;
679 break;