]> asedeno.scripts.mit.edu Git - git.git/blobdiff - dir.c
Merge branch 'bc/master-diff-hunk-header-fix'
[git.git] / dir.c
diff --git a/dir.c b/dir.c
index acf1001c4f9dd51587e3b07e52d4101ff3f1cb66..1c3c5015249e6ac0ed0461b49f6581aebc8701a3 100644 (file)
--- a/dir.c
+++ b/dir.c
@@ -831,3 +831,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;
+}
+