Code

sha1_file.c: split has_loose_object() into local and non-local counterparts
[git.git] / dir.c
diff --git a/dir.c b/dir.c
index 29d1d5ba31def46ba8b55905dc60773cc6cc167e..cfaa28ff23acb462aa0cfd54a405316320ec3bc8 100644 (file)
--- a/dir.c
+++ b/dir.c
@@ -54,7 +54,7 @@ int common_prefix(const char **pathspec)
 
 static inline int special_char(unsigned char c1)
 {
-       return !c1 || c1 == '*' || c1 == '[' || c1 == '?';
+       return !c1 || c1 == '*' || c1 == '[' || c1 == '?' || c1 == '\\';
 }
 
 /*
@@ -837,3 +837,23 @@ void setup_standard_excludes(struct dir_struct *dir)
        if (excludes_file && !access(excludes_file, R_OK))
                add_excludes_from_file(dir, excludes_file);
 }
+
+int remove_path(const char *name)
+{
+       char *slash;
+
+       if (unlink(name) && errno != ENOENT)
+               return -1;
+
+       slash = strrchr(name, '/');
+       if (slash) {
+               char *dirs = xstrdup(name);
+               slash = dirs + (slash - name);
+               do {
+                       *slash = '\0';
+               } while (rmdir(dirs) && (slash = strrchr(dirs, '/')));
+               free(dirs);
+       }
+       return 0;
+}
+