git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] checkout: don't check worktrees when not necessary

From
SBSpencer 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.

Previous: Duy NguyenNext: Nguyễn Thái Ngọc Duy
Message 3 of 5 in “checkout: don't check worktrees when not necessary”
  1. checkout: don't check worktrees when not necessarySpencer Baugh, May 31, 2015
  2. Duy NguyenJun 1, 2015
  3. Spencer BaughJun 10, 2015
  4. checkout: don't check worktrees when not necessaryNguyễn Thái Ngọc Duy, Jun 12, 2015
  5. Junio C HamanoJun 12, 2015

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.