summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: f948792)
raw | patch | inline | side by side (parent: f948792)
author | Steven Grimm <koreth@midwinter.com> | |
Mon, 16 Apr 2007 07:53:24 +0000 (00:53 -0700) | ||
committer | Junio C Hamano <junkio@cox.net> | |
Tue, 17 Apr 2007 07:19:11 +0000 (00:19 -0700) |
Signed-off-by: Steven Grimm <koreth@midwinter.com>
Signed-off-by: Junio C Hamano <junkio@cox.net>
Signed-off-by: Junio C Hamano <junkio@cox.net>
Documentation/git-rm.txt | patch | blob | history | |
builtin-rm.c | patch | blob | history | |
t/t3600-rm.sh | patch | blob | history |
index b051ccb6d6d47d7fdb41ba27e3e42c82a4460608..a65f24a0f698eb801ac43bba5aa7dc746e96edc0 100644 (file)
--- a/Documentation/git-rm.txt
+++ b/Documentation/git-rm.txt
SYNOPSIS
--------
-'git-rm' [-f] [-n] [-r] [--cached] [--] <file>...
+'git-rm' [-f] [-n] [-r] [--cached] [--ignore-unmatch] [--quiet] [--] <file>...
DESCRIPTION
-----------
the paths only from the index, leaving working tree
files.
+\--ignore-unmatch::
+ Exit with a zero status even if no files matched.
+
\--quiet::
git-rm normally outputs one line (in the form of an "rm" command)
for each file removed. This option suppresses that output.
diff --git a/builtin-rm.c b/builtin-rm.c
index b77b058e38c9a2b148f3c4deffa13945ee7daef6..4a0bd93c8b3b644fb86ce05686b09d79b180bffc 100644 (file)
--- a/builtin-rm.c
+++ b/builtin-rm.c
#include "tree-walk.h"
static const char builtin_rm_usage[] =
-"git-rm [-f] [-n] [-r] [--cached] [--quiet] [--] <file>...";
+"git-rm [-f] [-n] [-r] [--cached] [--ignore-unmatch] [--quiet] [--] <file>...";
static struct {
int nr, alloc;
{
int i, newfd;
int show_only = 0, force = 0, index_only = 0, recursive = 0, quiet = 0;
+ int ignore_unmatch = 0;
const char **pathspec;
char *seen;
recursive = 1;
else if (!strcmp(arg, "--quiet"))
quiet = 1;
+ else if (!strcmp(arg, "--ignore-unmatch"))
+ ignore_unmatch = 1;
else
usage(builtin_rm_usage);
}
if (pathspec) {
const char *match;
+ int seen_any = 0;
for (i = 0; (match = pathspec[i]) != NULL ; i++) {
- if (!seen[i])
- die("pathspec '%s' did not match any files",
- match);
+ if (!seen[i]) {
+ if (!ignore_unmatch) {
+ die("pathspec '%s' did not match any files",
+ match);
+ }
+ }
+ else {
+ seen_any = 1;
+ }
if (!recursive && seen[i] == MATCHED_RECURSIVELY)
die("not removing '%s' recursively without -r",
*match ? match : ".");
}
+
+ if (! seen_any)
+ exit(0);
}
/*
diff --git a/t/t3600-rm.sh b/t/t3600-rm.sh
index da9da9218065678a5f223143e3d3de2b928e7114..0a97b75288d44cf93e0a8f8d9ab1b76715f946d1 100755 (executable)
--- a/t/t3600-rm.sh
+++ b/t/t3600-rm.sh
'When the rm in "git-rm -f" fails, it should not remove the file from the index' \
'git-ls-files --error-unmatch baz'
+test_expect_success 'Remove nonexistent file with --ignore-unmatch' '
+ git rm --ignore-unmatch nonexistent
+'
+
test_expect_success '"rm" command printed' '
echo frotz > test-file &&
git add test-file &&