* [PATCH] add --progress to git-gc and git-repack
@ 2011-09-27 20:32 Oleg Andreev
2011-09-27 21:29 ` Jeff King
0 siblings, 1 reply; 2+ messages in thread
From: Oleg Andreev @ 2011-09-27 20:32 UTC (permalink / raw)
To: git, gitster
[-- Attachment #1: Type: text/plain, Size: 6019 bytes --]
Hello,
Here are two patches adding --progress option to git-gc and git-repack.
You can also pull them from here: git://github.com/oleganza/git.git
Just in case, if some spaces get corrupted, you can find the patches in the attachment.
From 1f261e13e72770deabd77087e354f304be850efc Mon Sep 17 00:00:00 2001
From: Oleg Andreev <oleganza@gmail.com>
Date: Tue, 27 Sep 2011 08:24:25 +0200
Subject: [PATCH 1/2] git-repack: pass --progress down to git-pack-objects
---
Documentation/git-repack.txt | 4 ++++
git-repack.sh | 6 ++++--
2 files changed, 8 insertions(+), 2 deletions(-)
diff --git a/Documentation/git-repack.txt b/Documentation/git-repack.txt
index 40af321..1c22076 100644
--- a/Documentation/git-repack.txt
+++ b/Documentation/git-repack.txt
@@ -74,6 +74,10 @@ other objects in that pack they already have locally.
Pass the `-q` option to 'git pack-objects'. See
linkgit:git-pack-objects[1].
+--progress::
+ Pass the `--progress` option to 'git pack-objects'. See
+ linkgit:git-pack-objects[1].
+
-n::
Do not update the server information with
'git update-server-info'. This option skips
diff --git a/git-repack.sh b/git-repack.sh
index 624feec..b86d60e 100755
--- a/git-repack.sh
+++ b/git-repack.sh
@@ -14,6 +14,7 @@ f pass --no-reuse-delta to git-pack-objects
F pass --no-reuse-object to git-pack-objects
n do not run git-update-server-info
q,quiet be quiet
+progress pass --progress to git-pack-objects
l pass --local to git-pack-objects
Packing constraints
window= size of the window used for delta compression
@@ -25,7 +26,7 @@ SUBDIRECTORY_OK='Yes'
. git-sh-setup
no_update_info= all_into_one= remove_redundant= unpack_unreachable=
-local= no_reuse= extra=
+local= no_reuse= extra= progress=
while test $# != 0
do
case "$1" in
@@ -35,6 +36,7 @@ do
unpack_unreachable=--unpack-unreachable ;;
-d) remove_redundant=t ;;
-q) GIT_QUIET=t ;;
+ --progress) progress=--progress ;;
-f) no_reuse=--no-reuse-delta ;;
-F) no_reuse=--no-reuse-object ;;
-l) local=--local ;;
@@ -85,7 +87,7 @@ esac
mkdir -p "$PACKDIR" || exit
args="$args $local ${GIT_QUIET:+-q} $no_reuse$extra"
-names=$(git pack-objects --keep-true-parents --honor-pack-keep --non-empty --all --reflog $args </dev/null "$PACKTMP") ||
+names=$(git pack-objects --keep-true-parents --honor-pack-keep --non-empty --all --reflog $progress $args </dev/null "$PACKTMP") ||
exit 1
if [ -z "$names" ]; then
say Nothing new to pack.
--
1.7.6.1
From 01437ba2785a23221f246c37f6ba317274bfa6f4 Mon Sep 17 00:00:00 2001
From: Oleg Andreev <oleganza@gmail.com>
Date: Tue, 27 Sep 2011 08:38:20 +0200
Subject: [PATCH 2/2] git-gc: pass --progress down to git-repack
---
Documentation/git-gc.txt | 11 +++++++++--
builtin/gc.c | 7 ++++++-
contrib/examples/git-gc.sh | 6 +++++-
3 files changed, 20 insertions(+), 4 deletions(-)
diff --git a/Documentation/git-gc.txt b/Documentation/git-gc.txt
index 815afcb..b65fa3e 100644
--- a/Documentation/git-gc.txt
+++ b/Documentation/git-gc.txt
@@ -9,7 +9,7 @@ git-gc - Cleanup unnecessary files and optimize the local repository
SYNOPSIS
--------
[verse]
-'git gc' [--aggressive] [--auto] [--quiet] [--prune=<date> | --no-prune]
+'git gc' [--aggressive] [--auto] [--quiet] [--progress] [--prune=<date> | --no-prune]
DESCRIPTION
-----------
@@ -69,7 +69,14 @@ automatic consolidation of packs.
Do not prune any loose objects.
--quiet::
- Suppress all progress reports.
+ Suppress all progress reports. Progress is not reported to
+ the standard error stream.
+
+--progress::
+ Progress status is reported on the standard error stream
+ by default when it is attached to a terminal, unless -q
+ is specified. This flag forces progress status even if the
+ standard error stream is not directed to a terminal.
Configuration
-------------
diff --git a/builtin/gc.c b/builtin/gc.c
index 0498094..e146985 100644
--- a/builtin/gc.c
+++ b/builtin/gc.c
@@ -28,7 +28,7 @@ static int gc_auto_threshold = 6700;
static int gc_auto_pack_limit = 50;
static const char *prune_expire = "2.weeks.ago";
-#define MAX_ADD 10
+#define MAX_ADD 11
static const char *argv_pack_refs[] = {"pack-refs", "--all", "--prune", NULL};
static const char *argv_reflog[] = {"reflog", "expire", "--all", NULL};
static const char *argv_repack[MAX_ADD] = {"repack", "-d", "-l", NULL};
@@ -177,10 +177,12 @@ int cmd_gc(int argc, const char **argv, const char *prefix)
int aggressive = 0;
int auto_gc = 0;
int quiet = 0;
+ int progress = 0;
char buf[80];
struct option builtin_gc_options[] = {
OPT__QUIET(&quiet, "suppress progress reporting"),
+ OPT_BOOLEAN(0, "progress", &progress, "force progress reporting"),
{ OPTION_STRING, 0, "prune", &prune_expire, "date",
"prune unreferenced objects",
PARSE_OPT_OPTARG, NULL, (intptr_t)prune_expire },
@@ -213,6 +215,9 @@ int cmd_gc(int argc, const char **argv, const char *prefix)
if (quiet)
append_option(argv_repack, "-q", MAX_ADD);
+ if (progress)
+ append_option(argv_repack, "--progress", MAX_ADD);
+
if (auto_gc) {
/*
* Auto-gc should be least intrusive as possible.
diff --git a/contrib/examples/git-gc.sh b/contrib/examples/git-gc.sh
index 1597e9f..52ea808 100755
--- a/contrib/examples/git-gc.sh
+++ b/contrib/examples/git-gc.sh
@@ -9,12 +9,16 @@ SUBDIRECTORY_OK=Yes
. git-sh-setup
no_prune=:
+progress=
while test $# != 0
do
case "$1" in
--prune)
no_prune=
;;
+ --progress)
+ progress=--progress
+ ;;
--)
usage
;;
@@ -32,6 +36,6 @@ esac
test "true" != "$pack_refs" ||
git pack-refs --prune &&
git reflog expire --all &&
-git-repack -a -d -l &&
+git-repack -a -d -l $progress &&
$no_prune git prune &&
git rerere gc || exit
--
1.7.6.1
[-- Attachment #2: 0001-git-repack-pass-progress-down-to-git-pack-objects.patch --]
[-- Type: application/octet-stream, Size: 2388 bytes --]
From 1f261e13e72770deabd77087e354f304be850efc Mon Sep 17 00:00:00 2001
From: Oleg Andreev <oleganza@gmail.com>
Date: Tue, 27 Sep 2011 08:24:25 +0200
Subject: [PATCH 1/2] git-repack: pass --progress down to git-pack-objects
---
Documentation/git-repack.txt | 4 ++++
git-repack.sh | 6 ++++--
2 files changed, 8 insertions(+), 2 deletions(-)
diff --git a/Documentation/git-repack.txt b/Documentation/git-repack.txt
index 40af321..1c22076 100644
--- a/Documentation/git-repack.txt
+++ b/Documentation/git-repack.txt
@@ -74,6 +74,10 @@ other objects in that pack they already have locally.
Pass the `-q` option to 'git pack-objects'. See
linkgit:git-pack-objects[1].
+--progress::
+ Pass the `--progress` option to 'git pack-objects'. See
+ linkgit:git-pack-objects[1].
+
-n::
Do not update the server information with
'git update-server-info'. This option skips
diff --git a/git-repack.sh b/git-repack.sh
index 624feec..b86d60e 100755
--- a/git-repack.sh
+++ b/git-repack.sh
@@ -14,6 +14,7 @@ f pass --no-reuse-delta to git-pack-objects
F pass --no-reuse-object to git-pack-objects
n do not run git-update-server-info
q,quiet be quiet
+progress pass --progress to git-pack-objects
l pass --local to git-pack-objects
Packing constraints
window= size of the window used for delta compression
@@ -25,7 +26,7 @@ SUBDIRECTORY_OK='Yes'
. git-sh-setup
no_update_info= all_into_one= remove_redundant= unpack_unreachable=
-local= no_reuse= extra=
+local= no_reuse= extra= progress=
while test $# != 0
do
case "$1" in
@@ -35,6 +36,7 @@ do
unpack_unreachable=--unpack-unreachable ;;
-d) remove_redundant=t ;;
-q) GIT_QUIET=t ;;
+ --progress) progress=--progress ;;
-f) no_reuse=--no-reuse-delta ;;
-F) no_reuse=--no-reuse-object ;;
-l) local=--local ;;
@@ -85,7 +87,7 @@ esac
mkdir -p "$PACKDIR" || exit
args="$args $local ${GIT_QUIET:+-q} $no_reuse$extra"
-names=$(git pack-objects --keep-true-parents --honor-pack-keep --non-empty --all --reflog $args </dev/null "$PACKTMP") ||
+names=$(git pack-objects --keep-true-parents --honor-pack-keep --non-empty --all --reflog $progress $args </dev/null "$PACKTMP") ||
exit 1
if [ -z "$names" ]; then
say Nothing new to pack.
--
1.7.6.1
[-- Attachment #3: 0002-git-gc-pass-progress-down-to-git-repack.patch --]
[-- Type: application/octet-stream, Size: 3372 bytes --]
From 01437ba2785a23221f246c37f6ba317274bfa6f4 Mon Sep 17 00:00:00 2001
From: Oleg Andreev <oleganza@gmail.com>
Date: Tue, 27 Sep 2011 08:38:20 +0200
Subject: [PATCH 2/2] git-gc: pass --progress down to git-repack
---
Documentation/git-gc.txt | 11 +++++++++--
builtin/gc.c | 7 ++++++-
contrib/examples/git-gc.sh | 6 +++++-
3 files changed, 20 insertions(+), 4 deletions(-)
diff --git a/Documentation/git-gc.txt b/Documentation/git-gc.txt
index 815afcb..b65fa3e 100644
--- a/Documentation/git-gc.txt
+++ b/Documentation/git-gc.txt
@@ -9,7 +9,7 @@ git-gc - Cleanup unnecessary files and optimize the local repository
SYNOPSIS
--------
[verse]
-'git gc' [--aggressive] [--auto] [--quiet] [--prune=<date> | --no-prune]
+'git gc' [--aggressive] [--auto] [--quiet] [--progress] [--prune=<date> | --no-prune]
DESCRIPTION
-----------
@@ -69,7 +69,14 @@ automatic consolidation of packs.
Do not prune any loose objects.
--quiet::
- Suppress all progress reports.
+ Suppress all progress reports. Progress is not reported to
+ the standard error stream.
+
+--progress::
+ Progress status is reported on the standard error stream
+ by default when it is attached to a terminal, unless -q
+ is specified. This flag forces progress status even if the
+ standard error stream is not directed to a terminal.
Configuration
-------------
diff --git a/builtin/gc.c b/builtin/gc.c
index 0498094..e146985 100644
--- a/builtin/gc.c
+++ b/builtin/gc.c
@@ -28,7 +28,7 @@ static int gc_auto_threshold = 6700;
static int gc_auto_pack_limit = 50;
static const char *prune_expire = "2.weeks.ago";
-#define MAX_ADD 10
+#define MAX_ADD 11
static const char *argv_pack_refs[] = {"pack-refs", "--all", "--prune", NULL};
static const char *argv_reflog[] = {"reflog", "expire", "--all", NULL};
static const char *argv_repack[MAX_ADD] = {"repack", "-d", "-l", NULL};
@@ -177,10 +177,12 @@ int cmd_gc(int argc, const char **argv, const char *prefix)
int aggressive = 0;
int auto_gc = 0;
int quiet = 0;
+ int progress = 0;
char buf[80];
struct option builtin_gc_options[] = {
OPT__QUIET(&quiet, "suppress progress reporting"),
+ OPT_BOOLEAN(0, "progress", &progress, "force progress reporting"),
{ OPTION_STRING, 0, "prune", &prune_expire, "date",
"prune unreferenced objects",
PARSE_OPT_OPTARG, NULL, (intptr_t)prune_expire },
@@ -213,6 +215,9 @@ int cmd_gc(int argc, const char **argv, const char *prefix)
if (quiet)
append_option(argv_repack, "-q", MAX_ADD);
+ if (progress)
+ append_option(argv_repack, "--progress", MAX_ADD);
+
if (auto_gc) {
/*
* Auto-gc should be least intrusive as possible.
diff --git a/contrib/examples/git-gc.sh b/contrib/examples/git-gc.sh
index 1597e9f..52ea808 100755
--- a/contrib/examples/git-gc.sh
+++ b/contrib/examples/git-gc.sh
@@ -9,12 +9,16 @@ SUBDIRECTORY_OK=Yes
. git-sh-setup
no_prune=:
+progress=
while test $# != 0
do
case "$1" in
--prune)
no_prune=
;;
+ --progress)
+ progress=--progress
+ ;;
--)
usage
;;
@@ -32,6 +36,6 @@ esac
test "true" != "$pack_refs" ||
git pack-refs --prune &&
git reflog expire --all &&
-git-repack -a -d -l &&
+git-repack -a -d -l $progress &&
$no_prune git prune &&
git rerere gc || exit
--
1.7.6.1
[-- Attachment #4: Type: text/plain, Size: 2 bytes --]
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] add --progress to git-gc and git-repack
2011-09-27 20:32 [PATCH] add --progress to git-gc and git-repack Oleg Andreev
@ 2011-09-27 21:29 ` Jeff King
0 siblings, 0 replies; 2+ messages in thread
From: Jeff King @ 2011-09-27 21:29 UTC (permalink / raw)
To: Oleg Andreev; +Cc: git, gitster
On Tue, Sep 27, 2011 at 10:32:45PM +0200, Oleg Andreev wrote:
> From 1f261e13e72770deabd77087e354f304be850efc Mon Sep 17 00:00:00 2001
> From: Oleg Andreev <oleganza@gmail.com>
> Date: Tue, 27 Sep 2011 08:24:25 +0200
> Subject: [PATCH 1/2] git-repack: pass --progress down to git-pack-objects
Please follow Documentation/SubmittingPatches. This should be part of
the actual email headers. And there should be one patch per email.
My first thought was "doesn't git-repack already show progress?".
There's no motivation in the commit message, so I have to guess why you
want this. I assume you want to override the isatty(2) decision that
pack-objects uses?
> diff --git a/git-repack.sh b/git-repack.sh
> index 624feec..b86d60e 100755
> --- a/git-repack.sh
> +++ b/git-repack.sh
> [...]
> @@ -35,6 +36,7 @@ do
> unpack_unreachable=--unpack-unreachable ;;
> -d) remove_redundant=t ;;
> -q) GIT_QUIET=t ;;
> + --progress) progress=--progress ;;
> -f) no_reuse=--no-reuse-delta ;;
> -F) no_reuse=--no-reuse-object ;;
> -l) local=--local ;;
Should this also handle --no-progress? Maybe it is not a big deal, as
"-q" will also suppress progress, but it would be consistent with other
git commands that take --progress.
> diff --git a/Documentation/git-gc.txt b/Documentation/git-gc.txt
> index 815afcb..b65fa3e 100644
> --- a/Documentation/git-gc.txt
> +++ b/Documentation/git-gc.txt
> [...]
> --quiet::
> - Suppress all progress reports.
> + Suppress all progress reports. Progress is not reported to
> + the standard error stream.
This just seems redundant to me.
> +--progress::
> + Progress status is reported on the standard error stream
> + by default when it is attached to a terminal, unless -q
> + is specified. This flag forces progress status even if the
> + standard error stream is not directed to a terminal.
Though this is a nice description.
> --- a/builtin/gc.c
> +++ b/builtin/gc.c
> struct option builtin_gc_options[] = {
> OPT__QUIET(&quiet, "suppress progress reporting"),
> + OPT_BOOLEAN(0, "progress", &progress, "force progress reporting"),
This will handle --no-progress for us automatically, which is good.
> diff --git a/contrib/examples/git-gc.sh b/contrib/examples/git-gc.sh
> index 1597e9f..52ea808 100755
> --- a/contrib/examples/git-gc.sh
> +++ b/contrib/examples/git-gc.sh
> [...]
> while test $# != 0
> do
> case "$1" in
> --prune)
> no_prune=
> ;;
> + --progress)
> + progress=--progress
> + ;;
This won't, but I think this whole hunk is unnecessary. The files in
contrib/examples are kept around for people to see how git commands can
be composed of plumbing building blocks. But they don't need to gain new
features as their C counterparts do. I think we can just leave them
frozen in time as of when each script was rewritten in C.
-Peff
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2011-09-27 21:29 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-09-27 20:32 [PATCH] add --progress to git-gc and git-repack Oleg Andreev
2011-09-27 21:29 ` Jeff King
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).