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

Re: [PATCH] builtin/remote.c: show progress when renaming remote references

From
Derrick Stolee <derrickstolee@github.com>
Date
Mar 2, 2022, 14:32 UTC
Message-ID
<06ef2e2c-7048-1101-870a-4774a2dcd988@github.com>
In-Reply-To
<70a0325ca8ab0492a9b0873ee3fba576c5ab90b9.1646173186.git.me@ttaylorr.com>
On 3/1/2022 5:20 PM, Taylor Blau wrote:
Show 29 quoted lines
> When renaming a remote, Git needs to rename all remote tracking
> references to the remote's new name (e.g., renaming
> "refs/remotes/old/foo" to "refs/remotes/new/foo" when renaming a remote
> from "old" to "new").
> 
> This can be somewhat slow when there are many references to rename,
> since each rename is done in a separate call to rename_ref() as opposed
> to grouping all renames together into the same transaction. It would be
> nice to execute all renames as a single transaction, but there is a
> snag: the reference transaction backend doesn't support renames during a
> transaction (only individually, via rename_ref()).
> 
> The reasons there are described in more detail in [1], but the main
> problem is that in order to preserve the existing reflog, it must be
> moved while holding both locks (i.e., on "oldname" and "newname"), and
> the ref transaction code doesn't support inserting arbitrary actions
> into the middle of a transaction like that.
> 
> As an aside, adding support for this to the ref transaction code is
> less straightforward than inserting both a ref_update() and ref_delete()
> call into the same transaction. rename_ref()'s special handling to
> detect D/F conflicts would need to be rewritten for the transaction code
> if we wanted to proactively catch D/F conflicts when renaming a
> reference during a transaction. The reftable backend could support this
> much more readily because of its lack of D/F conflicts.
> 
> Instead of a more complex modification to the ref transaction code,
> display a progress meter when running verbosely in order to convince the
> user that Git is doing work while renaming a remote.

Thanks for this patch. It improves the user experience through useful feedback.

Show 6 quoted lines
> @@ -682,7 +686,8 @@ static int mv(int argc, const char **argv)
>  		old_remote_context = STRBUF_INIT;
>  	struct string_list remote_branches = STRING_LIST_INIT_DUP;
>  	struct rename_info rename;
> -	int i, refspec_updated = 0;
> +	int i, j = 0, refspec_updated = 0;
My only complaint is that 'j' is not informative enough here.

'j' as a loop iterator is good, but we aren't looping "on" j, but instead tracking a progress_count across multiple loops.

Thanks, -Stolee

Previous: Taylor BlauNext: Taylor Blau
Message 2 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.