summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 4a92d1b)
raw | patch | inline | side by side (parent: 4a92d1b)
author | Alex Riesen <raa.lkml@gmail.com> | |
Fri, 26 Sep 2008 22:59:14 +0000 (00:59 +0200) | ||
committer | Shawn O. Pearce <spearce@spearce.org> | |
Mon, 29 Sep 2008 15:37:07 +0000 (08:37 -0700) |
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>
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>
builtin-apply.c | patch | blob | history | |
builtin-merge-recursive.c | patch | blob | history | |
builtin-rm.c | patch | blob | history |
diff --git a/builtin-apply.c b/builtin-apply.c
index 20bef1f21d393b0ddf36b8336af85a70c9b8c39c..70c9f93554c9bc97e5adbd924fd197973bb7d30d 100644 (file)
--- a/builtin-apply.c
+++ b/builtin-apply.c
#include "delta.h"
#include "builtin.h"
#include "string-list.h"
+#include "dir.h"
/*
* --check turns on checking that the working tree matches the
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);
}
}
}
index f628a62751d25d394c722bbc03f9367d3973fdd0..b9738655adc66386e55eccafa9ab891bdcf30960 100644 (file)
#include "ll-merge.h"
#include "interpolate.h"
#include "attr.h"
+#include "dir.h"
#include "merge-recursive.h"
static int subtree_merge;
return 0;
}
-static int remove_path(const char *name)
-{
- int ret;
- char *slash, *dirs;
-
- ret = unlink(name);
- if (ret)
- return ret;
- dirs = xstrdup(name);
- while ((slash = strrchr(name, '/'))) {
- *slash = '\0';
- if (rmdir(name) != 0)
- break;
- }
- free(dirs);
- return ret;
-}
-
static int remove_file(int clean, const char *path, int no_wd)
{
int update_cache = index_only || clean;
return -1;
}
if (update_working_directory) {
- if (remove_path(path) && errno != ENOENT)
+ if (remove_path(path))
return -1;
}
return 0;
diff --git a/builtin-rm.c b/builtin-rm.c
index fdac34f2423409add48706497fa01010219baf72..50ae6d54011fad89387f0d56ce7a4591d07874f3 100644 (file)
--- a/builtin-rm.c
+++ b/builtin-rm.c
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,
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;
}