Re: [PATCH v1 2/4] pathspec.h: move pathspec_needs_expanded_index() from reset.c to here
- From
Shaoxuan Yuan <shaoxuan.yuan02@gmail.com>
- Date
- Aug 5, 2022, 07:53 UTC
- Message-ID
- <892e718a-f9ab-51d9-619f-7aa661ddcda6@gmail.com>
- In-Reply-To
- <90f817f1-340d-48e0-22b1-c6644d62f19f@github.com>
On 8/3/2022 10:35 PM, Derrick Stolee wrote: > 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 for pointing it out! Will add.
-- Thanks, Shaoxuan