Re: [PATCH] builtin/remote.c: show progress when renaming remote references
From: brian m. carlson <hidden>
Date: 2022-03-02 22:21:24
On 2022-03-01 at 22:20:33, Taylor Blau wrote:
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. This is mostly done as-expected, with the minor caveat that we intentionally count symrefs renames twice, since renaming a symref takes place over two separate calls (one to delete the old one, and another to create the new one). [1]: https://lore.kernel.org/git/572367B4.4050207@alum.mit.edu/ (local) Suggested-by: brian m. carlson <redacted> Signed-off-by: Taylor Blau <redacted>
As I mentioned to you personally, I think this looks good. For context, I discovered this when I tried to rename a remote with tens of thousands of branches and it just ran silently for an extended period of time without any output. I actually interrupted it with Ctrl-C because I thought it had hung, so I'm hoping this will provide a better experience for users in that situation. -- brian m. carlson (he/him or they/them) Toronto, Ontario, CA
Attachments
- signature.asc [application/pgp-signature] 262 bytes