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

[PATCH v3 0/2] remote: show progress display when renaming

From
Taylor Blau <me@ttaylorr.com>
Date
Mar 3, 2022, 22:25 UTC
Message-ID
<cover.1646346286.git.me@ttaylorr.com>
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
Previous: Ævar Arnfjörð BjarmasonNext: Taylor Blau
Message 17 of 23 in “builtin/remote.c: show progress when renaming remote references”
  1. builtin/remote.c: show progress when renaming remote referencesTaylor Blau, Mar 1, 2022
  2. Derrick StoleeMar 2, 2022
  3. Taylor BlauMar 2, 2022
  4. Derrick StoleeMar 2, 2022
  5. Junio C HamanoMar 2, 2022
  6. Ævar Arnfjörð BjarmasonMar 2, 2022
  7. Taylor BlauMar 2, 2022
  8. Ævar Arnfjörð BjarmasonMar 3, 2022
  9. Taylor BlauMar 3, 2022
  10. Han-Wen NienhuysMar 7, 2022
  11. brian m. carlsonMar 2, 2022
  12. Taylor BlauMar 2, 2022
  13. Derrick StoleeMar 3, 2022
  14. Taylor BlauMar 3, 2022
  15. builtin/remote.c: show progress when renaming remote referencesTaylor Blau, Mar 2, 2022
  16. Ævar Arnfjörð BjarmasonMar 3, 2022
  17. 0/2 remote: show progress display when renamingTaylor Blau, Mar 3, 2022
  18. 1/2 builtin/remote.c: parse options in 'rename'Taylor Blau, Mar 3, 2022
  19. Ævar Arnfjörð BjarmasonMar 5, 2022
  20. 2/2 builtin/remote.c: show progress when renaming remote referencesTaylor Blau, Mar 3, 2022
  21. Junio C HamanoMar 3, 2022
  22. Taylor BlauMar 3, 2022
  23. Ævar Arnfjörð BjarmasonMar 5, 2022

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.