git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: "ZheNing Hu via GitGitGadget" <gitgitgadget@gmail.com>
To: git@vger.kernel.org
Cc: Junio C Hamano <gitster@pobox.com>,
	Derrick Stolee <derrickstolee@github.com>,
	Johannes Schindelin <johannes.schindelin@gmx.de>,
	Victoria Dye <vdye@github.com>,
	ZheNing Hu <adlternative@gmail.com>,
	ZheNing Hu <adlternative@gmail.com>
Subject: [PATCH] scalar: use verbose mode in clone
Date: Wed, 07 Dec 2022 18:10:56 +0000	[thread overview]
Message-ID: <pull.1441.git.1670436656379.gitgitgadget@gmail.com> (raw)

From: ZheNing Hu <adlternative@gmail.com>

Sometimes when users use scalar to download a monorepo
with a long commit history, they want to check the
progress bar to know how long they still need to wait
during the fetch process, but scalar suppresses this
output by default.

So add `[--verbose| -v]` to scalar clone, to enable
fetch's output.

Signed-off-by: ZheNing Hu <adlternative@gmail.com>
---
    scalar: use verbose mode in clone
    
    When users use scalar to download a monorepo with a long commit history
    (or the client and server network communication is very poor), we often
    need to spend a long time in the fetch phase of scalar, some users may
    want to check this progress bar To understand the progress of fetch and
    how long they have to wait, so we should enable scalar to display fetch
    progress.
    
    v1. add [--verbose| -v] to scalar clone.
    
    Note: output look like this:
    
    $ scalar clone -v git@github.com:git/git.git
    Initialized empty Git repository in /Users/adl/test/git/src/.git/
    remote: Enumerating objects: 209091, done.
    remote: Counting objects: 100% (991/991), done.
    remote: Compressing objects: 100% (944/944), done.
    Receiving objects: 100% (209085/209085), 81.39 MiB | 126.00 KiB/s, done.
    remote: Total 209085 (delta 54), reused 979 (delta 47), pack-reused 208094
    Resolving deltas: 100% (134000/134000), done.
    From github.com:git/git
     * [new branch]          jch         -> origin/jch
     * [new branch]          main        -> origin/main
     * [new branch]          maint       -> origin/maint
     * [new branch]          master      -> origin/master
     * [new branch]          next        -> origin/next
     * [new branch]          seen        -> origin/seen
     * [new branch]          todo        -> origin/todo
     * [new tag]             v2.39.0-rc2 -> v2.39.0-rc2
     * [new tag]             gitgui-0.10.0    -> gitgui-0.10.0
     * [new tag]             gitgui-0.10.1    -> gitgui-0.10.1
     * [new tag]             gitgui-0.10.2    -> gitgui-0.10.2
     * [new tag]             gitgui-0.11.0    -> gitgui-0.11.0
     ...
    
    
    "new branch", "new tag" output is a bit annoying, it would be better to
    suppress them, but keep the progress.

Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-1441%2Fadlternative%2Fzh%2Fscalar-verbosity-v1
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-1441/adlternative/zh/scalar-verbosity-v1
Pull-Request: https://github.com/gitgitgadget/git/pull/1441

 Documentation/scalar.txt |  7 ++++++-
 scalar.c                 | 11 ++++++++---
 2 files changed, 14 insertions(+), 4 deletions(-)

diff --git a/Documentation/scalar.txt b/Documentation/scalar.txt
index f33436c7f65..7ff37b43945 100644
--- a/Documentation/scalar.txt
+++ b/Documentation/scalar.txt
@@ -8,7 +8,7 @@ scalar - A tool for managing large Git repositories
 SYNOPSIS
 --------
 [verse]
-scalar clone [--single-branch] [--branch <main-branch>] [--full-clone] <url> [<enlistment>]
+scalar clone [--single-branch] [--branch <main-branch>] [--verbose | -v] [--full-clone] <url> [<enlistment>]
 scalar list
 scalar register [<enlistment>]
 scalar unregister [<enlistment>]
@@ -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.
+
 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[] = {
@@ -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))) {
 		warning(_("partial clone failed; attempting full clone"));
 
 		if (set_config("remote.origin.promisor") ||
@@ -508,7 +511,9 @@ static int cmd_clone(int argc, const char **argv)
 			goto cleanup;
 		}
 
-		if ((res = run_git("fetch", "--quiet", "origin", NULL)))
+		if ((res = run_git("fetch", "origin",
+				   verbosity ? NULL : "--quiet",
+				   NULL)))
 			goto cleanup;
 	}
 

base-commit: 2e71cbbddd64695d43383c25c7a054ac4ff86882
-- 
gitgitgadget

             reply	other threads:[~2022-12-07 18:11 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-12-07 18:10 ZheNing Hu via GitGitGadget [this message]
2022-12-07 22:10 ` [PATCH] scalar: use verbose mode in clone Taylor Blau
2022-12-08 15:54   ` ZheNing Hu
2022-12-08 16:30 ` Derrick Stolee
2022-12-13 16:37   ` ZheNing Hu
2022-12-25 13:29 ` [PATCH v2] scalar: show progress if stderr refer to a terminal ZheNing Hu via GitGitGadget
2023-01-05 19:19   ` Derrick Stolee
2023-01-06 12:30     ` Junio C Hamano
2023-01-11 11:59     ` ZheNing Hu
2023-01-11 13:14   ` [PATCH v3] " ZheNing Hu via GitGitGadget
2023-01-11 14:55     ` Derrick Stolee
2023-01-13 19:52       ` Junio C Hamano

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=pull.1441.git.1670436656379.gitgitgadget@gmail.com \
    --to=gitgitgadget@gmail.com \
    --cc=adlternative@gmail.com \
    --cc=derrickstolee@github.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=johannes.schindelin@gmx.de \
    --cc=vdye@github.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).