worktree: add --guess-remote flag to add subcommand
commit71d6682d8ca9870cbe457cf55c83402c33b41030
authorThomas Gummerer <t.gummerer@gmail.com>
Wed, 29 Nov 2017 20:04:50 +0000 (29 20:04 +0000)
committerJunio C Hamano <gitster@pobox.com>
Wed, 6 Dec 2017 17:47:35 +0000 (6 09:47 -0800)
tree23fe7176c9dc953f64acb55d96b852aded935a57
parent4e8533319760c1e9255c56c2059c721286dc8dab
worktree: add --guess-remote flag to add subcommand

Currently 'git worktree add <path>' creates a new branch named after the
basename of the <path>, that matches the HEAD of whichever worktree we
were on when calling "git worktree add <path>".

It's sometimes useful to have 'git worktree add <path> behave more like
the dwim machinery in 'git checkout <new-branch>', i.e. check if the new
branch name, derived from the basename of the <path>, uniquely matches
the branch name of a remote-tracking branch, and if so check out that
branch and set the upstream to the remote-tracking branch.

Add a new --guess-remote option that enables exactly that behaviour.

Signed-off-by: Thomas Gummerer <t.gummerer@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Documentation/git-worktree.txt
builtin/worktree.c
t/t2025-worktree-add.sh