X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;ds=sidebyside;f=builtin-clean.c;h=48bf29f40a5e06fd588b34c468535e04abcf206b;hb=a14f6ca26a1f17a6aa1c4dd8994ca1e1bcbe1729;hp=fefec3010c434219234e7832051ada9ed2e52335;hpb=803d5158123346229d71de53818920efbc88ca0f;p=git.git diff --git a/builtin-clean.c b/builtin-clean.c index fefec3010..48bf29f40 100644 --- a/builtin-clean.c +++ b/builtin-clean.c @@ -15,15 +15,15 @@ static int force = -1; /* unset */ static const char *const builtin_clean_usage[] = { - "git-clean [-d] [-f] [-n] [-q] [-x | -X] [--] ...", + "git clean [-d] [-f] [-n] [-q] [-x | -X] [--] ...", NULL }; -static int git_clean_config(const char *var, const char *value) +static int git_clean_config(const char *var, const char *value, void *cb) { if (!strcmp(var, "clean.requireforce")) force = !git_config_bool(var, value); - return git_default_config(var, value); + return git_default_config(var, value, cb); } int cmd_clean(int argc, const char **argv, const char *prefix) @@ -50,7 +50,7 @@ int cmd_clean(int argc, const char **argv, const char *prefix) OPT_END() }; - git_config(git_clean_config); + git_config(git_clean_config, NULL); if (force < 0) force = 0; else @@ -95,7 +95,8 @@ int cmd_clean(int argc, const char **argv, const char *prefix) for (i = 0; i < dir.nr; i++) { struct dir_entry *ent = dir.entries[i]; - int len, pos, matches; + int len, pos; + int matches = 0; struct cache_entry *ce; struct stat st; @@ -127,18 +128,18 @@ int cmd_clean(int argc, const char **argv, const char *prefix) if (pathspec) { memset(seen, 0, argc > 0 ? argc : 1); - matches = match_pathspec(pathspec, ent->name, ent->len, + matches = match_pathspec(pathspec, ent->name, len, baselen, seen); - } else { - matches = 0; } if (S_ISDIR(st.st_mode)) { strbuf_addstr(&directory, ent->name); qname = quote_path_relative(directory.buf, directory.len, &buf, prefix); - if (show_only && (remove_directories || matches)) { + if (show_only && (remove_directories || + (matches == MATCHED_EXACTLY))) { printf("Would remove %s\n", qname); - } else if (remove_directories || matches) { + } else if (remove_directories || + (matches == MATCHED_EXACTLY)) { if (!quiet) printf("Removing %s\n", qname); if (remove_dir_recursively(&directory, 0) != 0) {