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

Re: git status always modifies index?

From
Nathan Neulinger <nneul@neulinger.org>
Date
Nov 22, 2017, 16:20 UTC
Message-ID
<dfbf4af3-e87c-bdcb-7544-685572925a50@neulinger.org>
In-Reply-To
<20171122161014.djkdygmclk227xmq@LykOS.localdomain>
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.
-- Nathan
On 11/22/17 10:10 AM, Santiago Torres wrote:
Show 32 quoted lines
> On Wed, Nov 22, 2017 at 09:37:09AM -0600, Nathan Neulinger wrote:
>> What I'm meaning is - why does it need to write the index back out to disk?
>>
>>  From looking at the code in builtin/commit.c it looks like it takes a lock
>> on the index, collects the status, and then unconditionally rewrites the
>> index file.
>>
> Hmm, I just took a look at those lines and I see what you mean. From
> what I understand, this is to cache the result of the index computation
> for ensuing git calls.
> 
>> I'm proposing that the update_index_if_able call not actually be issued if
>> it would result in a ownership change on the underlying file - such as a
>> simple case of root user or other privileged account issuing 'git status' in
>> a directory.
> 
> I don't think this would be a desire-able default behavior. I'd wager
> that running git status using different accounts is not a great idea ---
> specially interacting with a user repository as root.
> 
>> I understand completely that it would be expected to be altered if the
>> privileged user did a commit/add or any other operation that was inherently
>> a 'write' operation, but doesn't seem like status should be one of those
>> cases.
> 
> I think it's because of the reasons above. That being said, I don't know
> what the rest of the community would think of something akin to a
> --no-update-index type flag.
> 
> Cheers!
> -Santiago.
> 
-- 
------------------------------------------------------------
Nathan Neulinger                       nneul@neulinger.org
Neulinger Consulting                   (573) 612-1412
Previous: Santiago TorresNext: Santiago Torres
Message 5 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.