git-reset: Let -q hush "locally modified" messages
[gitweb.git] / builtin-rm.c
index bca2bd97036fdaf2e2bf99e308ba62e1acf4d9e8..ee8247b08cd007f73d5dfffa560a9efe33d327b9 100644 (file)
@@ -11,7 +11,7 @@
 #include "parse-options.h"
 
 static const char * const builtin_rm_usage[] = {
-       "git-rm [options] [--] <file>...",
+       "git rm [options] [--] <file>...",
        NULL
 };
 
@@ -144,17 +144,20 @@ int cmd_rm(int argc, const char **argv, const char *prefix)
        const char **pathspec;
        char *seen;
 
-       git_config(git_default_config);
+       git_config(git_default_config, NULL);
+
+       argc = parse_options(argc, argv, builtin_rm_options, builtin_rm_usage, 0);
+       if (!argc)
+               usage_with_options(builtin_rm_usage, builtin_rm_options);
+
+       if (!index_only)
+               setup_work_tree();
 
        newfd = hold_locked_index(&lock_file, 1);
 
        if (read_cache() < 0)
                die("index file corrupt");
 
-       argc = parse_options(argc, argv, builtin_rm_options, builtin_rm_usage, 0);
-       if (!argc)
-               usage_with_options(builtin_rm_usage, builtin_rm_options);
-
        pathspec = get_pathspec(prefix, argv);
        seen = NULL;
        for (i = 0; pathspec[i] ; i++)
@@ -247,7 +250,7 @@ int cmd_rm(int argc, const char **argv, const char *prefix)
 
        if (active_cache_changed) {
                if (write_cache(newfd, active_cache, active_nr) ||
-                   close(newfd) || commit_locked_index(&lock_file))
+                   commit_locked_index(&lock_file))
                        die("Unable to write new index file");
        }