Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJunio C Hamano <junkio@cox.net>2007-01-12 01:58:47 +0300
committerJunio C Hamano <junkio@cox.net>2007-01-12 01:58:47 +0300
commit646ac22bdf7f7011bb4c77647053416e892ce64d (patch)
treed7a292aecfab6d0522fba899e3ad31231f350676 /builtin-rm.c
parent3b97fee23df7ec78eea77151fcc0885ec3191950 (diff)
git-rm: do not fail on already removed file.
Often the user would do "/bin/rm foo" before telling git, but then want to tell git about it. "git rm foo" however would fail because it cannot unlink(2) foo. Treat ENOENT error return from unlink(2) as if a successful removal happened. Signed-off-by: Junio C Hamano <junkio@cox.net>
Diffstat (limited to 'builtin-rm.c')
-rw-r--r--builtin-rm.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/builtin-rm.c b/builtin-rm.c
index 5b078c4194..d81f289c3c 100644
--- a/builtin-rm.c
+++ b/builtin-rm.c
@@ -32,6 +32,10 @@ static int remove_file(const char *name)
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 {
@@ -204,7 +208,7 @@ int cmd_rm(int argc, const char **argv, const char *prefix)
return 0;
/*
- * Then, unless we used "--cache", remove the filenames from
+ * Then, unless we used "--cached", remove the filenames from
* the workspace. If we fail to remove the first one, we
* abort the "git rm" (but once we've successfully removed
* any file at all, we'll go ahead and commit to it all: