git-apply: Remove directories that have become empty after deleting a file.
PATCH 1/1 git-apply: Remove directories that have become empty after deleting a file.
Signed-off-by Alexandre Julliard <[email protected]>
--- builtin-apply.c | 16 +++++++++++++++- 1 files changed, 15 insertions(+), 1 deletions(-)
builtin-apply.c +15 -1
@@ -2239,7 +2239,21 @@ static void remove_file(struct patch *patch)cache_tree_invalidate_path (active_cache_tree, patch->old_name); }if (!cached) -unlink (patch->old_name); + { +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)
Signature · 5 lines
1.4.4.4.g37ed -- Alexandre Julliard [email protected]