{"thread":{"id":"28513","subject":"[PATCH] add --progress to git-gc and git-repack","startedAt":"2011-09-27T20:32:45Z","lastAt":"2011-09-27T21:29:10Z","messageCount":2,"participants":["Oleg Andreev","Jeff King"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"176353","messageId":"9F9C752E-6B3C-401B-9E01-8B1F5544A82F@gmail.com","threadId":"28513","inReplyTo":null,"subject":"[PATCH] add --progress to git-gc and git-repack","fromName":"Oleg Andreev","fromEmail":"oleganza@gmail.com","sentAt":"2011-09-27T20:32:45Z","receivedAt":"2011-09-27T20:32:45Z","isPatch":true,"sender":{"key":"oleganza@gmail.com","avatar":null},"body":"Hello,\n\nHere are two patches adding --progress option to git-gc and git-repack.\n\nYou can also pull them from here: git://github.com/oleganza/git.git\n\nJust in case, if some spaces get corrupted, you can find the patches in the attachment.\n\n\n\nFrom 1f261e13e72770deabd77087e354f304be850efc Mon Sep 17 00:00:00 2001\nFrom: Oleg Andreev <oleganza@gmail.com>\nDate: Tue, 27 Sep 2011 08:24:25 +0200\nSubject: [PATCH 1/2] git-repack: pass --progress down to git-pack-objects\n\n---\n Documentation/git-repack.txt |    4 ++++\n git-repack.sh                |    6 ++++--\n 2 files changed, 8 insertions(+), 2 deletions(-)\n\ndiff --git a/Documentation/git-repack.txt b/Documentation/git-repack.txt\nindex 40af321..1c22076 100644\n--- a/Documentation/git-repack.txt\n+++ b/Documentation/git-repack.txt\n@@ -74,6 +74,10 @@ other objects in that pack they already have locally.\n \tPass the `-q` option to 'git pack-objects'. See\n \tlinkgit:git-pack-objects[1].\n \n+--progress::\n+\tPass the `--progress` option to 'git pack-objects'. See\n+\tlinkgit:git-pack-objects[1].\n+\n -n::\n \tDo not update the server information with\n \t'git update-server-info'.  This option skips\ndiff --git a/git-repack.sh b/git-repack.sh\nindex 624feec..b86d60e 100755\n--- a/git-repack.sh\n+++ b/git-repack.sh\n@@ -14,6 +14,7 @@ f               pass --no-reuse-delta to git-pack-objects\n F               pass --no-reuse-object to git-pack-objects\n n               do not run git-update-server-info\n q,quiet         be quiet\n+progress        pass --progress to git-pack-objects\n l               pass --local to git-pack-objects\n  Packing constraints\n window=         size of the window used for delta compression\n@@ -25,7 +26,7 @@ SUBDIRECTORY_OK='Yes'\n . git-sh-setup\n \n no_update_info= all_into_one= remove_redundant= unpack_unreachable=\n-local= no_reuse= extra=\n+local= no_reuse= extra= progress=\n while test $# != 0\n do\n \tcase \"$1\" in\n@@ -35,6 +36,7 @@ do\n \t\tunpack_unreachable=--unpack-unreachable ;;\n \t-d)\tremove_redundant=t ;;\n \t-q)\tGIT_QUIET=t ;;\n+\t--progress) progress=--progress ;;\n \t-f)\tno_reuse=--no-reuse-delta ;;\n \t-F)\tno_reuse=--no-reuse-object ;;\n \t-l)\tlocal=--local ;;\n@@ -85,7 +87,7 @@ esac\n mkdir -p \"$PACKDIR\" || exit\n \n args=\"$args $local ${GIT_QUIET:+-q} $no_reuse$extra\"\n-names=$(git pack-objects --keep-true-parents --honor-pack-keep --non-empty --all --reflog $args </dev/null \"$PACKTMP\") ||\n+names=$(git pack-objects --keep-true-parents --honor-pack-keep --non-empty --all --reflog $progress $args </dev/null \"$PACKTMP\") ||\n \texit 1\n if [ -z \"$names\" ]; then\n \tsay Nothing new to pack.\n-- \n1.7.6.1\n\n\n\nFrom 01437ba2785a23221f246c37f6ba317274bfa6f4 Mon Sep 17 00:00:00 2001\nFrom: Oleg Andreev <oleganza@gmail.com>\nDate: Tue, 27 Sep 2011 08:38:20 +0200\nSubject: [PATCH 2/2] git-gc: pass --progress down to git-repack\n\n---\n Documentation/git-gc.txt   |   11 +++++++++--\n builtin/gc.c               |    7 ++++++-\n contrib/examples/git-gc.sh |    6 +++++-\n 3 files changed, 20 insertions(+), 4 deletions(-)\n\ndiff --git a/Documentation/git-gc.txt b/Documentation/git-gc.txt\nindex 815afcb..b65fa3e 100644\n--- a/Documentation/git-gc.txt\n+++ b/Documentation/git-gc.txt\n@@ -9,7 +9,7 @@ git-gc - Cleanup unnecessary files and optimize the local repository\n SYNOPSIS\n --------\n [verse]\n-'git gc' [--aggressive] [--auto] [--quiet] [--prune=<date> | --no-prune]\n+'git gc' [--aggressive] [--auto] [--quiet] [--progress] [--prune=<date> | --no-prune]\n \n DESCRIPTION\n -----------\n@@ -69,7 +69,14 @@ automatic consolidation of packs.\n \tDo not prune any loose objects.\n \n --quiet::\n-\tSuppress all progress reports.\n+\tSuppress all progress reports. Progress is not reported to\n+\tthe standard error stream.\n+\n+--progress::\n+\tProgress status is reported on the standard error stream\n+\tby default when it is attached to a terminal, unless -q\n+\tis specified. This flag forces progress status even if the\n+\tstandard error stream is not directed to a terminal.\n \n Configuration\n -------------\ndiff --git a/builtin/gc.c b/builtin/gc.c\nindex 0498094..e146985 100644\n--- a/builtin/gc.c\n+++ b/builtin/gc.c\n@@ -28,7 +28,7 @@ static int gc_auto_threshold = 6700;\n static int gc_auto_pack_limit = 50;\n static const char *prune_expire = \"2.weeks.ago\";\n \n-#define MAX_ADD 10\n+#define MAX_ADD 11\n static const char *argv_pack_refs[] = {\"pack-refs\", \"--all\", \"--prune\", NULL};\n static const char *argv_reflog[] = {\"reflog\", \"expire\", \"--all\", NULL};\n static const char *argv_repack[MAX_ADD] = {\"repack\", \"-d\", \"-l\", NULL};\n@@ -177,10 +177,12 @@ int cmd_gc(int argc, const char **argv, const char *prefix)\n \tint aggressive = 0;\n \tint auto_gc = 0;\n \tint quiet = 0;\n+\tint progress = 0;\n \tchar buf[80];\n \n \tstruct option builtin_gc_options[] = {\n \t\tOPT__QUIET(&quiet, \"suppress progress reporting\"),\n+\t\tOPT_BOOLEAN(0, \"progress\", &progress, \"force progress reporting\"),\n \t\t{ OPTION_STRING, 0, \"prune\", &prune_expire, \"date\",\n \t\t\t\"prune unreferenced objects\",\n \t\t\tPARSE_OPT_OPTARG, NULL, (intptr_t)prune_expire },\n@@ -213,6 +215,9 @@ int cmd_gc(int argc, const char **argv, const char *prefix)\n \tif (quiet)\n \t\tappend_option(argv_repack, \"-q\", MAX_ADD);\n \n+\tif (progress)\n+\t\tappend_option(argv_repack, \"--progress\", MAX_ADD);\n+\n \tif (auto_gc) {\n \t\t/*\n \t\t * Auto-gc should be least intrusive as possible.\ndiff --git a/contrib/examples/git-gc.sh b/contrib/examples/git-gc.sh\nindex 1597e9f..52ea808 100755\n--- a/contrib/examples/git-gc.sh\n+++ b/contrib/examples/git-gc.sh\n@@ -9,12 +9,16 @@ SUBDIRECTORY_OK=Yes\n . git-sh-setup\n \n no_prune=:\n+progress=\n while test $# != 0\n do\n \tcase \"$1\" in\n \t--prune)\n \t\tno_prune=\n \t\t;;\n+\t--progress)\n+\t\tprogress=--progress\n+\t\t;;\n \t--)\n \t\tusage\n \t\t;;\n@@ -32,6 +36,6 @@ esac\n test \"true\" != \"$pack_refs\" ||\n git pack-refs --prune &&\n git reflog expire --all &&\n-git-repack -a -d -l &&\n+git-repack -a -d -l $progress &&\n $no_prune git prune &&\n git rerere gc || exit\n-- \n1.7.6.1\n\n\n\n\n\nFrom 1f261e13e72770deabd77087e354f304be850efc Mon Sep 17 00:00:00 2001\nFrom: Oleg Andreev <oleganza@gmail.com>\nDate: Tue, 27 Sep 2011 08:24:25 +0200\nSubject: [PATCH 1/2] git-repack: pass --progress down to git-pack-objects\n\n---\n Documentation/git-repack.txt |    4 ++++\n git-repack.sh                |    6 ++++--\n 2 files changed, 8 insertions(+), 2 deletions(-)\n\ndiff --git a/Documentation/git-repack.txt b/Documentation/git-repack.txt\nindex 40af321..1c22076 100644\n--- a/Documentation/git-repack.txt\n+++ b/Documentation/git-repack.txt\n@@ -74,6 +74,10 @@ other objects in that pack they already have locally.\n \tPass the `-q` option to 'git pack-objects'. See\n \tlinkgit:git-pack-objects[1].\n \n+--progress::\n+\tPass the `--progress` option to 'git pack-objects'. See\n+\tlinkgit:git-pack-objects[1].\n+\n -n::\n \tDo not update the server information with\n \t'git update-server-info'.  This option skips\ndiff --git a/git-repack.sh b/git-repack.sh\nindex 624feec..b86d60e 100755\n--- a/git-repack.sh\n+++ b/git-repack.sh\n@@ -14,6 +14,7 @@ f               pass --no-reuse-delta to git-pack-objects\n F               pass --no-reuse-object to git-pack-objects\n n               do not run git-update-server-info\n q,quiet         be quiet\n+progress        pass --progress to git-pack-objects\n l               pass --local to git-pack-objects\n  Packing constraints\n window=         size of the window used for delta compression\n@@ -25,7 +26,7 @@ SUBDIRECTORY_OK='Yes'\n . git-sh-setup\n \n no_update_info= all_into_one= remove_redundant= unpack_unreachable=\n-local= no_reuse= extra=\n+local= no_reuse= extra= progress=\n while test $# != 0\n do\n \tcase \"$1\" in\n@@ -35,6 +36,7 @@ do\n \t\tunpack_unreachable=--unpack-unreachable ;;\n \t-d)\tremove_redundant=t ;;\n \t-q)\tGIT_QUIET=t ;;\n+\t--progress) progress=--progress ;;\n \t-f)\tno_reuse=--no-reuse-delta ;;\n \t-F)\tno_reuse=--no-reuse-object ;;\n \t-l)\tlocal=--local ;;\n@@ -85,7 +87,7 @@ esac\n mkdir -p \"$PACKDIR\" || exit\n \n args=\"$args $local ${GIT_QUIET:+-q} $no_reuse$extra\"\n-names=$(git pack-objects --keep-true-parents --honor-pack-keep --non-empty --all --reflog $args </dev/null \"$PACKTMP\") ||\n+names=$(git pack-objects --keep-true-parents --honor-pack-keep --non-empty --all --reflog $progress $args </dev/null \"$PACKTMP\") ||\n \texit 1\n if [ -z \"$names\" ]; then\n \tsay Nothing new to pack.\n-- \n1.7.6.1\n\n\n\nFrom 01437ba2785a23221f246c37f6ba317274bfa6f4 Mon Sep 17 00:00:00 2001\nFrom: Oleg Andreev <oleganza@gmail.com>\nDate: Tue, 27 Sep 2011 08:38:20 +0200\nSubject: [PATCH 2/2] git-gc: pass --progress down to git-repack\n\n---\n Documentation/git-gc.txt   |   11 +++++++++--\n builtin/gc.c               |    7 ++++++-\n contrib/examples/git-gc.sh |    6 +++++-\n 3 files changed, 20 insertions(+), 4 deletions(-)\n\ndiff --git a/Documentation/git-gc.txt b/Documentation/git-gc.txt\nindex 815afcb..b65fa3e 100644\n--- a/Documentation/git-gc.txt\n+++ b/Documentation/git-gc.txt\n@@ -9,7 +9,7 @@ git-gc - Cleanup unnecessary files and optimize the local repository\n SYNOPSIS\n --------\n [verse]\n-'git gc' [--aggressive] [--auto] [--quiet] [--prune=<date> | --no-prune]\n+'git gc' [--aggressive] [--auto] [--quiet] [--progress] [--prune=<date> | --no-prune]\n \n DESCRIPTION\n -----------\n@@ -69,7 +69,14 @@ automatic consolidation of packs.\n \tDo not prune any loose objects.\n \n --quiet::\n-\tSuppress all progress reports.\n+\tSuppress all progress reports. Progress is not reported to\n+\tthe standard error stream.\n+\n+--progress::\n+\tProgress status is reported on the standard error stream\n+\tby default when it is attached to a terminal, unless -q\n+\tis specified. This flag forces progress status even if the\n+\tstandard error stream is not directed to a terminal.\n \n Configuration\n -------------\ndiff --git a/builtin/gc.c b/builtin/gc.c\nindex 0498094..e146985 100644\n--- a/builtin/gc.c\n+++ b/builtin/gc.c\n@@ -28,7 +28,7 @@ static int gc_auto_threshold = 6700;\n static int gc_auto_pack_limit = 50;\n static const char *prune_expire = \"2.weeks.ago\";\n \n-#define MAX_ADD 10\n+#define MAX_ADD 11\n static const char *argv_pack_refs[] = {\"pack-refs\", \"--all\", \"--prune\", NULL};\n static const char *argv_reflog[] = {\"reflog\", \"expire\", \"--all\", NULL};\n static const char *argv_repack[MAX_ADD] = {\"repack\", \"-d\", \"-l\", NULL};\n@@ -177,10 +177,12 @@ int cmd_gc(int argc, const char **argv, const char *prefix)\n \tint aggressive = 0;\n \tint auto_gc = 0;\n \tint quiet = 0;\n+\tint progress = 0;\n \tchar buf[80];\n \n \tstruct option builtin_gc_options[] = {\n \t\tOPT__QUIET(&quiet, \"suppress progress reporting\"),\n+\t\tOPT_BOOLEAN(0, \"progress\", &progress, \"force progress reporting\"),\n \t\t{ OPTION_STRING, 0, \"prune\", &prune_expire, \"date\",\n \t\t\t\"prune unreferenced objects\",\n \t\t\tPARSE_OPT_OPTARG, NULL, (intptr_t)prune_expire },\n@@ -213,6 +215,9 @@ int cmd_gc(int argc, const char **argv, const char *prefix)\n \tif (quiet)\n \t\tappend_option(argv_repack, \"-q\", MAX_ADD);\n \n+\tif (progress)\n+\t\tappend_option(argv_repack, \"--progress\", MAX_ADD);\n+\n \tif (auto_gc) {\n \t\t/*\n \t\t * Auto-gc should be least intrusive as possible.\ndiff --git a/contrib/examples/git-gc.sh b/contrib/examples/git-gc.sh\nindex 1597e9f..52ea808 100755\n--- a/contrib/examples/git-gc.sh\n+++ b/contrib/examples/git-gc.sh\n@@ -9,12 +9,16 @@ SUBDIRECTORY_OK=Yes\n . git-sh-setup\n \n no_prune=:\n+progress=\n while test $# != 0\n do\n \tcase \"$1\" in\n \t--prune)\n \t\tno_prune=\n \t\t;;\n+\t--progress)\n+\t\tprogress=--progress\n+\t\t;;\n \t--)\n \t\tusage\n \t\t;;\n@@ -32,6 +36,6 @@ esac\n test \"true\" != \"$pack_refs\" ||\n git pack-refs --prune &&\n git reflog expire --all &&\n-git-repack -a -d -l &&\n+git-repack -a -d -l $progress &&\n $no_prune git prune &&\n git rerere gc || exit\n-- \n1.7.6.1\n\n\n\n\n\n"},{"id":"176356","messageId":"20110927212910.GA5176@sigill.intra.peff.net","threadId":"28513","inReplyTo":"9F9C752E-6B3C-401B-9E01-8B1F5544A82F@gmail.com","subject":"Re: [PATCH] add --progress to git-gc and git-repack","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2011-09-27T21:29:10Z","receivedAt":"2011-09-27T21:29:10Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Tue, Sep 27, 2011 at 10:32:45PM +0200, Oleg Andreev wrote:\n\n> From 1f261e13e72770deabd77087e354f304be850efc Mon Sep 17 00:00:00 2001\n> From: Oleg Andreev <oleganza@gmail.com>\n> Date: Tue, 27 Sep 2011 08:24:25 +0200\n> Subject: [PATCH 1/2] git-repack: pass --progress down to git-pack-objects\n\nPlease follow Documentation/SubmittingPatches.  This should be part of\nthe actual email headers. And there should be one patch per email.\n\nMy first thought was \"doesn't git-repack already show progress?\".\nThere's no motivation in the commit message, so I have to guess why you\nwant this. I assume you want to override the isatty(2) decision that\npack-objects uses?\n\n> diff --git a/git-repack.sh b/git-repack.sh\n> index 624feec..b86d60e 100755\n> --- a/git-repack.sh\n> +++ b/git-repack.sh\n> [...]\n> @@ -35,6 +36,7 @@ do\n>  \t\tunpack_unreachable=--unpack-unreachable ;;\n>  \t-d)\tremove_redundant=t ;;\n>  \t-q)\tGIT_QUIET=t ;;\n> +\t--progress) progress=--progress ;;\n>  \t-f)\tno_reuse=--no-reuse-delta ;;\n>  \t-F)\tno_reuse=--no-reuse-object ;;\n>  \t-l)\tlocal=--local ;;\n\nShould this also handle --no-progress? Maybe it is not a big deal, as\n\"-q\" will also suppress progress, but it would be consistent with other\ngit commands that take --progress.\n\n> diff --git a/Documentation/git-gc.txt b/Documentation/git-gc.txt\n> index 815afcb..b65fa3e 100644\n> --- a/Documentation/git-gc.txt\n> +++ b/Documentation/git-gc.txt\n> [...]\n>  --quiet::\n> -\tSuppress all progress reports.\n> +\tSuppress all progress reports. Progress is not reported to\n> +\tthe standard error stream.\n\nThis just seems redundant to me.\n\n> +--progress::\n> +\tProgress status is reported on the standard error stream\n> +\tby default when it is attached to a terminal, unless -q\n> +\tis specified. This flag forces progress status even if the\n> +\tstandard error stream is not directed to a terminal.\n\nThough this is a nice description.\n\n> --- a/builtin/gc.c\n> +++ b/builtin/gc.c\n>  \tstruct option builtin_gc_options[] = {\n>  \t\tOPT__QUIET(&quiet, \"suppress progress reporting\"),\n> +\t\tOPT_BOOLEAN(0, \"progress\", &progress, \"force progress reporting\"),\n\nThis will handle --no-progress for us automatically, which is good.\n\n> diff --git a/contrib/examples/git-gc.sh b/contrib/examples/git-gc.sh\n> index 1597e9f..52ea808 100755\n> --- a/contrib/examples/git-gc.sh\n> +++ b/contrib/examples/git-gc.sh\n> [...]\n>  while test $# != 0\n>  do\n>  \tcase \"$1\" in\n>  \t--prune)\n>  \t\tno_prune=\n>  \t\t;;\n> +\t--progress)\n> +\t\tprogress=--progress\n> +\t\t;;\n\nThis won't, but I think this whole hunk is unnecessary. The files in\ncontrib/examples are kept around for people to see how git commands can\nbe composed of plumbing building blocks. But they don't need to gain new\nfeatures as their C counterparts do. I think we can just leave them\nfrozen in time as of when each script was rewritten in C.\n\n-Peff\n"}]}