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

Re: Distinguishing FF vs non-FF updates in the reflog?

From
Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Date
Mar 22, 2021, 13:26 UTC
Message-ID
<87eeg7qpyr.fsf@evledraar.gmail.com>
In-Reply-To
<CAFQ2z_MefCwiWdhs0buJv5Zok+nsgaOvUCcsSnfm_PP0WozZKA@mail.gmail.com>
On Wed, Mar 17 2021, Han-Wen Nienhuys wrote:
Show 10 quoted lines
> Hi there,
>
> I'm working on some extensions to Gerrit for which it would be very
> beneficial if we could tell from the reflog if an update is a
> fast-forward or not: if we find a SHA1 in the reflog, and see there
> were only FF updates since, we can be sure that the SHA1 is reachable
> from the branch, without having to open packfiles and decode commits.
>
> For the reftable format, I think we could store this easily by
> introducing more record types. [snip].

Aside from what others have mentioned here, you're talking about the log_type field are you not? I.e.: https://googlers.googlesource.com/sop/jgit/+/reftable/Documentation/technical/reftable.md#log-block-format

Has that "log_type = 0x0" tombstone proven to be a worthwhile optimization past the stash case mention there (which is presumably not relevant to the vast majority of Google's use-cases).

I.e. it's redundant to looking at the record and seeing if new_id = ZERO_OID.

Similarly can't ff v.s. non-ff be deduced unambiguously by looking ahead to the next record, and seeing if the current record's "old_id" matches that of the last record's "new_id". If it does it's a FF, if not it's a non-FF (or a create/delete).

I'm not arguing that a quicker lookup isn't needed, I'm just trying to dig at what "beneficial" here is. The format is ordered, and the common case is that the page we have in memory has the last record.

What sort of case are we talking about where not unpacking the log_data segment is making a difference?

> However, the textual reflog format doesn't easily allow for this.
> However, we might add a convention, eg. have the message start with
> 'FF' or 'NFF' depending on the nature of the update.

Maybe a bit ugly, but a ".." and "..." prefix would at least be consistent with "fetch" output. Or e.g. "commit:" and "+commit:" for ff and non-ff (and we could make it "\t commit:" v.s. "\t+commit:" v.s. current "\tcommit:" to distinguish all three in the current text-based format. Per "OUTPUT" in git-fetch(1).

> [Ævar: snipped from earlier] Today we have 0 = deletion, 1 = update,
> and we could add 2 = FF update, 3 = non-FF update.

I've written log table implementations (a site table in a RDBMS) for git (one table for refs) which had:

    create, ff, non-ff, delete

I wonder if that quad-state would be useful for reftable too, with this proposed change you'd still need to unpack the record and see if the old_id is ZERO_OID to check if it's a creation, would you not?

I also wonder if it couldn't be:
    0 = deletion, 1 = non-ff-update, 2 = ff-update, 4 = creation

So the format wouldn't forever carry the historical wart of this not having been considered from the beginning.

It would mean that the few current reftable users (just Google?) would have to look at the record to see if it's *really* a non-ff-update, but presumably they need to do so now for ff v.s. non-ff, so they're no worse off than they are now.

Then when those users know they're on a version that distinguishes these they can hard rely on 1 not being a "ff for sure", not a "maybe" status for new updates. Presumably they either don't care about ancient reflog records, or a one-off migration of rewriting the records for older entries could be done.

Also between my [1] and this proposal we have at least a reftable v1.01 in the wild (the filename locking behavior change discussed in [1]), and this would make it v1.02, but the only up-to-date spec is for v1.00 (and maybe JGit has other changes I haven't tracked).

That [1] change is minor, but still, a spec change.

So just a *poke* that having some version where the spec is kept up-to-date with that and this change if it happens would be very useful, especially if the reftable-in-git.git lands one of these days.

1. https://lore.kernel.org/git/87k0tzulf1.fsf@evledraar.gmail.com/
Previous: Jeff KingNext: Han-Wen Nienhuys
Message 13 of 19 in “Distinguishing FF vs non-FF updates in the reflog?”
  1. Han-Wen NienhuysMar 17, 2021
  2. Martin FickMar 17, 2021
  3. Han-Wen NienhuysMar 18, 2021
  4. Jeff KingMar 18, 2021
  5. Martin FickMar 18, 2021
  6. Han-Wen NienhuysMar 22, 2021
  7. Martin FickMar 22, 2021
  8. Martin FickMar 18, 2021
  9. Jeff KingMar 18, 2021
  10. Jeff KingMar 18, 2021
  11. Han-Wen NienhuysMar 22, 2021
  12. Jeff KingMar 26, 2021
  13. Ævar Arnfjörð BjarmasonMar 22, 2021
  14. Han-Wen NienhuysMar 22, 2021
  15. Ævar Arnfjörð BjarmasonMar 22, 2021
  16. Han-Wen NienhuysMar 22, 2021
  17. Ævar Arnfjörð BjarmasonMar 22, 2021
  18. Han-Wen NienhuysMar 22, 2021
  19. Junio C HamanoMar 22, 2021

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.