Re: [PATCH] checkout: don't check worktrees when not necessary
- From
- Spencer Baugh <catern@catern.com>
- Date
- Jun 10, 2015, 19:21 UTC
- Message-ID
- <87zj47gyif.fsf@earth.i-did-not-set--mail-host-address--so-tickle-me>
- In-Reply-To
- <20150601102317.GA20607@lanh>
Duy Nguyen <pclouds@gmail.com> writes:
Show 22 quoted lines
> On Sun, May 31, 2015 at 07:16:29PM -0400, Spencer Baugh wrote:
>> --- a/builtin/checkout.c
>> +++ b/builtin/checkout.c
>> @@ -1237,6 +1237,7 @@ static int parse_branchname_arg(int argc, const char **argv,
>> char *head_ref = resolve_refdup("HEAD", 0, sha1, &flag);
>> if (head_ref &&
>> (!(flag & REF_ISSYMREF) || strcmp(head_ref, new->path)) &&
>> + !(opts->patch_mode || opts->pathspec.nr) &&
>> !opts->ignore_other_worktrees)
>> check_linked_checkouts(new);
>> free(head_ref);
>
> Simple and effective. But if in future we add more options for
> non-switching-branch checkout, we need to update both places, here and
> near the end of cmd_checkout().
>
> Perhaps we can move all this block inside checkout_branch() so we only
> need to test "opts->patch_mode || opts->pathspec.nr" once, at the end
> of cmd_checkout(). Something like below?
>
> I'm not opposed to your change, but if you go with it, you should
> cherry pick my test in the below patch. Or create a similar test.Sorry for late reply, but I think your change is much better than mine so I'd suggest just using that instead.