diff options
author | Junio C Hamano <gitster@pobox.com> | 2016-06-20 11:01:02 -0700 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2016-06-20 11:01:02 -0700 |
commit | 6d41eb685a709b405ba0119453aaad3ad3888b7c (patch) | |
tree | ee256b65976d8f27492500356b6a38aa3f57dd28 /builtin | |
parent | 1b3d14c1c89d8ad61be97a1f2d2606a07b25872b (diff) | |
parent | 1a450e2fd1f82311b214851d5b097b74c8fb0ade (diff) | |
download | git-6d41eb685a709b405ba0119453aaad3ad3888b7c.tar.gz git-6d41eb685a709b405ba0119453aaad3ad3888b7c.tar.xz |
Merge branch 'jg/dash-is-last-branch-in-worktree-add'
"git worktree add" learned that '-' can be used as a short-hand for
"@{-1}", the previous branch.
* jg/dash-is-last-branch-in-worktree-add:
worktree: allow "-" short-hand for @{-1} in add command
Diffstat (limited to 'builtin')
-rw-r--r-- | builtin/worktree.c | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/builtin/worktree.c b/builtin/worktree.c index 96a2834a1..e3199a22e 100644 --- a/builtin/worktree.c +++ b/builtin/worktree.c @@ -340,6 +340,9 @@ static int add(int ac, const char **av, const char *prefix) path = prefix ? prefix_filename(prefix, strlen(prefix), av[0]) : av[0]; branch = ac < 2 ? "HEAD" : av[1]; + if (!strcmp(branch, "-")) + branch = "@{-1}"; + opts.force_new_branch = !!new_branch_force; if (opts.force_new_branch) { struct strbuf symref = STRBUF_INIT; |