Re: [PATCH v2 04/12] worktree.c: mark current worktree
- From
Eric Sunshine <sunshine@sunshineco.com>
- Date
- Apr 21, 2016, 07:20 UTC
- Message-ID
- <CAPig+cR99Nx=dk+zT2Jgpr2ZgYM4v0q2vX7v6TXmWHU5k6ga3w@mail.gmail.com>
- In-Reply-To
- <1461158693-21289-5-git-send-email-pclouds@gmail.com>
On Wed, Apr 20, 2016 at 9:24 AM, Nguyễn Thái Ngọc Duy <pclouds@gmail.com> wrote:
Show 13 quoted lines
> 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?
Show 6 quoted lines
> + strbuf_reset(&path); > + if (wt->is_current) > + break; > + } > + strbuf_release(&git_dir); > + strbuf_release(&path);
Minor: Would it make sense to place this new code in its own function -- say, mark_current_worktree() -- to keep get_worktrees() from becoming overlong?
> return list; > }