Re: [PATCH 5/5] worktree: add "unlock" command
- From
Eric Sunshine <sunshine@sunshineco.com>
- Date
- May 16, 2016, 00:42 UTC
- Message-ID
- <CAPig+cSN284FS6P_hS0FRe5+JfQ9+=XYPezEKxL18BVwwifJfg@mail.gmail.com>
- In-Reply-To
- <20160510141729.23063-5-pclouds@gmail.com>
On Tue, May 10, 2016 at 10:17 AM, Nguyễn Thái Ngọc Duy <pclouds@gmail.com> wrote:
Show 22 quoted lines
> Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
> ---
> diff --git a/builtin/worktree.c b/builtin/worktree.c
> @@ -498,6 +499,34 @@ static int lock_worktree(int ac, const char **av, const char *prefix)
> +static int unlock_worktree(int ac, const char **av, const char *prefix)
> +{
> + struct option options[] = {
> + OPT_END()
> + };
> + struct worktree **worktrees, *wt;
> + struct strbuf dst = STRBUF_INIT;
> +
> + ac = parse_options(ac, av, prefix, options, worktree_usage, 0);
> + if (ac != 1)
> + usage_with_options(worktree_usage, options);
> +
> + strbuf_addstr(&dst, prefix_filename(prefix,
> + strlen(prefix),
> + av[0]));
> +
> + worktrees = get_worktrees();
> + wt = find_worktree_by_path(worktrees, dst.buf);strbuf_release(&dst);
Show 9 quoted lines
> + if (!wt)
> + die(_("'%s' is not a working directory"), av[0]);
> + if (is_main_worktree(wt))
> + die(_("'%s' is a main working directory"), av[0]);
> + if (!is_worktree_locked(wt))
> + die(_("not locked"));
> +
> + return unlink_or_warn(git_common_path("worktrees/%s/locked", wt->id));
> +}