On Fri, Apr 22, 2016 at 9:01 AM, Nguyễn Thái Ngọc Duy <pclouds@xxxxxxxxx> wrote: > Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@xxxxxxxxx> > --- > diff --git a/worktree.c b/worktree.c > @@ -147,6 +150,25 @@ done: > +static void mark_current_worktree(struct worktree **worktrees) > +{ > + struct strbuf git_dir = STRBUF_INIT; > + struct strbuf path = STRBUF_INIT; > + int i; > + > + strbuf_addstr(&git_dir, absolute_path(get_git_dir())); This could also just be: char *git_dir = xstrdup(absolute_path(...)); with a corresponding 'free(git_dir)' below. > + for (i = 0; worktrees[i]; i++) { > + struct worktree *wt = worktrees[i]; > + strbuf_addstr(&path, absolute_path(get_worktree_git_dir(wt))); > + wt->is_current = !fspathcmp(git_dir.buf, path.buf); Similarly, it looks like 'path' doesn't need to be a strbuf at all since the result of absolute_path() should remain valid long enough for fspathcmp(). It could just be: const char *path = absolute_path(...); wt->is_current = !fspathcmp(git_dir, path); But these are very minor; probably not worth a re-roll. > + strbuf_reset(&path); > + if (wt->is_current) > + break; > + } > + strbuf_release(&git_dir); > + strbuf_release(&path); > +} -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html