From: "Elijah Newren via GitGitGadget" <gitgitgadget@gmail.com>
To: git@vger.kernel.org
Cc: bmalehorn@gmail.com, Elijah Newren <newren@gmail.com>,
Elijah Newren <newren@gmail.com>
Subject: [PATCH 3/4] clean: consolidate handling of ignored parameters
Date: Thu, 11 Jun 2020 06:59:32 +0000 [thread overview]
Message-ID: <e6c700b3b4fa064c6a78e6d3ab262cf105b0e1e4.1591858774.git.gitgitgadget@gmail.com> (raw)
In-Reply-To: <pull.806.git.git.1591858774.gitgitgadget@gmail.com>
From: Elijah Newren <newren@gmail.com>
I spent a long time trying to figure out how and whether the code worked
with different values of ignore, ignore_only, and remove_directories.
After lots of time setting up lots of testcases, sifting through lots of
print statements, and walking through the debugger, I finally realized
that one piece of code related to how it was all setup was found in
clean.c rather than dir.c. Make a change that would have made it easier
for me to do the extra testing by putting this handling in one spot.
Signed-off-by: Elijah Newren <newren@gmail.com>
---
builtin/clean.c | 16 +++++++---------
1 file changed, 7 insertions(+), 9 deletions(-)
diff --git a/builtin/clean.c b/builtin/clean.c
index 3ca940f83a2..1be437bd5a3 100644
--- a/builtin/clean.c
+++ b/builtin/clean.c
@@ -924,12 +924,6 @@ int cmd_clean(int argc, const char **argv, const char *prefix)
0);
memset(&dir, 0, sizeof(dir));
- if (ignored_only)
- dir.flags |= DIR_SHOW_IGNORED;
-
- if (ignored && ignored_only)
- die(_("-x and -X cannot be used together"));
-
if (!interactive && !dry_run && !force) {
if (config_set)
die(_("clean.requireForce set to true and neither -i, -n, nor -f given; "
@@ -946,6 +940,13 @@ int cmd_clean(int argc, const char **argv, const char *prefix)
dir.flags |= DIR_SHOW_OTHER_DIRECTORIES;
+ if (ignored && ignored_only)
+ die(_("-x and -X cannot be used together"));
+ if (!ignored)
+ setup_standard_excludes(&dir);
+ if (ignored_only)
+ dir.flags |= DIR_SHOW_IGNORED;
+
if (argc) {
/*
* Remaining args implies pathspecs specified, and we should
@@ -960,9 +961,6 @@ int cmd_clean(int argc, const char **argv, const char *prefix)
if (read_cache() < 0)
die(_("index file corrupt"));
- if (!ignored)
- setup_standard_excludes(&dir);
-
pl = add_pattern_list(&dir, EXC_CMDL, "--exclude option");
for (i = 0; i < exclude_list.nr; i++)
add_pattern(exclude_list.items[i].string, "", 0, pl, -(i+1));
--
gitgitgadget
next prev parent reply other threads:[~2020-06-11 6:59 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-06-11 6:59 [PATCH 0/4] Clean cleanups Elijah Newren via GitGitGadget
2020-06-11 6:59 ` [PATCH 1/4] dir: fix a few confusing comments Elijah Newren via GitGitGadget
2020-06-11 6:59 ` [PATCH 2/4] dir, clean: avoid disallowed behavior Elijah Newren via GitGitGadget
2020-06-11 6:59 ` Elijah Newren via GitGitGadget [this message]
2020-06-11 6:59 ` [PATCH 4/4] clean: optimize and document cases where we recurse into subdirectories Elijah Newren via GitGitGadget
2020-06-13 0:28 ` Junio C Hamano
2020-06-18 6:19 ` Brian Malehorn
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=e6c700b3b4fa064c6a78e6d3ab262cf105b0e1e4.1591858774.git.gitgitgadget@gmail.com \
--to=gitgitgadget@gmail.com \
--cc=bmalehorn@gmail.com \
--cc=git@vger.kernel.org \
--cc=newren@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).