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

Re: [PATCH 0/2] describe and diff: implement --no-optional-locks

From
Junio C Hamano <gitster@pobox.com>
Date
Mar 6, 2025, 16:11 UTC
Message-ID
<xmqqo6yejg0y.fsf@gitster.g>
In-Reply-To
<pull.1872.git.1741240685.gitgitgadget@gmail.com>

"Benjamin Woodruff via GitGitGadget" <gitgitgadget@gmail.com> writes:

> git describe and git diff may update the index in the background for similar
> performance reasons to git-status.
That is a wrong reasoning that is completely opposite, though.

The commands at the Porcelain level, like "status" and "diff", refresh the index for the CORRECTNESS purposes.

The commands at the plumbing level, which are designed to be used in your own scripts, like "diff-files" and "diff-index", do not refresh the index for the performance purposes. If your own script wants to produce correct result, your script IS responsible for refreshing the index after its last modification to working tree files before it starts to use the plumbing commands to inspect which ones are modified and which ones are not. This is so that your script has more control over when the index is refreshed. It does not have to pay cost to run refresh for each Git command it invokes, if it knows that it does not make any modification between the two invocations; it can instead refresh just once and then run these two plumbing commands.

So, it would be absolute no-no to make the Porcelain commands like "describe" and "diff" not to refresh the index before they work by default. As an optional behaviour, it might be acceptable if there is no other reasonable solutions (like, using plumbing commands if the callers are not you typing but your scripts calling them).

Previous: Benjamin Woodruff via GitGitGadgetNext: Jeff King
Message 4 of 11 in “describe and diff: implement --no-optional-locks”
  1. 0/2 describe and diff: implement --no-optional-locksBenjamin Woodruff via GitGitGadget, Mar 6, 2025
  2. 1/2 describe: implement --no-optional-locksBenjamin Woodruff via GitGitGadget, Mar 6, 2025
  3. 2/2 diff: implement --no-optional-locksBenjamin Woodruff via GitGitGadget, Mar 6, 2025
  4. Junio C HamanoMar 6, 2025
  5. Jeff KingMar 9, 2025
  6. Junio C HamanoMar 10, 2025
  7. Jeff KingMar 10, 2025
  8. Junio C HamanoMar 10, 2025
  9. Benjamin WoodruffMar 10, 2025
  10. Junio C HamanoMar 10, 2025
  11. Jeff KingMar 11, 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.