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

Re: [PATCH v1] worktree: integrate with sparse-index

From
Victoria Dye <vdye@github.com>
Date
Jun 6, 2023, 04:22 UTC
Message-ID
<523de20d-a816-5101-af82-5bfff26fbcac@github.com>
In-Reply-To
<CAMO4yUEQZz8DqPb7RyN8Owb=23p==6XS6G7Bza77p4-iydo6Qg@mail.gmail.com>
Shuqi Liang wrote:
Show 17 quoted lines
>>> +test_expect_success 'worktree is not expanded' '
>>> +     init_repos &&
>>> +
>>> +     test_all_match git worktree add .worktrees/hotfix &&
>>
>> Shouldn't 'git worktree add' not expand the index? Why use 'test_all_match'
>> instead of 'ensure_not_expanded'?
> 
> Here's my perspective on why my use of "test_all_match" instead of
> "ensure_not_expanded" in "git worktree add":
> 
> The functions "validate_no_submodules" and "check_clean_worktree" are
> specifically related to the "git worktree remove" command, and "git
> worktree add" doesn't require index reading, so with or without the
> "ensure_full_index" wouldn't affect the "git worktree add" command.
> I look forward to hearing your thoughts regarding whether my
> understanding is correct or not.

I see, thanks for the explanation. I could understand it both ways: on one hand, you don't want redundant/unnecessary tests; on the other hand, that test design decision relies pretty heavily on knowing the internal implementation details, which the tests conceptually shouldn't have visibility to.

I'd still lean towards using 'ensure_not_expanded' (it protects us from future changes causing index expansion, although that seems fairly unlikely). However, if you do choose to stick with not using 'ensure_not_expanded', I'd recommend using 'git -C sparse-index worktree add .worktrees/hotfix' instead of 'test_all_match'. The 'worktree' test already compares behavior across the three test repositories; to keep things focused on index expansion, only the 'sparse-index' repo should be set up & tested.

> 
> Thanks for your valuable feedback!
Previous: Shuqi LiangNext: Shuqi Liang
Message 4 of 6 in “worktree: integrate with sparse-index”
  1. worktree: integrate with sparse-indexShuqi Liang, Jun 5, 2023
  2. Victoria DyeJun 5, 2023
  3. Shuqi LiangJun 5, 2023
  4. Victoria DyeJun 6, 2023
  5. worktree: integrate with sparse-indexShuqi Liang, Jun 6, 2023
  6. Victoria DyeJun 7, 2023

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.