mirror of
https://github.com/git/git
synced 2024-08-24 18:26:02 +00:00
git-apply: Remove directories that have become empty after deleting a file.
Signed-off-by: Alexandre Julliard <julliard@winehq.org> Signed-off-by: Junio C Hamano <junkio@cox.net>
This commit is contained in:
parent
d93b7d1c30
commit
d234b21c69
|
@ -2239,8 +2239,19 @@ static void remove_file(struct patch *patch)
|
|||
die("unable to remove %s from index", patch->old_name);
|
||||
cache_tree_invalidate_path(active_cache_tree, patch->old_name);
|
||||
}
|
||||
if (!cached)
|
||||
unlink(patch->old_name);
|
||||
if (!cached) {
|
||||
if (!unlink(patch->old_name)) {
|
||||
char *name = xstrdup(patch->old_name);
|
||||
char *end = strrchr(name, '/');
|
||||
while (end) {
|
||||
*end = 0;
|
||||
if (rmdir(name))
|
||||
break;
|
||||
end = strrchr(name, '/');
|
||||
}
|
||||
free(name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void add_index_file(const char *path, unsigned mode, void *buf, unsigned long size)
|
||||
|
|
Loading…
Reference in a new issue