From: Eric Sunshine <sunshine@sunshineco.com>
To: git@vger.kernel.org
Cc: Duy Nguyen <pclouds@gmail.com>,
Cameron Gunnin <cameron.gunnin@synopsys.com>,
Eric Sunshine <sunshine@sunshineco.com>
Subject: [PATCH 0/3] git-worktree: fix "add" being fooled by suffix matching
Date: Mon, 24 Feb 2020 04:08:45 -0500 [thread overview]
Message-ID: <20200224090848.54321-1-sunshine@sunshineco.com> (raw)
In-Reply-To: <CAPig+cQh8hxeoVjLHDKhAcZVQPpPT5v0AUY8gsL9=qfJ7z-L2A@mail.gmail.com>
"git worktree add <path>" performs various checks before approving
<path> as a valid location for the new worktree. One such check is
asking whether <path> is already a registered worktree. Unfortunately,
this check can be fooled by the magic suffix matching performed by
find_worktree() as a convenience to minimize typing when identifying
worktrees on the command-line.
That the check could be fooled was a known issue, and a special-case
work-around for accidental matching against the main worktree was
already in place even when the validation check was first
implemented[1]. Since that time, an additional case of accidental suffix
matching has been reported[2], which was not covered by the existing
special case.
Rather than adding more band-aids to the validation to work around magic
matching performed by find_worktree(), this patch series fixes the
problem once and for all by locating a worktree deterministically based
only on pathname.
[1]: https://lore.kernel.org/git/CAPig+cQh8hxeoVjLHDKhAcZVQPpPT5v0AUY8gsL9=qfJ7z-L2A@mail.gmail.com/
[2]: https://lore.kernel.org/git/0308570E-AAA3-43B8-A592-F4DA9760DBED@synopsys.com/
Eric Sunshine (3):
worktree: improve find_worktree() documentation
worktree: add utility to find worktree by pathname
worktree: don't allow "add" validation to be fooled by suffix matching
builtin/worktree.c | 9 +--------
t/t2400-worktree-add.sh | 9 +++++++++
worktree.c | 16 ++++++++++------
worktree.h | 20 ++++++++++++++++++--
4 files changed, 38 insertions(+), 16 deletions(-)
--
2.25.1.526.gf05a752211
next prev parent reply other threads:[~2020-02-24 9:13 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-02-11 23:50 BUG: git worktree add directory-path fails due to over-aggressive disallowing of worktrees with same suffix Cameron Gunnin
2019-02-12 22:44 ` Eric Sunshine
2020-02-24 9:08 ` Eric Sunshine [this message]
2020-02-24 9:08 ` [PATCH 1/3] worktree: improve find_worktree() documentation Eric Sunshine
2020-02-24 9:08 ` [PATCH 2/3] worktree: add utility to find worktree by pathname Eric Sunshine
2020-02-24 9:08 ` [PATCH 3/3] worktree: don't allow "add" validation to be fooled by suffix matching Eric Sunshine
2020-02-24 21:06 ` Junio C Hamano
2020-02-24 21:02 ` [PATCH 0/3] git-worktree: fix "add" being " Junio C Hamano
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200224090848.54321-1-sunshine@sunshineco.com \
--to=sunshine@sunshineco.com \
--cc=cameron.gunnin@synopsys.com \
--cc=git@vger.kernel.org \
--cc=pclouds@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).