Re: [PATCH v2 04/12] worktree.c: mark current worktree
- From
Duy Nguyen <pclouds@gmail.com>
- Date
- Apr 21, 2016, 09:33 UTC
- Message-ID
- <CACsJy8ATaYx0Fk-7HK9Rz_o687hxCLuOJYJ6DkBd4Xk8sP+byw@mail.gmail.com>
- In-Reply-To
- <CACsJy8DwzfsPthWy6pG2t0cGVT0kcrJT7xWdyvs+0EPFDbNtSQ@mail.gmail.com>
On Thu, Apr 21, 2016 at 3:19 PM, Duy Nguyen <pclouds@gmail.com> wrote:
Show 24 quoted lines
> On Thu, Apr 21, 2016 at 2:20 PM, Eric Sunshine <sunshine@sunshineco.com> wrote:
>> On Wed, Apr 20, 2016 at 9:24 AM, Nguyễn Thái Ngọc Duy <pclouds@gmail.com> wrote:
>>> Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
>>> ---
>>> diff --git a/worktree.c b/worktree.c
>>> @@ -178,6 +182,18 @@ struct worktree **get_worktrees(void)
>>> }
>>> ALLOC_GROW(list, counter + 1, alloc);
>>> list[counter] = NULL;
>>> +
>>> + strbuf_addstr(&git_dir, absolute_path(get_git_dir()));
>>> + for (i = 0; i < counter; i++) {
>>> + struct worktree *wt = list[i];
>>> + strbuf_addstr(&path, absolute_path(get_worktree_git_dir(wt)));
>>> + wt->is_current = !strcmp_icase(git_dir.buf, path.buf);
>>
>> Can you talk a bit about why this uses 'icase'? Should it be
>> respecting cache.h:ignore_case?
>
> It does.That function (in dir.c) is just one-liner
>
> return ignore_case ? strcasecmp(a, b) : strcmp(a, b);
>
> I admit though, the naming does not make that clear.While we're at it, how about renaming it to pathcmp (and its friend strncmp_icase to pathncmp)?
-- Duy