]> git.ipfire.org Git - thirdparty/git.git/blobdiff - dir.c
git-show-ref.txt: remove word and make consistent
[thirdparty/git.git] / dir.c
diff --git a/dir.c b/dir.c
index 29d1d5ba31def46ba8b55905dc60773cc6cc167e..4e6b988d37a0fb58fde4a170ebf7fe3702a3a474 100644 (file)
--- a/dir.c
+++ b/dir.c
@@ -54,11 +54,11 @@ 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 == '\\';
 }
 
 /*
- * Does 'match' matches the given name?
+ * Does 'match' match the given name?
  * A match is found if
  *
  * (1) the 'match' string is leading directory of 'name', or
@@ -139,7 +139,7 @@ int match_pathspec(const char **pathspec, const char *name, int namelen, int pre
 
 static int no_wildcard(const char *string)
 {
-       return string[strcspn(string, "*?[{")] == '\0';
+       return string[strcspn(string, "*?[{\\")] == '\0';
 }
 
 void add_exclude(const char *string, const char *base,
@@ -292,7 +292,7 @@ static void prep_exclude(struct dir_struct *dir, const char *base, int baselen)
        dir->basebuf[baselen] = '\0';
 }
 
-/* Scan the list and let the last match determines the fate.
+/* Scan the list and let the last match determine the fate.
  * Return 1 for exclude, 0 for include and -1 for undecided.
  */
 static int excluded_1(const char *pathname,
@@ -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;
+}
+