From: Taylor Blau <me@ttaylorr.com>
To: git@vger.kernel.org
Cc: sandals@crustytoothpaste.net, derrickstolee@github.com,
avarab@gmail.com, gitster@pobox.com
Subject: [PATCH v3 0/2] remote: show progress display when renaming
Date: Thu, 3 Mar 2022 17:25:13 -0500 [thread overview]
Message-ID: <cover.1646346286.git.me@ttaylorr.com> (raw)
In-Reply-To: <70a0325ca8ab0492a9b0873ee3fba576c5ab90b9.1646173186.git.me@ttaylorr.com>
Here is a reroll of the patch we've been discussing to add progress
output when renaming remote-tracking references (as part of a `git
remote rename <old> <new>`).
This single patch is now two (and hence, has a cover letter!) because of
a slight change in approach which amounts to changing this behavior from
an opt-in
git remote -v rename <old> <new>
to something much more in line with our existing use of the
`--[no-]progress` option like:
git remote rename [--[no-]progress] <old> <new>
(where `--progress` is the default exactly when `isatty(2)` is true).
I think similar treatment could be applied to other `git remote`
sub-commands, but I'm reasonably happy starting with just `git remote
rename` and looking at the others later.
Taylor Blau (2):
builtin/remote.c: parse options in 'rename'
builtin/remote.c: show progress when renaming remote references
Documentation/git-remote.txt | 2 +-
builtin/remote.c | 39 ++++++++++++++++++++++++++++--------
t/t5505-remote.sh | 4 +++-
3 files changed, 35 insertions(+), 10 deletions(-)
Range-diff against v2:
-: ---------- > 1: b76da50b54 builtin/remote.c: parse options in 'rename'
1: dc63ec91ab ! 2: d5b0a4b710 builtin/remote.c: show progress when renaming remote references
@@ Documentation/git-remote.txt: SYNOPSIS
'git remote' [-v | --verbose]
'git remote add' [-t <branch>] [-m <master>] [-f] [--[no-]tags] [--mirror=(fetch|push)] <name> <URL>
-'git remote rename' <old> <new>
-+'git remote' [-v | --verbose] 'rename' <old> <new>
++'git remote rename' [--[no-]progress] <old> <new>
'git remote remove' <name>
'git remote set-head' <name> (-a | --auto | -d | --delete | <branch>)
'git remote set-branches' [--add] <name> <branch>...
@@ builtin/remote.c
"git remote [-v | --verbose]",
N_("git remote add [-t <branch>] [-m <master>] [-f] [--tags | --no-tags] [--mirror=<fetch|push>] <name> <url>"),
- N_("git remote rename <old> <new>"),
-+ N_("git remote [-v | --verbose] rename <old> <new>"),
++ N_("git remote rename [--[no-]progress] <old> <new>"),
N_("git remote remove <name>"),
N_("git remote set-head <name> (-a | --auto | -d | --delete | <branch>)"),
N_("git remote [-v | --verbose] show [-n] <name>"),
+@@ builtin/remote.c: static const char * const builtin_remote_add_usage[] = {
+ };
+
+ static const char * const builtin_remote_rename_usage[] = {
+- N_("git remote rename <old> <new>"),
++ N_("git remote rename [--[no-]progress] <old> <new>"),
+ NULL
+ };
+
@@ builtin/remote.c: struct rename_info {
const char *old_name;
const char *new_name;
@@ builtin/remote.c: static int read_remote_branches(const char *refname,
}
strbuf_release(&buf);
+@@ builtin/remote.c: static void handle_push_default(const char* old_name, const char* new_name)
+
+ static int mv(int argc, const char **argv)
+ {
++ int show_progress = isatty(2);
+ struct option options[] = {
++ OPT_BOOL(0, "progress", &show_progress, N_("force progress reporting")),
+ OPT_END()
+ };
+ struct remote *oldremote, *newremote;
@@ builtin/remote.c: static int mv(int argc, const char **argv)
old_remote_context = STRBUF_INIT;
struct string_list remote_branches = STRING_LIST_INIT_DUP;
@@ builtin/remote.c: static int mv(int argc, const char **argv)
+ int i, refs_renamed_nr = 0, refspec_updated = 0;
+ struct progress *progress = NULL;
- if (argc != 3)
- usage_with_options(builtin_remote_rename_usage, options);
+ argc = parse_options(argc, argv, NULL, options,
+ builtin_remote_rename_usage, 0);
@@ builtin/remote.c: static int mv(int argc, const char **argv)
- rename.old_name = argv[1];
- rename.new_name = argv[2];
+ rename.old_name = argv[0];
+ rename.new_name = argv[1];
rename.remote_branches = &remote_branches;
+ rename.symrefs_nr = 0;
@@ builtin/remote.c: static int mv(int argc, const char **argv)
* the new symrefs.
*/
for_each_ref(read_remote_branches, &rename);
-+ if (verbose) {
++ if (show_progress) {
+ /*
+ * Count symrefs twice, since "renaming" them is done by
+ * deleting and recreating them in two separate passes.
@@ t/t5505-remote.sh: test_expect_success 'rename a remote' '
cd four &&
git config branch.main.pushRemote origin &&
- git remote rename origin upstream &&
-+ GIT_PROGRESS_DELAY=0 git remote -v rename origin upstream 2>err &&
++ GIT_TRACE2_EVENT=$(pwd)/trace \
++ git remote rename --progress origin upstream &&
++ test_region progress "Renaming remote references" trace &&
grep "pushRemote" .git/config &&
-+ grep "Renaming remote references: 100% (4/4), done" err &&
test -z "$(git for-each-ref refs/remotes/origin)" &&
test "$(git symbolic-ref refs/remotes/upstream/HEAD)" = "refs/remotes/upstream/main" &&
- test "$(git rev-parse upstream/main)" = "$(git rev-parse main)" &&
--
2.35.1.73.gccc5557600
next prev parent reply other threads:[~2022-03-03 22:25 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-03-01 22:20 [PATCH] builtin/remote.c: show progress when renaming remote references Taylor Blau
2022-03-02 14:32 ` Derrick Stolee
2022-03-02 15:52 ` Taylor Blau
2022-03-02 18:58 ` Derrick Stolee
2022-03-02 19:03 ` Junio C Hamano
2022-03-02 19:00 ` Ævar Arnfjörð Bjarmason
2022-03-02 22:55 ` Taylor Blau
2022-03-03 10:51 ` Ævar Arnfjörð Bjarmason
2022-03-03 19:54 ` Taylor Blau
2022-03-07 10:34 ` Han-Wen Nienhuys
2022-03-02 22:21 ` brian m. carlson
2022-03-02 22:57 ` Taylor Blau
2022-03-03 16:09 ` Derrick Stolee
2022-03-03 19:58 ` Taylor Blau
2022-03-02 23:00 ` [PATCH v2] " Taylor Blau
2022-03-03 11:04 ` Ævar Arnfjörð Bjarmason
2022-03-03 22:25 ` Taylor Blau [this message]
2022-03-03 22:25 ` [PATCH v3 1/2] builtin/remote.c: parse options in 'rename' Taylor Blau
2022-03-05 14:28 ` Ævar Arnfjörð Bjarmason
2022-03-03 22:25 ` [PATCH v3 2/2] builtin/remote.c: show progress when renaming remote references Taylor Blau
2022-03-03 23:20 ` Junio C Hamano
2022-03-03 23:30 ` Taylor Blau
2022-03-05 14:31 ` Ævar Arnfjörð Bjarmason
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=cover.1646346286.git.me@ttaylorr.com \
--to=me@ttaylorr.com \
--cc=avarab@gmail.com \
--cc=derrickstolee@github.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=sandals@crustytoothpaste.net \
/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.
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 NNTP newsgroup(s).