Add the WITH_P4IMPORT knob to the Makefile.
[gitweb.git] / builtin-rm.c
index 5b078c41943c9ce0ff1983896e8ad6ae38705f60..bf42003a7e79f96bf4964b116ddd3ee79350e682 100644 (file)
@@ -10,7 +10,7 @@
 #include "tree-walk.h"
 
 static const char builtin_rm_usage[] =
-"git-rm [-n] [-f] [--cached] <filepattern>...";
+"git-rm [-f] [-n] [-r] [--cached] [--] <file>...";
 
 static struct {
        int nr, alloc;
@@ -32,6 +32,10 @@ static int remove_file(const char *name)
        char *slash;
 
        ret = unlink(name);
+       if (ret && errno == ENOENT)
+               /* The user has removed it from the filesystem by hand */
+               ret = errno = 0;
+
        if (!ret && (slash = strrchr(name, '/'))) {
                char *n = xstrdup(name);
                do {
@@ -85,20 +89,10 @@ static int check_local_mod(unsigned char *head)
                if (ce_match_stat(ce, &st, 0))
                        errs = error("'%s' has local modifications "
                                     "(hint: try -f)", ce->name);
-               if (no_head)
-                       continue;
-               /*
-                * It is Ok to remove a newly added path, as long as
-                * it is cache-clean.
-                */
-               if (get_tree_entry(head, name, sha1, &mode))
-                       continue;
-               /*
-                * Otherwise make sure the version from the HEAD
-                * matches the index.
-                */
-               if (ce->ce_mode != create_ce_mode(mode) ||
-                   hashcmp(ce->sha1, sha1))
+               if (no_head
+                    || get_tree_entry(head, name, sha1, &mode)
+                    || ce->ce_mode != create_ce_mode(mode)
+                    || hashcmp(ce->sha1, sha1))
                        errs = error("'%s' has changes staged in the index "
                                     "(hint: try -f)", name);
        }
@@ -204,7 +198,7 @@ int cmd_rm(int argc, const char **argv, const char *prefix)
                return 0;
 
        /*
-        * Then, unless we used "--cache", remove the filenames from
+        * Then, unless we used "--cached", remove the filenames from
         * the workspace. If we fail to remove the first one, we
         * abort the "git rm" (but once we've successfully removed
         * any file at all, we'll go ahead and commit to it all: