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

[PATCH v2 0/2] Handle git_path() with lock files correctly in worktrees

From
Johannes Schindelin via GitGitGadget <gitgitgadget@gmail.com>
Date
Oct 17, 2019, 22:07 UTC
Message-ID
<pull.401.v2.git.1571350077.gitgitgadget@gmail.com>
In-Reply-To
<pull.401.git.1571209637.gitgitgadget@gmail.com>

I stumbled over this during my recent work in Git GUI [https://github.com/gitgitgadget/git/pull/361] that was originally really only intended to use the correct hooks directory.

It turns out that my fears that index.lock was mishandled were unfounded, hence this patch series has a lot lower priority for me than "OMG we must push this into v2.24.0!".

Technically, the first patch is not needed (because I decided against adding a test to t1400 in the end, in favor of t1500), but it shouldn't hurt, either.

Changes since v1:
 * Clarified the commit message to state that index.lock is fine, it is 
   logs/HEAD.lock that isn't.
Johannes Schindelin (2):
  t1400: wrap setup code in test case
  git_path(): handle `.lock` files correctly
 path.c                |  4 ++--
 t/t1400-update-ref.sh | 18 ++++++++++--------
 t/t1500-rev-parse.sh  | 15 +++++++++++++++
 3 files changed, 27 insertions(+), 10 deletions(-)
base-commit: 108b97dc372828f0e72e56bbb40cae8e1e83ece6
Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-401%2Fdscho%2Flock-files-in-worktrees-v2
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-401/dscho/lock-files-in-worktrees-v2
Pull-Request: https://github.com/gitgitgadget/git/pull/401
Range-diff vs v1:
 1:  cf97c5182e = 1:  cf97c5182e t1400: wrap setup code in test case
 2:  f08c90ea02 ! 2:  93dba5a3a3 git_path(): handle `.lock` files correctly
     @@ -3,8 +3,9 @@
          git_path(): handle `.lock` files correctly
      
          Ever since worktrees were introduced, the `git_path()` function _really_
     -    needed to be called e.g. to get at the `index`. However, the wrong path
     -    is returned for `index.lock`.
     +    needed to be called e.g. to get at the path to `logs/HEAD` (`HEAD` is
     +    specific to the worktree). However, the wrong path is returned for
     +    `logs/HEAD.lock`.
      
          This does not matter as long as the Git executable is doing the asking,
          as the path for that `index.lock` file is constructed from
     @@ -13,10 +14,12 @@
          However, Git GUI just learned to use `--git-path` instead of appending
          relative paths to what `git rev-parse --git-dir` returns (and as a
          consequence not only using the correct hooks directory, but also using
     -    the correct paths in worktrees other than the main one). And one of the
     -    paths it is looking for is... you guessed it... `index.lock`.
     +    the correct paths in worktrees other than the main one). While it does
     +    not seem as if Git GUI in particular is asking for `logs/HEAD.lock`,
     +    let's be safe rather than sorry.
      
     -    So let's make that work as script writers would expect it to.
     +    Side note: Git GUI _does_ ask for `index.lock`, but that is already
     +    resolved correctly.
      
          Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
      
-- 
gitgitgadget
Previous: Johannes SchindelinNext: Johannes Schindelin via GitGitGadget
Message 13 of 31 in “Handle git_path() with lock files correctly in worktrees”
  1. 0/2 Handle git_path() with lock files correctly in worktreesJohannes Schindelin via GitGitGadget, Oct 16, 2019
  2. 1/2 t1400: wrap setup code in test caseJohannes Schindelin via GitGitGadget, Oct 16, 2019
  3. 2/2 git_path(): handle `.lock` files correctlyJohannes Schindelin via GitGitGadget, Oct 16, 2019
  4. SZEDER GáborOct 16, 2019
  5. Junio C HamanoOct 17, 2019
  6. Johannes SchindelinOct 17, 2019
  7. SZEDER GáborOct 18, 2019
  8. SZEDER GáborOct 18, 2019
  9. 0/2 path.c: minor common_list fixesSZEDER Gábor, Oct 18, 2019
  10. 1/2 path.c: fix field name in 'struct common_dir'SZEDER Gábor, Oct 18, 2019
  11. 2/2 path.c: mark 'logs/HEAD' in 'common_list' as fileSZEDER Gábor, Oct 18, 2019
  12. Johannes SchindelinOct 21, 2019
  13. 0/2 Handle git_path() with lock files correctly in worktreesJohannes Schindelin via GitGitGadget, Oct 17, 2019
  14. 1/2 t1400: wrap setup code in test caseJohannes Schindelin via GitGitGadget, Oct 17, 2019
  15. 2/2 git_path(): handle `.lock` files correctlyJohannes Schindelin via GitGitGadget, Oct 17, 2019
  16. Junio C HamanoOct 18, 2019
  17. SZEDER GáborOct 18, 2019
  18. Johannes SchindelinOct 21, 2019
  19. Junio C HamanoOct 23, 2019
  20. 0/2 Handle git_path() with lock files correctly in worktreesJohannes Schindelin via GitGitGadget, Oct 21, 2019
  21. 1/2 t1400: wrap setup code in test caseJohannes Schindelin via GitGitGadget, Oct 21, 2019
  22. 2/2 git_path(): handle `.lock` files correctlyJohannes Schindelin via GitGitGadget, Oct 21, 2019
  23. SZEDER GáborOct 22, 2019
  24. Junio C HamanoOct 23, 2019
  25. Johannes SchindelinOct 28, 2019
  26. SZEDER GáborOct 28, 2019
  27. Junio C HamanoOct 28, 2019
  28. 0/2 Handle git_path() with lock files correctly in worktreesJohannes Schindelin via GitGitGadget, Oct 28, 2019
  29. 1/2 t1400: wrap setup code in test caseJohannes Schindelin via GitGitGadget, Oct 28, 2019
  30. 2/2 git_path(): handle `.lock` files correctlyJohannes Schindelin via GitGitGadget, Oct 28, 2019
  31. Junio C HamanoOct 29, 2019

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.