Download raw body.
Supress progress for update and checkout
On Fri, Sep 10, 2021 at 03:00:39PM -0600, Tracey Emery wrote:
> On Fri, Sep 10, 2021 at 10:42:44PM +0200, Stefan Sperling wrote:
> > On Fri, Sep 10, 2021 at 02:25:27PM -0600, Tracey Emery wrote:
> > > Hello,
> > >
> > > The following supresses the output for update and checkout. Running
> > > these commands on large repos makes the terminal unusable.
> > >
> > > This simply adds a couple of new callbacks that don't printf output.
> > >
> > > Is there a better way to do this, or ok?
> >
> > I would stick a new 'verbosity' flag into struct got_checkout_progress_arg
> > and struct got_update_progress_arg. Let it default to zero and set it to -1
> > if -q is used. The callbacks can then check for upa->verbosity >= 0 before
> > printing things. That would match how 'fetch' and 'clone' handle this.
>
> Much simpler.
>
Hold, that's not right either.
> --
>
> Tracey Emery
>
> diff 0e33f8e0becf732ab33b3ce78c026790a651a5f9 /home/tracey/src/got
> blob - 02e13d54951c31a8f0e635a8f07be977d6861681
> file + got/got.1
> --- got/got.1
> +++ got/got.1
> @@ -493,7 +493,7 @@ and Git's garbage collector.
> .It Cm fe
> Short alias for
> .Cm fetch .
> -.It Cm checkout Oo Fl E Oc Oo Fl b Ar branch Oc Oo Fl c Ar commit Oc Oo Fl p Ar path-prefix Oc Ar repository-path Op Ar work-tree-path
> +.It Cm checkout Oo Fl E Oc Oo Fl b Ar branch Oc Oo Fl c Ar commit Oc Oo Fl p Ar path-prefix Oc Oo Fl q Oc Ar repository-path Op Ar work-tree-path
> Copy files from a repository into a new work tree.
> Show the status of each affected file, using the following status codes:
> .Bl -column YXZ description
> @@ -553,11 +553,13 @@ Restrict the work tree to a subset of the repository's
> Only files beneath the specified
> .Ar path-prefix
> will be checked out.
> +.It Fl q
> +Silence progress output.
> .El
> .It Cm co
> Short alias for
> .Cm checkout .
> -.It Cm update Oo Fl b Ar branch Oc Oo Fl c Ar commit Oc Op Ar path ...
> +.It Cm update Oo Fl b Ar branch Oc Oo Fl c Ar commit Oc Oo Fl q Oc Op Ar path ...
> Update an existing work tree to a different
> .Ar commit .
> Change existing files in the work tree as necessary to match file contents
> @@ -650,6 +652,8 @@ An abbreviated hash argument will be expanded to a ful
> automatically, provided the abbreviation is unique.
> If this option is not specified, the most recent commit on the work tree's
> branch will be used.
> +.It Fl q
> +Silence progress output.
> .El
> .It Cm up
> Short alias for
> blob - 51bedeed3942da484d0dfe4614307f848dcbd5ed
> file + got/got.c
> --- got/got.c
> +++ got/got.c
> @@ -2638,7 +2638,8 @@ __dead static void
> usage_checkout(void)
> {
> fprintf(stderr, "usage: %s checkout [-E] [-b branch] [-c commit] "
> - "[-p prefix] repository-path [worktree-path]\n", getprogname());
> + "[-p prefix] [-q] repository-path [worktree-path]\n",
> + getprogname());
> exit(1);
> }
>
> @@ -2655,6 +2656,7 @@ show_worktree_base_ref_warning(void)
> struct got_checkout_progress_arg {
> const char *worktree_path;
> int had_base_commit_ref_error;
> + int verbose;
> };
>
> static const struct got_error *
> @@ -2674,7 +2676,8 @@ checkout_progress(void *arg, unsigned char status, con
> while (path[0] == '/')
> path++;
>
> - printf("%c %s/%s\n", status, a->worktree_path, path);
> + if (a->verbose)
> + printf("%c %s/%s\n", status, a->worktree_path, path);
> return NULL;
> }
>
> @@ -2828,13 +2831,13 @@ cmd_checkout(int argc, char *argv[])
> const char *branch_name = GOT_REF_HEAD;
> char *commit_id_str = NULL;
> char *cwd = NULL;
> - int ch, same_path_prefix, allow_nonempty = 0;
> + int ch, same_path_prefix, allow_nonempty = 0, verbose = 1;
> struct got_pathlist_head paths;
> struct got_checkout_progress_arg cpa;
>
> TAILQ_INIT(&paths);
>
> - while ((ch = getopt(argc, argv, "b:c:Ep:")) != -1) {
> + while ((ch = getopt(argc, argv, "b:c:Ep:q")) != -1) {
> switch (ch) {
> case 'b':
> branch_name = optarg;
> @@ -2850,6 +2853,9 @@ cmd_checkout(int argc, char *argv[])
> case 'p':
> path_prefix = optarg;
> break;
> + case 'q':
> + verbose = 0;
> + break;
> default:
> usage_checkout();
> /* NOTREACHED */
> @@ -3002,6 +3008,7 @@ cmd_checkout(int argc, char *argv[])
> goto done;
> cpa.worktree_path = worktree_path;
> cpa.had_base_commit_ref_error = 0;
> + cpa.verbose = verbose;
> error = got_worktree_checkout_files(worktree, &paths, repo,
> checkout_progress, &cpa, check_cancelled, NULL);
> if (error != NULL)
> @@ -3024,6 +3031,7 @@ struct got_update_progress_arg {
> int conflicts;
> int obstructed;
> int not_updated;
> + int verbose;
> };
>
> void
> @@ -3045,7 +3053,8 @@ print_update_progress_stats(struct got_update_progress
> __dead static void
> usage_update(void)
> {
> - fprintf(stderr, "usage: %s update [-b branch] [-c commit] [path ...]\n",
> + fprintf(stderr, "usage: %s update [-b branch] [-c commit] [-q] "
> + "[path ...]\n",
> getprogname());
> exit(1);
> }
> @@ -3074,7 +3083,8 @@ update_progress(void *arg, unsigned char status, const
>
> while (path[0] == '/')
> path++;
> - printf("%c %s\n", status, path);
> + if (upa->verbose)
> + printf("%c %s\n", status, path);
> return NULL;
> }
>
> @@ -3203,12 +3213,12 @@ cmd_update(int argc, char *argv[])
> struct got_reference *head_ref = NULL;
> struct got_pathlist_head paths;
> struct got_pathlist_entry *pe;
> - int ch;
> + int ch, verbose = 1;
> struct got_update_progress_arg upa;
>
> TAILQ_INIT(&paths);
>
> - while ((ch = getopt(argc, argv, "b:c:")) != -1) {
> + while ((ch = getopt(argc, argv, "b:c:q")) != -1) {
> switch (ch) {
> case 'b':
> branch_name = optarg;
> @@ -3218,6 +3228,9 @@ cmd_update(int argc, char *argv[])
> if (commit_id_str == NULL)
> return got_error_from_errno("strdup");
> break;
> + case 'q':
> + verbose = 0;
> + break;
> default:
> usage_update();
> /* NOTREACHED */
> @@ -3339,6 +3352,7 @@ cmd_update(int argc, char *argv[])
> }
>
> memset(&upa, 0, sizeof(upa));
> + upa.verbose = verbose;
> error = got_worktree_checkout_files(worktree, &paths, repo,
> update_progress, &upa, check_cancelled, NULL);
> if (error != NULL)
--
Tracey Emery
Supress progress for update and checkout