summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: c7263d4)
raw | patch | inline | side by side (parent: c7263d4)
author | Steven Grimm <koreth@midwinter.com> | |
Mon, 16 Apr 2007 07:46:48 +0000 (00:46 -0700) | ||
committer | Junio C Hamano <junkio@cox.net> | |
Mon, 16 Apr 2007 08:06:02 +0000 (01:06 -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 6feebc0400b86407a118840d9a6cc994a94715d6..b051ccb6d6d47d7fdb41ba27e3e42c82a4460608 100644 (file)
--- a/Documentation/git-rm.txt
+++ b/Documentation/git-rm.txt
the paths only from the index, leaving working tree
files.
+\--quiet::
+ git-rm normally outputs one line (in the form of an "rm" command)
+ for each file removed. This option suppresses that output.
+
DISCUSSION
----------
diff --git a/builtin-rm.c b/builtin-rm.c
index 8a0738f83dd31a847bf486ddb3aefef94af5e049..d3de4b54524cc616b12353a180e821ec57c27f1a 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] [--] <file>...";
+"git-rm [-f] [-n] [-r] [--cached] [--quiet] [--] <file>...";
static struct {
int nr, alloc;
int cmd_rm(int argc, const char **argv, const char *prefix)
{
int i, newfd;
- int show_only = 0, force = 0, index_only = 0, recursive = 0;
+ int show_only = 0, force = 0, index_only = 0, recursive = 0, quiet = 0;
const char **pathspec;
char *seen;
force = 1;
else if (!strcmp(arg, "-r"))
recursive = 1;
+ else if (!strcmp(arg, "--quiet"))
+ quiet = 1;
else
usage(builtin_rm_usage);
}
*/
for (i = 0; i < list.nr; i++) {
const char *path = list.name[i];
- printf("rm '%s'\n", path);
+ if (!quiet)
+ printf("rm '%s'\n", path);
if (remove_file_from_cache(path))
die("git-rm: unable to remove %s", path);
diff --git a/t/t3600-rm.sh b/t/t3600-rm.sh
index e31cf93a00ab377355734b3d88d536d36fe734e1..da9da9218065678a5f223143e3d3de2b928e7114 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 '"rm" command printed' '
+ echo frotz > test-file &&
+ git add test-file &&
+ git commit -m "add file for rm test" &&
+ git rm test-file > rm-output &&
+ test `egrep "^rm " rm-output | wc -l` = 1 &&
+ rm -f test-file rm-output &&
+ git commit -m "remove file from rm test"
+'
+
+test_expect_success '"rm" command suppressed with --quiet' '
+ echo frotz > test-file &&
+ git add test-file &&
+ git commit -m "add file for rm --quiet test" &&
+ git rm --quiet test-file > rm-output &&
+ test `wc -l < rm-output` = 0 &&
+ rm -f test-file rm-output &&
+ git commit -m "remove file from rm --quiet test"
+'
+
# Now, failure cases.
test_expect_success 'Re-add foo and baz' '
git add foo baz &&
! test -d frotz
'
+test_expect_failure 'Remove nonexistent file returns nonzero exit status' '
+ git rm nonexistent
+'
+
test_done