add a -q (quiet) option to 'gotadmin pack'
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112
diff --git a/gotadmin/gotadmin.1 b/gotadmin/gotadmin.1
index 997a10f..80fd907 100644
--- a/gotadmin/gotadmin.1
+++ b/gotadmin/gotadmin.1
@@ -72,7 +72,7 @@ If this directory is a
.Xr got 1
work tree, use the repository path associated with this work tree.
.El
-.It Cm pack Oo Fl a Oc Oo Fl r Ar repository-path Oc Oo Fl x Ar reference Oc Op Ar reference ...
+.It Cm pack Oo Fl a Oc Oo Fl r Ar repository-path Oc Oo Fl x Ar reference Oc Oo Fl q Oc Op Ar reference ...
Generate a new pack file and a corresponding pack file index.
By default, add any loose objects which are reachable via any references
to the generated pack file.
@@ -122,6 +122,8 @@ option may be specified multiple times to build a list of references to exclude.
Exclusion takes precedence over inclusion.
If a reference appears in both the included and excluded lists, it will
be excluded.
+.It Fl q
+Suppress progress reporting output.
.El
.Tg ix
.It Cm indexpack Ar packfile-path
diff --git a/gotadmin/gotadmin.c b/gotadmin/gotadmin.c
index 09d1ca1..fc67c23 100644
--- a/gotadmin/gotadmin.c
+++ b/gotadmin/gotadmin.c
@@ -614,7 +614,7 @@ cmd_pack(int argc, char *argv[])
const struct got_error *error = NULL;
char *repo_path = NULL;
struct got_repository *repo = NULL;
- int ch, i, loose_obj_only = 1;
+ int ch, i, loose_obj_only = 1, verbosity = 0;
struct got_object_id *pack_hash = NULL;
char *id_str = NULL;
struct got_pack_progress_arg ppa;
@@ -629,7 +629,7 @@ cmd_pack(int argc, char *argv[])
TAILQ_INIT(&exclude_refs);
TAILQ_INIT(&include_refs);
- while ((ch = getopt(argc, argv, "ar:x:")) != -1) {
+ while ((ch = getopt(argc, argv, "ar:x:q")) != -1) {
switch (ch) {
case 'a':
loose_obj_only = 0;
@@ -648,6 +648,9 @@ cmd_pack(int argc, char *argv[])
if (error)
return error;
break;
+ case 'q':
+ verbosity = -1;
+ break;
default:
usage_pack();
/* NOTREACHED */
@@ -713,6 +716,7 @@ cmd_pack(int argc, char *argv[])
ppa.last_scaled_size[0] = '\0';
ppa.last_p_indexed = -1;
ppa.last_p_resolved = -1;
+ ppa.verbosity = verbosity;
error = got_repo_pack_objects(&packfile, &pack_hash,
&include_refs, &exclude_refs, repo, loose_obj_only,
@@ -726,13 +730,15 @@ cmd_pack(int argc, char *argv[])
error = got_object_id_str(&id_str, pack_hash);
if (error)
goto done;
- printf("\nWrote %s.pack\n", id_str);
+ if (verbosity >= 0)
+ printf("\nWrote %s.pack\n", id_str);
error = got_repo_index_pack(packfile, pack_hash, repo,
pack_index_progress, &ppa, check_cancelled, NULL);
if (error)
goto done;
- printf("\nIndexed %s.pack\n", id_str);
+ if (verbosity >= 0)
+ printf("\nIndexed %s.pack\n", id_str);
done:
if (repo)
got_repo_close(repo);
diff --git a/regress/cmdline/pack.sh b/regress/cmdline/pack.sh
index 943365b..f2acf22 100755
--- a/regress/cmdline/pack.sh
+++ b/regress/cmdline/pack.sh
@@ -409,8 +409,7 @@ test_pack_ambiguous_arg() {
(cd $testroot/wt && got commit -m "edit alpha" >/dev/null)
local commit1=`git_show_branch_head $testroot/repo mybranch`
- gotadmin pack -r $testroot/repo -x master master \
- > /dev/null 2> $testroot/stderr
+ gotadmin pack -q -r $testroot/repo -x master master 2> $testroot/stderr
ret=$?
if [ $ret -eq 0 ]; then
echo "gotadmin pack succeeded unexpectedly" >&2
@@ -467,7 +466,7 @@ test_pack_loose_only() {
# pack objects belonging to the 'master' branch; its objects
# should then be excluded while packing 'mybranch' since they
# are already packed
- gotadmin pack -r $testroot/repo master > /dev/null
+ gotadmin pack -q -r $testroot/repo master
ret=$?
if [ $ret -ne 0 ]; then
echo "gotadmin pack failed unexpectedly" >&2
@@ -574,7 +573,7 @@ test_pack_all_objects() {
(cd $testroot/wt && got commit -m "edit alpha" >/dev/null)
# pack objects belonging to the 'master' branch
- gotadmin pack -r $testroot/repo master > /dev/null
+ gotadmin pack -q -r $testroot/repo master
ret=$?
if [ $ret -ne 0 ]; then
echo "gotadmin pack failed unexpectedly" >&2