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

Re: [PATCH] commit: Optimize number of lstat() calls

From
Junio C Hamano <gitster@pobox.com>
Date
Feb 4, 2017, 06:50 UTC
Message-ID
<xmqqwpd678lx.fsf@gitster.mtv.corp.google.com>
In-Reply-To
<DA0A42D68346B1469147552440A645039A9C9988@ORSMSX115.amr.corp.intel.com>

Aside from whitespace breakage, I think we should never skip the refreshing of the real index that is left after "git commit" finishes.

Between these two calls to refresh_cache(), the one that writes out a temporary index that contains the contents of HEAD plus the contents of the working tree for the specified paths may be fine without refreshing, unless somebody else (like the pre-commit hook) looks at it. But the other one refreshes the real index file that will be used after "git commit" returns the control. Users and scripts that run "git commit" inside expect that the entries in the resulting index are refreshed after "git commit" returns, and I do not think of a safe way to optimizing it out; unlike the other one, to which we can say "as long as there is no pre-commit hook, nobody will look at it after we are done", there does not an easy-to-check set of conditions that we can use to decide when it is safe to skip refreshing.

Besides, leaving the main index not refreshed would mean the user has to pay the refreshing cost when s/he runs other commands "git diff", "git status", etc. after "git commit" for the first time; so...

Previous: Junio C HamanoNext: Johannes Schindelin
Message 3 of 6 in “commit: Optimize number of lstat() calls”
  1. commit: Optimize number of lstat() callsGumbel, Matthew K, Feb 3, 2017
  2. Junio C HamanoFeb 3, 2017
  3. Junio C HamanoFeb 4, 2017
  4. Johannes SchindelinFeb 4, 2017
  5. Junio C HamanoFeb 4, 2017
  6. Johannes SchindelinFeb 4, 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.