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

Re: git status always modifies index?

From
Jeff King <peff@peff.net>
Date
Nov 22, 2017, 21:17 UTC
Message-ID
<20171122211729.GA2854@sigill>
In-Reply-To
<20171122202720.GD11671@aiede.mtv.corp.google.com>
On Wed, Nov 22, 2017 at 12:27:20PM -0800, Jonathan Nieder wrote:
Show 19 quoted lines
> Nathan Neulinger wrote[1]:
> 
> > I just got an answer to my stackoverflow question on this,
> > apparently it's already implemented:
> >
> > https://stackoverflow.com/questions/47436939/how-to-run-git-status-without-modifying-git-index-such-as-in-a-prompt-command
> >
> > There is a "--no-optional-locks" command in 2.15 that looks like it
> > does exactly what I need.
> 
> I was about to point to
> https://public-inbox.org/git/20170921043214.pyhdsrpy4omy54rm@sigill.intra.peff.net/
> about exactly this thing. :)
> 
> That said, I wonder if this use case is an illustration that a name
> like --no-lock-index (as was used in Git for Windows when this feature
> first appeared) or --no-refresh-on-disk-index (sorry, I am terrible at
> coming up with option names) would make the feature easier to
> discover.

Yeah, it's interesting that Nathan does not care about the simultaneous locking here, but rather about the effect of writing to the repo for what would otherwise be a read-only operation.

Under the original intent of --no-optional-locks I think if we could somehow magically update the on-disk index without lock contention, it would be OK to do so. But that would make it no longer work for this particular case.

And I would also not be surprised if there are other cases where we write in a lockless way that would best be avoided in a multi-user setup. I'm thinking specifically of the way that some merge-y operations may write out intermediate objects, even though they're only needed inside the process. It _should_ be a read-only operation to ask "can these two things be merged cleanly", and you should be able to ask that without accidentally creating root-owned files in .git/objects.

So I actually think what Nathan wants is not exactly the same as --no-optional-locks in the first place. But in practice, for a limited set of operations and with the way that locks work in Git, it accomplishes the same thing. Maybe that points to having a broader option. Or maybe having two separate options that largely have the same effect. Or maybe just living with the minor philosophical rough edges, since it seems OK in practice.

-Peff
Previous: Jonathan NiederNext: Jonathan Nieder
Message 8 of 33 in “git status always modifies index?”
  1. Nathan NeulingerNov 22, 2017
  2. Santiago TorresNov 22, 2017
  3. Nathan NeulingerNov 22, 2017
  4. Santiago TorresNov 22, 2017
  5. Nathan NeulingerNov 22, 2017
  6. Santiago TorresNov 22, 2017
  7. Jonathan NiederNov 22, 2017
  8. Jeff KingNov 22, 2017
  9. Jonathan NiederNov 22, 2017
  10. Jeff KingNov 22, 2017
  11. Johannes SchindelinNov 25, 2017
  12. Jeff KingNov 26, 2017
  13. Johannes SchindelinNov 26, 2017
  14. Jeff KingNov 27, 2017
  15. Junio C HamanoNov 27, 2017
  16. Johannes SchindelinNov 27, 2017
  17. git-status.txt: mention --no-optional-locksJeff King, Nov 27, 2017
  18. Junio C HamanoNov 27, 2017
  19. Kaartic SivaraamNov 27, 2017
  20. Johannes SchindelinNov 27, 2017
  21. Johannes SchindelinNov 27, 2017
  22. Jonathan NiederNov 27, 2017
  23. Junio C HamanoNov 26, 2017
  24. Junio C HamanoNov 26, 2017
  25. Jeff KingNov 27, 2017
  26. Junio C HamanoNov 27, 2017
  27. Jeff KingNov 27, 2017
  28. Jonathan NiederNov 27, 2017
  29. Jeff KingNov 27, 2017
  30. Junio C HamanoDec 3, 2017
  31. Jeff KingNov 26, 2017
  32. Junio C HamanoNov 27, 2017
  33. Jeff KingNov 27, 2017

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.