Thread (2 messages) read the whole thread 2 messages, 2 authors, 2025-02-13

Re: [PATCH v3] builtin/refs: add '--skip-reflog' flag to bypass reflog migration

From: Karthik Nayak <hidden>
Date: 2025-02-13 09:22:42

Junio C Hamano [off-list ref] writes:
Karthik Nayak [off-list ref] writes:
quoted
The 'git-refs(1)' migrate subcommand, which transfers repositories
between reference backends, currently migrates reflogs by default as of
246cebe320 (refs: add support for migrating reflogs, 2024-12-16).

While this behavior is desirable for most client-side repositories,
server-side repositories are not expected to contain reflogs. However,
due to historical reasons, some may still have them. This could be
caused, for example, by bugs, misconfiguration, or an administrator
enabling reflogs on the server for debugging purposes.

To address this, introduce the --skip-reflog flag, allowing users to
bypass reflog migration. This ensures that the repository ends up in the
expected state after migration.
I do not quite understand the motivation behind this change.

If a repository has reflog that you do not need by mistake or
misconfiguration, I agree that there should be a way for you to
remove the reflog.  Removing it while converting the ref backend may
be a convenient way if and only if the reason why you noticed such a
repository with unwanted reflog is because you were about to migrate
it, but regardless of when you notice such refs with unwanted log,
you would want to be able to drop their logs.  You may not even be
planning to migrate your backend when you noticed that the refs have
unwanted log, you may have already migrated long time ago when you
noticed that the refs have unwanted log, or you may not even be
planning to migrate in the first place.  Even after you migrated
your backend, an administrator may have to enable reflog for
debugging, and then after the administrator is done, then what?
Should the backend migrated back from reftable to files and then
back again, only to pass this --skip-reflog option?

Wouldn't it be a lot more flexible if you add a new subcommand
"drop" to the "git reflog" command?
Karthik Nayak [off-list ref] writes:
quoted
The 'git-refs(1)' migrate subcommand, which transfers repositories
between reference backends, currently migrates reflogs by default as of
246cebe320 (refs: add support for migrating reflogs, 2024-12-16).

While this behavior is desirable for most client-side repositories,
server-side repositories are not expected to contain reflogs. However,
due to historical reasons, some may still have them. This could be
caused, for example, by bugs, misconfiguration, or an administrator
enabling reflogs on the server for debugging purposes.

To address this, introduce the --skip-reflog flag, allowing users to
bypass reflog migration. This ensures that the repository ends up in the
expected state after migration.
I do not quite understand the motivation behind this change.

If a repository has reflog that you do not need by mistake or
misconfiguration, I agree that there should be a way for you to
remove the reflog.  Removing it while converting the ref backend may
be a convenient way if and only if the reason why you noticed such a
repository with unwanted reflog is because you were about to migrate
it, but regardless of when you notice such refs with unwanted log,
you would want to be able to drop their logs.  You may not even be
planning to migrate your backend when you noticed that the refs have
unwanted log, you may have already migrated long time ago when you
noticed that the refs have unwanted log, or you may not even be
planning to migrate in the first place.  Even after you migrated
your backend, an administrator may have to enable reflog for
debugging, and then after the administrator is done, then what?
Should the backend migrated back from reftable to files and then
back again, only to pass this --skip-reflog option?

Wouldn't it be a lot more flexible if you add a new subcommand
"drop" to the "git reflog" command?
To just get rid of reflogs from a repository, I think 'git reflog drop'
or something similar would indeed be a better way to go about it. As you
stated, with this patch, we could still face the issue wherein the
administartor could re-enable reflog and we're back to square one.

Why I think this patch is important, is because while there could be
existing reflogs in a repository, if one doesn't care about _reflogs_
there could be significant performance gains while migrating repos from
one backend to the other, while also leaving the reflogs behind. The
intent of the patch is not to be a detterrent for reflogs. The `git refs
migrate` command is not the pathway for that. Rather, the goal is to
ensure we skip them during migraiton because we do not want to bother
migrating them.

Saying this, another option is to have `git reflog drop` and then
perform the migration, but I think it does makes sense to provide users
with a fine-tuning during migration to allow them to choose what they
want to migrate.

I know that in GitLab we have repositories with millions of references
and while we generally have reflogs disabled. There could be
repositories with reflogs enabled during debugging or just old
repositories where reflogs always existed. Since migrating backends
blocks all operations on the repository, it would be vital to also
optimize it as much as possible.

Thanks,
Karthik

Attachments

Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help