git-rm: honor -n flag.
Even when invoked with -n flag, git-rm removed the matching paths anyway. Also includes the missing check spotted by SungHyun Nam, which caused it to segfault. Now we refuse to run without any paths. Signed-off-by: Junio C Hamano <junkio@cox.net>
Junio C Hamano committed
Jun 8, 2006 at 21:11 UTC
7612a1efdb0c0806b43db10ce784707aae874340
1 file changed
+10
-7
builtin-rm.c
+10
-7
@@ -83,15 +83,15 @@ int cmd_rm(int argc, const char **argv, char **envp)
83
}
84
die(builtin_rm_usage);
85
}
86
- pathspec = get_pathspec(prefix, argv + i);
86
+ if (argc <= i)
87
+ usage(builtin_rm_usage);
88
89
+ pathspec = get_pathspec(prefix, argv + i);
90
seen = NULL;
89
- if (pathspec) {
90
- for (i = 0; pathspec[i] ; i++)
91
- /* nothing */;
92
- seen = xmalloc(i);
93
- memset(seen, 0, i);
94
- }
91
+ for (i = 0; pathspec[i] ; i++)
92
+ /* nothing */;
93
+ seen = xmalloc(i);
94
+ memset(seen, 0, i);
95
96
for (i = 0; i < active_nr; i++) {
97
struct cache_entry *ce = active_cache[i];
@@ -121,6 +121,9 @@ int cmd_rm(int argc, const char **argv, char **envp)
121
cache_tree_invalidate_path(active_cache_tree, path);
122
}
123
124
+ if (show_only)
125
+ return 0;
126
+
127
/*
128
* Then, if we used "-f", remove the filenames from the
129
* workspace. If we fail to remove the first one, we