aboutsummaryrefslogtreecommitdiff
path: root/builtin-rm.c
diff options
context:
space:
mode:
authorAlex Riesen <raa.lkml@gmail.com>2008-09-27 00:59:14 +0200
committerShawn O. Pearce <spearce@spearce.org>2008-09-29 08:37:07 -0700
commit175a494823c1eacd4da9c4a5b90ec0668f7051c0 (patch)
tree4877e614101afd3512573199e95f9b8b7dbdd0bb /builtin-rm.c
parent4a92d1bfb784b09641180d164e7d719080165dc4 (diff)
downloadgit-175a494823c1eacd4da9c4a5b90ec0668f7051c0.tar.gz
git-175a494823c1eacd4da9c4a5b90ec0668f7051c0.tar.xz
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 <raa.lkml@gmail.com> Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Diffstat (limited to 'builtin-rm.c')
-rw-r--r--builtin-rm.c22
1 files changed, 1 insertions, 21 deletions
diff --git a/builtin-rm.c b/builtin-rm.c
index fdac34f24..50ae6d540 100644
--- a/builtin-rm.c
+++ b/builtin-rm.c
@@ -29,26 +29,6 @@ static void add_list(const char *name)
list.name[list.nr++] = name;
}
-static int remove_file(const char *name)
-{
- int ret;
- char *slash;
-
- ret = unlink(name);
- if (ret && errno == ENOENT)
- /* The user has removed it from the filesystem by hand */
- ret = errno = 0;
-
- if (!ret && (slash = strrchr(name, '/'))) {
- char *n = xstrdup(name);
- do {
- n[slash - name] = 0;
- name = n;
- } while (!rmdir(name) && (slash = strrchr(name, '/')));
- }
- return ret;
-}
-
static int check_local_mod(unsigned char *head, int index_only)
{
/* items in list are already sorted in the cache order,
@@ -239,7 +219,7 @@ int cmd_rm(int argc, const char **argv, const char *prefix)
int removed = 0;
for (i = 0; i < list.nr; i++) {
const char *path = list.name[i];
- if (!remove_file(path)) {
+ if (!remove_path(path)) {
removed = 1;
continue;
}