git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] scalar: use verbose mode in clone

From
Taylor Blau <me@ttaylorr.com>
Date
Dec 7, 2022, 22:10 UTC
Message-ID
<Y5EPVpb511wk5Uw/@nand.local>
In-Reply-To
<pull.1441.git.1670436656379.gitgitgadget@gmail.com>
On Wed, Dec 07, 2022 at 06:10:56PM +0000, ZheNing Hu via GitGitGadget wrote:
> So add `[--verbose| -v]` to scalar clone, to enable
> fetch's output.
Seems reasonable.
Show 9 quoted lines
> @@ -84,6 +84,11 @@ cloning. If the HEAD at the remote did not point at any branch when
>  	A sparse-checkout is initialized by default. This behavior can be
>  	turned off via `--full-clone`.
>
> +-v::
> +--verbose::
> +	When scalar executes `git fetch`, `--quiet` is used by default to
> +	suppress the output of fetch, use verbose mode for cancel this.
> +

This description may be exposing a few too many implementation details for our liking. E.g., scalar happens to use `git fetch`, but it might not always. That is probably academic, but a more practical reason to do some hiding here might just be that it's unnecessary detail to expose in our documentation.

Perhaps something like:
    -v::
    --verbose::
     Enable more verbose output when cloning a repository.
Or something simple like that.
Show 24 quoted lines
>  List
>  ~~~~
>
> diff --git a/scalar.c b/scalar.c
> index 6c52243cdf1..b1d4504d136 100644
> --- a/scalar.c
> +++ b/scalar.c
> @@ -404,7 +404,7 @@ void load_builtin_commands(const char *prefix, struct cmdnames *cmds)
>  static int cmd_clone(int argc, const char **argv)
>  {
>  	const char *branch = NULL;
> -	int full_clone = 0, single_branch = 0;
> +	int full_clone = 0, single_branch = 0, verbosity = 0;
>  	struct option clone_options[] = {
>  		OPT_STRING('b', "branch", &branch, N_("<branch>"),
>  			   N_("branch to checkout after clone")),
> @@ -413,6 +413,7 @@ static int cmd_clone(int argc, const char **argv)
>  		OPT_BOOL(0, "single-branch", &single_branch,
>  			 N_("only download metadata for the branch that will "
>  			    "be checked out")),
> +		OPT__VERBOSITY(&verbosity),
>  		OPT_END(),
>  	};
>  	const char * const clone_usage[] = {
Looking good.
Show 8 quoted lines
> @@ -499,7 +500,9 @@ static int cmd_clone(int argc, const char **argv)
>  	if (set_recommended_config(0))
>  		return error(_("could not configure '%s'"), dir);
>
> -	if ((res = run_git("fetch", "--quiet", "origin", NULL))) {
> +	if ((res = run_git("fetch", "origin",
> +			   verbosity ? NULL : "--quiet",
> +			   NULL))) {

Hmmph. This and below are a little strange in that they will end up calling:

    run_git("fetch", "origin", NULL, NULL);

when running without `--verbose`. `run_git()` will still do the right thing and stop reading its arguments after the first NULL that it sees. So I doubt that it's a huge deal in practice, but felt worth calling out nonetheless.

Is there an opportunity to easily test this new code?

Thanks, Taylor

Previous: ZheNing Hu via GitGitGadgetNext: ZheNing Hu
Message 2 of 12 in “scalar: use verbose mode in clone”
  1. scalar: use verbose mode in cloneZheNing Hu via GitGitGadget, Dec 7, 2022
  2. Taylor BlauDec 7, 2022
  3. ZheNing HuDec 8, 2022
  4. Derrick StoleeDec 8, 2022
  5. ZheNing HuDec 13, 2022
  6. scalar: show progress if stderr refer to a terminalZheNing Hu via GitGitGadget, Dec 25, 2022
  7. Derrick StoleeJan 5, 2023
  8. Junio C HamanoJan 6, 2023
  9. ZheNing HuJan 11, 2023
  10. scalar: show progress if stderr refer to a terminalZheNing Hu via GitGitGadget, Jan 11, 2023
  11. Derrick StoleeJan 11, 2023
  12. Junio C HamanoJan 13, 2023

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.