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!