clean: consolidate handling of ignored parameters
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> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
parent
351ea1c3cb
commit
f7f5c6c0ba
@ -924,12 +924,6 @@ int cmd_clean(int argc, const char **argv, const char *prefix)
|
|||||||
0);
|
0);
|
||||||
|
|
||||||
memset(&dir, 0, sizeof(dir));
|
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 (!interactive && !dry_run && !force) {
|
||||||
if (config_set)
|
if (config_set)
|
||||||
die(_("clean.requireForce set to true and neither -i, -n, nor -f given; "
|
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;
|
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) {
|
if (argc) {
|
||||||
/*
|
/*
|
||||||
* Remaining args implies pathspecs specified, and we should
|
* 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)
|
if (read_cache() < 0)
|
||||||
die(_("index file corrupt"));
|
die(_("index file corrupt"));
|
||||||
|
|
||||||
if (!ignored)
|
|
||||||
setup_standard_excludes(&dir);
|
|
||||||
|
|
||||||
pl = add_pattern_list(&dir, EXC_CMDL, "--exclude option");
|
pl = add_pattern_list(&dir, EXC_CMDL, "--exclude option");
|
||||||
for (i = 0; i < exclude_list.nr; i++)
|
for (i = 0; i < exclude_list.nr; i++)
|
||||||
add_pattern(exclude_list.items[i].string, "", 0, pl, -(i+1));
|
add_pattern(exclude_list.items[i].string, "", 0, pl, -(i+1));
|
||||||
|
Loading…
Reference in New Issue
Block a user