Skip to content

Commit 01437ba

Browse files
committed
git-gc: pass --progress down to git-repack
1 parent 1f261e1 commit 01437ba

File tree

3 files changed

+20
-4
lines changed

3 files changed

+20
-4
lines changed

Documentation/git-gc.txt

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ git-gc - Cleanup unnecessary files and optimize the local repository
99
SYNOPSIS
1010
--------
1111
[verse]
12-
'git gc' [--aggressive] [--auto] [--quiet] [--prune=<date> | --no-prune]
12+
'git gc' [--aggressive] [--auto] [--quiet] [--progress] [--prune=<date> | --no-prune]
1313

1414
DESCRIPTION
1515
-----------
@@ -69,7 +69,14 @@ automatic consolidation of packs.
6969
Do not prune any loose objects.
7070

7171
--quiet::
72-
Suppress all progress reports.
72+
Suppress all progress reports. Progress is not reported to
73+
the standard error stream.
74+
75+
--progress::
76+
Progress status is reported on the standard error stream
77+
by default when it is attached to a terminal, unless -q
78+
is specified. This flag forces progress status even if the
79+
standard error stream is not directed to a terminal.
7380

7481
Configuration
7582
-------------

builtin/gc.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ static int gc_auto_threshold = 6700;
2828
static int gc_auto_pack_limit = 50;
2929
static const char *prune_expire = "2.weeks.ago";
3030

31-
#define MAX_ADD 10
31+
#define MAX_ADD 11
3232
static const char *argv_pack_refs[] = {"pack-refs", "--all", "--prune", NULL};
3333
static const char *argv_reflog[] = {"reflog", "expire", "--all", NULL};
3434
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)
177177
int aggressive = 0;
178178
int auto_gc = 0;
179179
int quiet = 0;
180+
int progress = 0;
180181
char buf[80];
181182

182183
struct option builtin_gc_options[] = {
183184
OPT__QUIET(&quiet, "suppress progress reporting"),
185+
OPT_BOOLEAN(0, "progress", &progress, "force progress reporting"),
184186
{ OPTION_STRING, 0, "prune", &prune_expire, "date",
185187
"prune unreferenced objects",
186188
PARSE_OPT_OPTARG, NULL, (intptr_t)prune_expire },
@@ -213,6 +215,9 @@ int cmd_gc(int argc, const char **argv, const char *prefix)
213215
if (quiet)
214216
append_option(argv_repack, "-q", MAX_ADD);
215217

218+
if (progress)
219+
append_option(argv_repack, "--progress", MAX_ADD);
220+
216221
if (auto_gc) {
217222
/*
218223
* Auto-gc should be least intrusive as possible.

contrib/examples/git-gc.sh

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,16 @@ SUBDIRECTORY_OK=Yes
99
. git-sh-setup
1010

1111
no_prune=:
12+
progress=
1213
while test $# != 0
1314
do
1415
case "$1" in
1516
--prune)
1617
no_prune=
1718
;;
19+
--progress)
20+
progress=--progress
21+
;;
1822
--)
1923
usage
2024
;;
@@ -32,6 +36,6 @@ esac
3236
test "true" != "$pack_refs" ||
3337
git pack-refs --prune &&
3438
git reflog expire --all &&
35-
git-repack -a -d -l &&
39+
git-repack -a -d -l $progress &&
3640
$no_prune git prune &&
3741
git rerere gc || exit

0 commit comments

Comments
 (0)