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

Re: [PATCH 0/2] Add a way to wait for index lock

From
JWJun Wu <quark.zju@gmail.com>
Date
Oct 14, 2026, 22:12 UTC
Message-ID
<20261014221226.1693842-1-quark.zju@gmail.com>
In-Reply-To
<xmqqh5ipuuhk.fsf@gitster.g>
On Tue, 13 Oct 2026 15:05:27 -0700, Junio C Hamano wrote:
> It is unfair to expect that the readers would guess what you left
> unsaid here, which probably is "we will introduce the third choice,
> which does such and such things, and it improves the situation in
> such and such ways because ...", before listing ...

Got it. I was trying to reduce duplication with commit message. Will adjust going forward.

Show 9 quoted lines
> > To minimize write race, if the index is read before locking, the
> > wait will be skipped, as if timeout is 0. Depending on the read/lock
> > order, some commands (e.g. add, rm, mv, checkout, restore, read-tree,
> > apply, update-index) respect the timeout. Some (e.g. reset, stash,
> > merge, rebase, cherry-pick, am) do not. I started with the simple and
> > common commands. If there is interest in other commands I can take a
> > look too.
>
> Is the above supposed to be the description of the proposed solution?

I thought it was the exciting key detail that is worth highlighting. But it seems too tricky to grasp. Will adjust going forward.

Show 6 quoted lines
> There are multiple parties (i.e., `git status` that needed to
> discard the result with "--no-optional-locks" and other end-user
> actions that do need to safely update the index) involved, and it is
> unclear whose actions many of verbs in your writing refer to in the
> above.  E.g., "if the index is read before locking, the wait will be
> skipped" for whom?  "git status" that wants to opportunistically
Scope "if the index ..." to a single process only:
- "who": the current process that calls repo_hold_locked_index (could be any
  command that calls this function)
- "if the index is read before locking, ...": within the current process,
  if the index is read (repo->index->initialized) before locking
  (repo_hold_locked_index), then use the old behavior (timeout=0).
- whether there is a separate `git status` process or not, whether that process
  has read/locked the index or not, are irrelevant to the above rule scoped to
  the current process.
> write out the result of refreshing?  End-user actions like "git add"
> that wanted to register new contents to the index?  Both?

Both are subject to the above rule. Today, `git status` always reads the index before locking, so timeout=0, and its behavior is not changed.

Previous: Junio C HamanoNext: Jeff King
Message 13 of 20 in “Add a way to wait for index lock”
  1. 0/2 Add a way to wait for index lockJun Wu, Oct 13, 2026
  2. 1/2 repository: add core.indexLockTimeoutJun Wu, Oct 13, 2026
  3. D. Ben KnobleOct 13, 2026
  4. Jun WuOct 14, 2026
  5. D. Ben KnobleOct 14, 2026
  6. Junio C HamanoOct 13, 2026
  7. Jun WuOct 14, 2026
  8. Ben KnobleOct 19, 2026
  9. 2/2 commit: lock index before readingJun Wu, Oct 13, 2026
  10. Jeff KingOct 14, 2026
  11. Jun WuOct 15, 2026
  12. Junio C HamanoOct 13, 2026
  13. Jun WuOct 14, 2026
  14. Jeff KingOct 14, 2026
  15. 0/4 Wait for the index lock instead of failingJun Wu, Oct 17, 2026
  16. 1/4 repository: add repo_try_hold_locked_index()Jun Wu, Oct 17, 2026
  17. 2/4 repository: add core.indexLockTimeoutJun Wu, Oct 17, 2026
  18. 3/4 commit: fix write raceJun Wu, Oct 17, 2026
  19. 4/4 reset: fix write raceJun Wu, Oct 17, 2026
  20. Mihai CosmaOct 22, 2026

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.