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

Re: [PATCH 2/6] builtin/update-index: end ODB transaction when --verbose is specified

From
Justin Tobler <jltobler@gmail.com>
Date
Sep 11, 2025, 15:34 UTC
Message-ID
<3cmqsfz5j2h36mw7yzwbrgfgchaettcnidvkiboqqktkm3dd5k@h6rmgjnqdmq2>
In-Reply-To
<aMJu7vPKfnxt9UiC@pks.im>
On 25/09/11 08:40AM, Patrick Steinhardt wrote:
Show 26 quoted lines
> On Tue, Sep 09, 2025 at 02:11:30PM -0500, Justin Tobler wrote:
> > With 23a3a303 (update-index: use the bulk-checkin infrastructure,
> > 2022-04-04), object database transactions were added to
> > git-update-index(1) to facilitate writing objects in bulk. With
> > transactions, newly added objects are instead written to a temporary
> > object directory and migrated to the primary object database upon
> > transaction commit.
> > 
> > When the --verbose option is specified, each individual object is
> > explicitly flushed via flush_odb_transaction() prior to reporting the
> > update. Flushing the object database transaction migrates pending
> > objects to the primary object database without marking the transaction
> > as complete. This is done so objects are immediately visible to
> > git-update-index(1) callers using the --verbose option and that rely on
> > parsing verbose output to know when objects are written.
> > 
> > As soon as verbose output is requested in git-update-index(1), all
> > subsequent object writes are flushed prior to being reported and thus no
> > longer benefit from being transactional. Furthermore, the mechanism to
> > flush a transaction without committing is rather awkward. Drop the call
> > to flush_odb_transaction() in favor of ending the transaction early when
> > the --verbose flag is encountered.
> 
> Okay, this interface feels somewhat weird indeed. If we now end the
> transaction early, does the transaction still serve any purpose at all?
> Like, do we use it to batch steps _before_ we start reporting stuff?

We only start reporting updates when the --verbose option is first encountered. Options are not all processed upfront. This means in the follow example:

  $ git update-index --add foo --add bar --verbose --stdin

both "foo" and "bar" are silently added via a transaction. After the --verbose option, subsequent updates are reported. At this point there is no reason for the transaction to continue as all subsequent object writes must be fully written before being reported. Thus the transaction is ended early.

> If the answer is "no", we might be able to just not create a transaction
> altogether. 

We still use a transaction in the normal case when objects are written without --verbose enabled. This matches the existing behavior.

> If the answer is "yes" we should probably point out in the
> commit message that the transaction still has a purpose.

Yes, transactions still have a purpose, but only for object written before the --verbose option is first encountered. I'll try to clarify this in the commit message.

-Justin
Previous: Patrick SteinhardtNext: Patrick Steinhardt
Message 11 of 38 in “odb: add transaction interfaces to ODB subsystem”
  1. 0/6 odb: add transaction interfaces to ODB subsystemJustin Tobler, Sep 9, 2025
  2. 1/6 bulk-checkin: remove ODB transaction nestingJustin Tobler, Sep 9, 2025
  3. Patrick SteinhardtSep 11, 2025
  4. Justin ToblerSep 11, 2025
  5. Taylor BlauSep 15, 2025
  6. Justin ToblerSep 16, 2025
  7. Junio C HamanoSep 16, 2025
  8. Justin ToblerSep 16, 2025
  9. 2/6 builtin/update-index: end ODB transaction when --verbose is specifiedJustin Tobler, Sep 9, 2025
  10. Patrick SteinhardtSep 11, 2025
  11. Justin ToblerSep 11, 2025
  12. Patrick SteinhardtSep 15, 2025
  13. Justin ToblerSep 15, 2025
  14. Justin ToblerSep 15, 2025
  15. 3/6 bulk-checkin: drop flush_odb_transaction()Justin Tobler, Sep 9, 2025
  16. 4/6 object-file: relocate ODB transaction codeJustin Tobler, Sep 9, 2025
  17. 5/6 object-file: update naming from bulk-checkinJustin Tobler, Sep 9, 2025
  18. 6/6 odb: add transaction interfaceJustin Tobler, Sep 9, 2025
  19. Patrick SteinhardtSep 11, 2025
  20. Justin ToblerSep 11, 2025
  21. 0/6 odb: add transaction interfaces to ODB subsystemJustin Tobler, Sep 15, 2025
  22. 1/6 bulk-checkin: remove ODB transaction nestingJustin Tobler, Sep 15, 2025
  23. Karthik NayakSep 16, 2025
  24. Justin ToblerSep 16, 2025
  25. 2/6 builtin/update-index: end ODB transaction when --verbose is specifiedJustin Tobler, Sep 15, 2025
  26. Karthik NayakSep 16, 2025
  27. Justin ToblerSep 16, 2025
  28. 3/6 bulk-checkin: drop flush_odb_transaction()Justin Tobler, Sep 15, 2025
  29. 4/6 object-file: relocate ODB transaction codeJustin Tobler, Sep 15, 2025
  30. 5/6 object-file: update naming from bulk-checkinJustin Tobler, Sep 15, 2025
  31. 6/6 odb: add transaction interfaceJustin Tobler, Sep 15, 2025
  32. 0/6 odb: add transaction interfaces to ODB subsystemJustin Tobler, Sep 16, 2025
  33. 2/6 builtin/update-index: end ODB transaction when --verbose is specifiedJustin Tobler, Sep 16, 2025
  34. 1/6 bulk-checkin: remove ODB transaction nestingJustin Tobler, Sep 16, 2025
  35. 3/6 bulk-checkin: drop flush_odb_transaction()Justin Tobler, Sep 16, 2025
  36. 4/6 object-file: relocate ODB transaction codeJustin Tobler, Sep 16, 2025
  37. 5/6 object-file: update naming from bulk-checkinJustin Tobler, Sep 16, 2025
  38. 6/6 odb: add transaction interfaceJustin Tobler, Sep 16, 2025

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.