]> rtime.felk.cvut.cz Git - git.git/blobdiff - builtin-clean.c
t7004: Use prerequisite tags to skip tests that need gpg
[git.git] / builtin-clean.c
index 6778a03ae4c901d216e4b91cd41f2073e0e98589..f78c2fb108bc667079290f9b2fa82f47da5eb34c 100644 (file)
 static int force = -1; /* unset */
 
 static const char *const builtin_clean_usage[] = {
-       "git-clean [-d] [-f] [-n] [-q] [-x | -X] [--] <paths>...",
+       "git clean [-d] [-f] [-n] [-q] [-x | -X] [--] <paths>...",
        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)
@@ -31,11 +31,11 @@ int cmd_clean(int argc, const char **argv, const char *prefix)
        int i;
        int show_only = 0, remove_directories = 0, quiet = 0, ignored = 0;
        int ignored_only = 0, baselen = 0, config_set = 0, errors = 0;
-       struct strbuf directory;
+       struct strbuf directory = STRBUF_INIT;
        struct dir_struct dir;
        const char *path, *base;
        static const char **pathspec;
-       struct strbuf buf;
+       struct strbuf buf = STRBUF_INIT;
        const char *qname;
        char *seen = NULL;
        struct option options[] = {
@@ -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
@@ -58,7 +58,6 @@ int cmd_clean(int argc, const char **argv, const char *prefix)
 
        argc = parse_options(argc, argv, options, builtin_clean_usage, 0);
 
-       strbuf_init(&buf, 0);
        memset(&dir, 0, sizeof(dir));
        if (ignored_only)
                dir.show_ignored = 1;
@@ -88,7 +87,6 @@ int cmd_clean(int argc, const char **argv, const char *prefix)
        if (baselen)
                path = base = xmemdupz(*pathspec, baselen);
        read_directory(&dir, path, base, baselen, pathspec);
-       strbuf_init(&directory, 0);
 
        if (pathspec)
                seen = xmalloc(argc > 0 ? argc : 1);