Skip to content

Commit

Permalink
git-apply: Remove directories that have become empty after deleting a…
Browse files Browse the repository at this point in the history
… file.

Signed-off-by: Alexandre Julliard <julliard@winehq.org>
Signed-off-by: Junio C Hamano <junkio@cox.net>
  • Loading branch information
Alexandre Julliard authored and Junio C Hamano committed Jan 10, 2007
1 parent d93b7d1 commit d234b21
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions builtin-apply.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit d234b21

Please sign in to comment.