From: Elijah Newren <newren@gmail.com>
To: git@vger.kernel.org
Cc: sxlijin@gmail.com, peff@peff.net, Elijah Newren <newren@gmail.com>
Subject: [RFC PATCH 0/7] Fix `git clean` with pathspecs
Date: Thu, 5 Apr 2018 10:34:39 -0700 [thread overview]
Message-ID: <20180405173446.32372-1-newren@gmail.com> (raw)
Sometimes, multiple `git clean $ARGS` invocations (with the exact same
flags and parameters for each invocation) are needed to properly clean
out the desired files. Sometimes, `git clean $PATHS` just refuses to
clean the files it was explicitly told to clean. This patch series
aims to address these (very old) problems.
I was made aware of the problems when a user brought to me the
following testcase:
mkdir d{1,2}
touch d{1,2}/ut
touch d1/t
git add d1/t
With this setup, the user would need to run
git clean -ffd */ut
twice to delete both ut files. Digging further, I found multiple
interesting variants.
However, I am still slightly unsure of what the correct behavior is
supposed to be for one particular case, namely, if the clean command
were instead:
git clean -f '*ut'
(note that the glob is quoted to protect from shell expansion, and
that the -d option was removed), should the files still be cleaned? I
assumed yes and implemented that in patches 5-6, but the commit message
discusses this case, and patch 7 exists to change the implementation
to answer this question with a 'no'. Patch 7 should NOT should not be
accepted as-is -- it should either be dropped or squashed into earlier
commits, but which depends on the desired behavior.
Patches 1-2 are almost independent one-line fixes that could be
submitted independently. However, if we decide to keep the changes
from patch 7, then this series does depend on patch 2 for the tests to
pass.
Patch 3 adds four new testcases covering the variants I noticed.
Patch 4 fixes clean with explicit pathspecs and the -d option.
Patches 5-7 fixes clean with explicit pathspecs without the -d option.
Elijah Newren (7):
dir.c: Fix typo in comment
dir.c: fix off-by-one error in match_pathspec_item
t7300: Add some testcases showing failure to clean specified pathspecs
dir: Directories should be checked for matching pathspecs too
dir: Make the DO_MATCH_SUBMODULE code reusable for a non-submodule
case
dir: If our pathspec might match files under a dir, recurse into it
If we do not want globs to recurse into subdirs without -d...
dir.c | 23 +++++++++++++++--------
dir.h | 5 +++--
t/t7300-clean.sh | 32 ++++++++++++++++++++++++++++++++
3 files changed, 50 insertions(+), 10 deletions(-)
--
2.17.0.7.g0b50f94d69
next reply other threads:[~2018-04-05 17:35 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-04-05 17:34 Elijah Newren [this message]
2018-04-05 17:34 ` [RFC PATCH 1/7] dir.c: Fix typo in comment Elijah Newren
2018-04-05 17:34 ` [RFC PATCH 2/7] dir.c: fix off-by-one error in match_pathspec_item Elijah Newren
2018-04-05 17:49 ` Jeff King
2018-04-05 18:36 ` Elijah Newren
2018-04-05 19:04 ` Jeff King
2018-04-05 20:06 ` Elijah Newren
2018-04-06 17:53 ` Jeff King
2018-04-05 17:34 ` [RFC PATCH 3/7] t7300: Add some testcases showing failure to clean specified pathspecs Elijah Newren
2018-04-05 17:34 ` [RFC PATCH 4/7] dir: Directories should be checked for matching pathspecs too Elijah Newren
2018-04-05 18:58 ` Jeff King
2018-04-05 19:15 ` Elijah Newren
2018-04-05 19:31 ` Jeff King
2018-04-09 2:07 ` Junio C Hamano
2018-04-05 17:34 ` [RFC PATCH 5/7] dir: Make the DO_MATCH_SUBMODULE code reusable for a non-submodule case Elijah Newren
2018-04-05 17:34 ` [RFC PATCH 6/7] dir: If our pathspec might match files under a dir, recurse into it Elijah Newren
2018-04-05 17:34 ` [RFC PATCH 7/7] If we do not want globs to recurse into subdirs without -d Elijah Newren
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=20180405173446.32372-1-newren@gmail.com \
--to=newren@gmail.com \
--cc=git@vger.kernel.org \
--cc=peff@peff.net \
--cc=sxlijin@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.