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, 16:40 UTC
Message-ID
<878s6fqgze.fsf@evledraar.gmail.com>
In-Reply-To
<CAFQ2z_ML8s0Gk4Zmg+2mxzkfP1AbL=zkeUG0yKEtoege7it-vA@mail.gmail.com>
On Mon, Mar 22 2021, Han-Wen Nienhuys wrote:
Show 17 quoted lines
> On Mon, Mar 22, 2021 at 4:39 PM Ævar Arnfjörð Bjarmason
> <avarab@gmail.com> wrote:
>> We can know with !strcmp(rows[0][1], rows[1][0]) whether the latest
>> update is a ff or non-ff (it is). As opposed to:
>>
>>     $ cut -d ' ' -f1-2 .git/logs/refs/remotes/origin/seen | head -n 2
>>     8b26a41f4bf7e7c0f097cb91012d08fe8ae30e7f 0f3a981cbd5be5f97e9504ab770cd88f988fe820
>>     0f3a981cbd5be5f97e9504ab770cd88f988fe820 fdd019edfe6bc60d0100d5751c41e4f6ad28a2ef
>>
>> Where the rows[0][1] value is not the same as rows[1][0].
>
> I'm confused.
>
> rows[0][1] == "0f3a981cbd5be5f97e9504ab770cd88f988fe820"
> rows[1][0] == "0f3a981cbd5be5f97e9504ab770cd88f988fe820"
>
> they are the same. I don't understand your argument.

Sorry, I mean same = ff update, not the same = non-ff. So I flipped those around in describing it.

But in any case, the point is that you can reliably tell from a log of updates whether individual updates are ff or non-ff, as long as you:

1. Look at two records but not one, or rather the ff-ness of the update
   you're looking at now depends on <oldvalue> of that update matching
   the <newvalue> of the update before that.
2. The log is guaranteed to be in the same order as the update-ref
   calls, and not to be pruned in the middle.
3. Don't care about the FF-ness of the first entry in the reflog
   (e.g. prune it at N entries or 2 weeks, you can't see if the oldest
   entry you have is a FF or not)

So as I noted I've materialized this in a RDBMS before as something like ENUM('delete', 'create', 'ff', 'non-ff'), but that was:

A. In the delete/create case as much about the convenience of
   selecting/grouping as anything else, easier to select operation =
   "delete" than {old,new} = "<copy paste or calefully type exactly 40 x
   '0'>"
B. In SQL it's a PITA both typing and index-wise to get information
   about a record based on a "previous" record when the relation between
   the two is a a UNIQUE INDEX and AUTO-INCREMENT id. I.e. for an
   AUTO_INCREMENT UNIQUE INDEX of repo,refname,id to get the "last"
   record you need to select where repo && refname is the same, and id <
   current_id LIMIT 1.
C. You're accessing the data ad-hoc & manually via SQL, not some
   Git-specific query language/wrapper.

But in the case of reftable I'm wondering what the use-case is, since presumably whatever API now serves up the reflog from it can just as well look at one more record and fill in a matrialized "ff" or "non-ff" field for the current record based on that.

Also: If you're adding more values a genuinely useful value to log (that
I've seen custom logging for) is "was this a forced push? || update-ref
without the <oldvalue>?", which is *not* the same as "not a
fast-forward". I.e. it's the difference between "update this with this
<oldvalue>" (ff or non-ff) v.s. "I don't care what the oldvalue is, just
update it" (f orce or not).

(To complicate matters and make them even more harder to explain, the whole "force with lease" thing is not actually a "force push" in that sense, it's just an update-ref with an oldvalue you expect to result in a non-ff update).

Previous: Han-Wen NienhuysNext: Han-Wen Nienhuys
Message 17 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.