Thread (6 messages) 6 messages, 2 authors, 2023-06-07

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

From: Victoria Dye <hidden>
Date: 2023-06-06 04:22:58

Shuqi Liang wrote:
quoted
quoted
+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!
  
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help