Add branch --set-upstream
[gitweb.git] / builtin-clean.c
index e424b77e6b7367a5704d586ab38d34908684de55..3a70fa81bdd8f0e087476560f7c2f668a3cda0ea 100644 (file)
@@ -31,6 +31,7 @@ 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;
+       int rm_flags = REMOVE_DIR_KEEP_NESTED_GIT;
        struct strbuf directory = STRBUF_INIT;
        struct dir_struct dir;
        static const char **pathspec;
@@ -40,7 +41,7 @@ int cmd_clean(int argc, const char **argv, const char *prefix)
        struct option options[] = {
                OPT__QUIET(&quiet),
                OPT__DRY_RUN(&show_only),
-               OPT_BOOLEAN('f', NULL, &force, "force"),
+               OPT_BOOLEAN('f', "force", &force, "force"),
                OPT_BOOLEAN('d', NULL, &remove_directories,
                                "remove whole directories"),
                OPT_BOOLEAN('x', NULL, &ignored, "remove ignored files, too"),
@@ -69,6 +70,9 @@ int cmd_clean(int argc, const char **argv, const char *prefix)
                die("clean.requireForce%s set and -n or -f not given; "
                    "refusing to clean", config_set ? "" : " not");
 
+       if (force > 1)
+               rm_flags = 0;
+
        dir.flags |= DIR_SHOW_OTHER_DIRECTORIES;
 
        if (read_cache() < 0)
@@ -133,7 +137,8 @@ int cmd_clean(int argc, const char **argv, const char *prefix)
                                   (matches == MATCHED_EXACTLY)) {
                                if (!quiet)
                                        printf("Removing %s\n", qname);
-                               if (remove_dir_recursively(&directory, 0) != 0) {
+                               if (remove_dir_recursively(&directory,
+                                                          rm_flags) != 0) {
                                        warning("failed to remove '%s'", qname);
                                        errors++;
                                }