{"thread":{"id":"6890","subject":"[PATCH] fetch & clone: do not output progress when not on a tty","startedAt":"2007-02-20T02:01:44Z","lastAt":"2007-02-20T02:01:44Z","messageCount":1,"participants":["Johannes Schindelin"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"35078","messageId":"Pine.LNX.4.63.0702200259520.22628@wbgn013.biozentrum.uni-wuerzburg.de","threadId":"6890","inReplyTo":null,"subject":"[PATCH] fetch & clone: do not output progress when not on a tty","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2007-02-20T02:01:44Z","receivedAt":"2007-02-20T02:01:44Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"\nThis adds the option \"--no-progress\" to fetch-pack and upload-pack,\nand makes fetch and clone pass this option when stdout is not a tty.\n\nWhile at documenting that option, also document --strict and --timeout\noptions for upload-pack.\n\nSigned-off-by: Johannes Schindelin <Johannes.Schindelin@gmx.de>\n---\n\n\tAs promised, this is a working version of the patch I sent out \n\tearlier. Another late-night patch. But I tested this, and it seems \n\tto work properly.\n\n Documentation/git-fetch-pack.txt  |    5 ++++-\n Documentation/git-upload-pack.txt |   12 +++++++++++-\n fetch-pack.c                      |   16 +++++++++++++---\n git-clone.sh                      |    6 ++++--\n git-fetch.sh                      |    5 ++++-\n upload-pack.c                     |   24 +++++++++++++++++++-----\n 6 files changed, 55 insertions(+), 13 deletions(-)\n\ndiff --git a/Documentation/git-fetch-pack.txt b/Documentation/git-fetch-pack.txt\nindex 105d76b..a99a5b3 100644\n--- a/Documentation/git-fetch-pack.txt\n+++ b/Documentation/git-fetch-pack.txt\n@@ -8,7 +8,7 @@ git-fetch-pack - Receive missing objects from another repository\n \n SYNOPSIS\n --------\n-'git-fetch-pack' [--all] [--quiet|-q] [--keep|-k] [--thin] [--upload-pack=<git-upload-pack>] [--depth=<n>] [-v] [<host>:]<directory> [<refs>...]\n+'git-fetch-pack' [--all] [--quiet|-q] [--keep|-k] [--thin] [--upload-pack=<git-upload-pack>] [--depth=<n>] [--no-progress] [-v] [<host>:]<directory> [<refs>...]\n \n DESCRIPTION\n -----------\n@@ -63,6 +63,9 @@ OPTIONS\n \\--depth=<n>::\n \tLimit fetching to ancestor-chains not longer than n.\n \n+\\--no-progress::\n+\tDo not show the progress.\n+\n \\-v::\n \tRun verbosely.\n \ndiff --git a/Documentation/git-upload-pack.txt b/Documentation/git-upload-pack.txt\nindex 9da062d..c75c86e 100644\n--- a/Documentation/git-upload-pack.txt\n+++ b/Documentation/git-upload-pack.txt\n@@ -8,7 +8,7 @@ git-upload-pack - Send objects packed back to git-fetch-pack\n \n SYNOPSIS\n --------\n-'git-upload-pack' <directory>\n+'git-upload-pack' [--strict] [--timeout=<n>] [--no-progress] <directory>\n \n DESCRIPTION\n -----------\n@@ -23,6 +23,16 @@ repository.  For push operations, see 'git-send-pack'.\n \n OPTIONS\n -------\n+\n+\\--strict::\n+\tDo not try <directory>/.git/ if <directory> is no git directory.\n+\n+\\--timeout=<n>::\n+\tInterrupt transfer after <n> seconds of inactivity.\n+\n+\\--no-progress::\n+\tDo not show the progress.\n+\n <directory>::\n \tThe repository to sync from.\n \ndiff --git a/fetch-pack.c b/fetch-pack.c\nindex c787106..fc6b4e0 100644\n--- a/fetch-pack.c\n+++ b/fetch-pack.c\n@@ -15,8 +15,9 @@ static int quiet;\n static int verbose;\n static int fetch_all;\n static int depth;\n+static int no_progress;\n static const char fetch_pack_usage[] =\n-\"git-fetch-pack [--all] [--quiet|-q] [--keep|-k] [--thin] [--upload-pack=<git-upload-pack>] [--depth=<n>] [-v] [<host>:]<directory> [<refs>...]\";\n+\"git-fetch-pack [--all] [--quiet|-q] [--keep|-k] [--thin] [--upload-pack=<git-upload-pack>] [--depth=<n>] [--no-progress] [-v] [<host>:]<directory> [<refs>...]\";\n static const char *uploadpack = \"git-upload-pack\";\n \n #define COMPLETE\t(1U << 0)\n@@ -521,7 +522,7 @@ static int get_pack(int xd[2])\n \tif (do_keep) {\n \t\t*av++ = \"index-pack\";\n \t\t*av++ = \"--stdin\";\n-\t\tif (!quiet)\n+\t\tif (!quiet && !no_progress)\n \t\t\t*av++ = \"-v\";\n \t\tif (use_thin_pack)\n \t\t\t*av++ = \"--fix-thin\";\n@@ -718,6 +719,10 @@ int main(int argc, char **argv)\n \t\t\t\t\tst.st_mtime = 0;\n \t\t\t\tcontinue;\n \t\t\t}\n+\t\t\tif (!strcmp(\"--no-progress\", arg)) {\n+\t\t\t\tno_progress = 1;\n+\t\t\t\tcontinue;\n+\t\t\t}\n \t\t\tusage(fetch_pack_usage);\n \t\t}\n \t\tdest = arg;\n@@ -727,7 +732,12 @@ int main(int argc, char **argv)\n \t}\n \tif (!dest)\n \t\tusage(fetch_pack_usage);\n-\tpid = git_connect(fd, dest, uploadpack);\n+\tif (no_progress) {\n+\t\tchar buf[256];\n+\t\tsnprintf(buf, sizeof(buf), \"%s --no-progress\", uploadpack);\n+\t\tpid = git_connect(fd, dest, buf);\n+\t} else\n+\t\tpid = git_connect(fd, dest, uploadpack);\n \tif (pid < 0)\n \t\treturn 1;\n \tif (heads && nr_heads)\ndiff --git a/git-clone.sh b/git-clone.sh\nindex 1bd54de..86890ea 100755\n--- a/git-clone.sh\n+++ b/git-clone.sh\n@@ -79,6 +79,8 @@ origin=\n origin_override=\n use_separate_remote=t\n depth=\n+no_progress=\n+test -t 1 || no_progress=--no-progress\n while\n \tcase \"$#,$1\" in\n \t0,*) break ;;\n@@ -290,8 +292,8 @@ yes,yes)\n \t\t;;\n \t*)\n \t\tcase \"$upload_pack\" in\n-\t\t'') git-fetch-pack --all -k $quiet $depth \"$repo\" ;;\n-\t\t*) git-fetch-pack --all -k $quiet \"$upload_pack\" $depth \"$repo\" ;;\n+\t\t'') git-fetch-pack --all -k $quiet $depth $no_progress \"$repo\";;\n+\t\t*) git-fetch-pack --all -k $quiet \"$upload_pack\" $depth $no_progress \"$repo\" ;;\n \t\tesac >\"$GIT_DIR/CLONE_HEAD\" ||\n \t\t\tdie \"fetch-pack from '$repo' failed.\"\n \t\t;;\ndiff --git a/git-fetch.sh b/git-fetch.sh\nindex d230995..5d3fec0 100755\n--- a/git-fetch.sh\n+++ b/git-fetch.sh\n@@ -24,6 +24,8 @@ update_head_ok=\n exec=\n keep=\n shallow_depth=\n+no_progress=\n+test -t 1 || no_progress=--no-progress\n while case \"$#\" in 0) break ;; esac\n do\n \tcase \"$1\" in\n@@ -386,7 +388,8 @@ fetch_main () {\n     ( : subshell because we muck with IFS\n       IFS=\" \t$LF\"\n       (\n-\t  git-fetch-pack --thin $exec $keep $shallow_depth \"$remote\" $rref ||\n+\t  git-fetch-pack --thin $exec $keep $shallow_depth $no_progress \\\n+\t\t\"$remote\" $rref ||\n \t  echo failed \"$remote\"\n       ) |\n       (\ndiff --git a/upload-pack.c b/upload-pack.c\nindex 3648aae..4eb21cf 100644\n--- a/upload-pack.c\n+++ b/upload-pack.c\n@@ -10,7 +10,7 @@\n #include \"revision.h\"\n #include \"list-objects.h\"\n \n-static const char upload_pack_usage[] = \"git-upload-pack [--strict] [--timeout=nn] <dir>\";\n+static const char upload_pack_usage[] = \"git-upload-pack [--strict] [--timeout=nn] [--no-progress] <dir>\";\n \n /* bits #0..7 in revision.h, #8..10 in commit.c */\n #define THEY_HAVE\t(1u << 11)\n@@ -26,7 +26,7 @@ static const char upload_pack_usage[] = \"git-upload-pack [--strict] [--timeout=n\n static unsigned long oldest_have;\n \n static int multi_ack, nr_our_refs;\n-static int use_thin_pack, use_ofs_delta;\n+static int use_thin_pack, use_ofs_delta, no_progress;\n static struct object_array have_obj;\n static struct object_array want_obj;\n static unsigned int timeout;\n@@ -164,6 +164,9 @@ static void create_pack_file(void)\n \t\tdie(\"git-upload-pack: unable to fork git-pack-objects\");\n \t}\n \tif (!pid_pack_objects) {\n+\t\tchar *argv[10];\n+\t\tint i = 0;\n+\n \t\tdup2(lp_pipe[0], 0);\n \t\tdup2(pu_pipe[1], 1);\n \t\tdup2(pe_pipe[1], 2);\n@@ -174,9 +177,16 @@ static void create_pack_file(void)\n \t\tclose(pu_pipe[1]);\n \t\tclose(pe_pipe[0]);\n \t\tclose(pe_pipe[1]);\n-\t\texecl_git_cmd(\"pack-objects\", \"--stdout\", \"--progress\",\n-\t\t\t      use_ofs_delta ? \"--delta-base-offset\" : NULL,\n-\t\t\t      NULL);\n+\n+\t\targv[i++] = \"pack-objects\";\n+\t\targv[i++] = \"--stdout\";\n+\t\tif (!no_progress)\n+\t\t\targv[i++] = \"--progress\";\n+\t\tif (use_ofs_delta)\n+\t\t\targv[i++] = \"--delta-base-offset\";\n+\t\targv[i++] = NULL;\n+\n+\t\texecv_git_cmd(argv);\n \t\tkill(pid_rev_list, SIGKILL);\n \t\tdie(\"git-upload-pack: unable to exec git-pack-objects\");\n \t}\n@@ -660,6 +670,10 @@ int main(int argc, char **argv)\n \t\t\ttimeout = atoi(arg+10);\n \t\t\tcontinue;\n \t\t}\n+\t\tif (!strcmp(arg, \"--no-progress\")) {\n+\t\t\tno_progress = 1;\n+\t\t\tcontinue;\n+\t\t}\n \t\tif (!strcmp(arg, \"--\")) {\n \t\t\ti++;\n \t\t\tbreak;\n-- \n1.5.0.1.2140.gcfff-dirty\n"}]}