{"thread":{"id":"6313","subject":"[PATCH] git-apply: Remove directories that have become empty after deleting a file.","startedAt":"2007-01-09T20:25:46Z","lastAt":"2007-01-09T20:25:46Z","messageCount":1,"participants":["Alexandre Julliard"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"31276","messageId":"87fyak0wxh.fsf@wine.dyndns.org","threadId":"6313","inReplyTo":null,"subject":"[PATCH] git-apply: Remove directories that have become empty after deleting a file.","fromName":"Alexandre Julliard","fromEmail":"julliard@winehq.org","sentAt":"2007-01-09T20:25:46Z","receivedAt":"2007-01-09T20:25:46Z","isPatch":true,"sender":{"key":"julliard@winehq.org","avatar":null},"body":"\nSigned-off-by: Alexandre Julliard <julliard@winehq.org>\n---\n builtin-apply.c |   16 +++++++++++++++-\n 1 files changed, 15 insertions(+), 1 deletions(-)\n\ndiff --git a/builtin-apply.c b/builtin-apply.c\nindex 1c35837..fac8349 100644\n--- a/builtin-apply.c\n+++ b/builtin-apply.c\n@@ -2239,7 +2239,21 @@ static void remove_file(struct patch *patch)\n \t\tcache_tree_invalidate_path(active_cache_tree, patch->old_name);\n \t}\n \tif (!cached)\n-\t\tunlink(patch->old_name);\n+\t{\n+\t\tif (!unlink(patch->old_name))\n+\t\t{\n+\t\t\tchar *name = xstrdup(patch->old_name);\n+\t\t\tchar *end = strrchr(name, '/');\n+\t\t\twhile (end)\n+\t\t\t{\n+\t\t\t\t*end = 0;\n+\t\t\t\tif (rmdir(name))\n+\t\t\t\t\tbreak;\n+\t\t\t\tend = strrchr(name, '/');\n+\t\t\t}\n+\t\t\tfree(name);\n+\t\t}\n+\t}\n }\n \n static void add_index_file(const char *path, unsigned mode, void *buf, unsigned long size)\n-- \n1.4.4.4.g37ed\n\n-- \nAlexandre Julliard\njulliard@winehq.org\n"}]}