commit 20e420c8b1505de5032e4c2672147483bd15d616 from: Stefan Sperling date: Mon Apr 11 13:33:54 2022 UTC add a -q (quiet) option to 'gotadmin pack' commit - fbafdecfb2616668a85d20ef641764749a229f7a commit + 20e420c8b1505de5032e4c2672147483bd15d616 blob - 997a10f0a2c6d6c9750ef3660207ac358a4d56ea blob + 80fd9074549181f88fa96e0b7e0ee1063bec0780 --- gotadmin/gotadmin.1 +++ 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 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 blob - 09d1ca1db98e99e774fa86e99f0212c6871c7fcb blob + fc67c23d9de31032415a5315451f590e9d291ed2 --- gotadmin/gotadmin.c +++ 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; @@ -647,6 +647,9 @@ cmd_pack(int argc, char *argv[]) optarg, NULL); if (error) return error; + break; + case 'q': + verbosity = -1; break; default: usage_pack(); @@ -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); blob - 943365b98b4c77208dff732937dfafcd5fe825a7 blob + f2acf22971de6d69864669240411b42ba43f58bc --- regress/cmdline/pack.sh +++ 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