From 175a494823c1eacd4da9c4a5b90ec0668f7051c0 Mon Sep 17 00:00:00 2001 From: Alex Riesen Date: Sat, 27 Sep 2008 00:59:14 +0200 Subject: Use remove_path from dir.c instead of own implementation Besides, it fixes a memleak (builtin-rm.c) and accidental change of the input const argument (builtin-merge-recursive.c). Signed-off-by: Alex Riesen Signed-off-by: Shawn O. Pearce --- builtin-apply.c | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) (limited to 'builtin-apply.c') diff --git a/builtin-apply.c b/builtin-apply.c index 20bef1f21..70c9f9355 100644 --- a/builtin-apply.c +++ b/builtin-apply.c @@ -13,6 +13,7 @@ #include "delta.h" #include "builtin.h" #include "string-list.h" +#include "dir.h" /* * --check turns on checking that the working tree matches the @@ -2735,15 +2736,7 @@ static void remove_file(struct patch *patch, int rmdir_empty) warning("unable to remove submodule %s", patch->old_name); } else if (!unlink(patch->old_name) && rmdir_empty) { - char *name = xstrdup(patch->old_name); - char *end = strrchr(name, '/'); - while (end) { - *end = 0; - if (rmdir(name)) - break; - end = strrchr(name, '/'); - } - free(name); + remove_path(patch->old_name); } } } -- cgit v1.2.1