From: Derrick Stolee Date: Wed, 24 Aug 2022 19:08:10 GMT Subject: Re: [PATCH v1 1/2] builtin/grep.c: add --sparse option Message-ID: In-Reply-To: <74ff1a97-fa98-7280-9d84-35dafaf3cb3d@gmail.com> On 8/24/2022 2:20 PM, Shaoxuan Yuan wrote: > Hi reviewrs, > > I came back from busying with relocation :) Welcome back! I'm looking forward to overlapping our timezones a bit more. > On 8/17/2022 10:12 PM, Derrick Stolee wrote: >> On 8/17/2022 3:56 AM, Shaoxuan Yuan wrote: >>> Add a --sparse option to `git-grep`. This option is mainly used to: >> Or something like that. The documentation updates will also help clarify >> what happens when '--cached' is not included. I assume '--sparse' is >> ignored, but perhaps it _could_ allow looking at the cached files outside >> the sparse-checkout definition, this could make the simpler invocation of >> 'git grep --sparse ' be the way that users can search after their >> attempt to search the worktree failed. > > This simpler version was in my earlier local branch, but later I > decided not to go with it. I found the difference between these two > approaches, is that "--cached --sparse" is more correct in terms of > how Git actually works (because sparsity is a concept in the index); > and "--sparse" is more comfortable for the end user. > > I found the former one better here, because it is more self-explanatory, > and thus more info for the user, i.e. "you are now looking at the > index, and Git will also consider files outside of sparse definition." > > To be honest, I don't know which one is "better", but I think I'll > keep the current implementation unless something more convincing shows > up later. I think it is fine for you to keep the "--sparse requires --cached" approach that you have now, since we can always choose to extend the options to allow --sparse without --cached later. Thanks, -Stolee