From: Derrick Stolee Date: Wed, 03 Aug 2022 14:35:29 GMT Subject: Re: [PATCH v1 2/4] pathspec.h: move pathspec_needs_expanded_index() from reset.c to here Message-ID: <90f817f1-340d-48e0-22b1-c6644d62f19f@github.com> In-Reply-To: <20220803045118.1243087-3-shaoxuan.yuan02@gmail.com> On 8/3/2022 12:51 AM, Shaoxuan Yuan wrote: > Method pathspec_needs_expanded_index() in reset.c from 4d1cfc1351 > (reset: make --mixed sparse-aware, 2021-11-29) is reusable when we > need to verify if the index needs to be expanded when the command > is utilizing a pathspec rather than a literal path. > > Move it to pathspec.h for reusability. > > Add a few items to the function so it can better serve its purpose as > a standalone public function: > > * Add a check in front so if the index is not sparse, return early since > no expansion is needed. > > * Add documentation to the function. I took a look at this diff on my machine with --color-moved, which highlighted the other valuable thing about this move: it takes an arbitrary 'struct index_state' pointer instead of using the_index and active_cache. These are good things that might be worth mentioning in the commit message. Thanks, -Stolee