summaryrefslogtreecommitdiff
path: root/builtin
diff options
context:
space:
mode:
authorLibravatar John Keeping <john@keeping.me.uk>2013-09-12 20:25:00 +0100
committerLibravatar Junio C Hamano <gitster@pobox.com>2013-09-13 12:37:35 -0700
commitf8bc2ac3bf2df76ae864041a5496fab6446ad189 (patch)
tree1189b4c117ba8d6871fd3e5bc00ae6b72d922ec3 /builtin
parentUpdate draft release notes to 1.8.5 for the second batch of topics (diff)
downloadtgif-f8bc2ac3bf2df76ae864041a5496fab6446ad189.tar.xz
rm: re-use parse_pathspec's trailing-slash removal
Instead of re-implementing the "remove trailing slashes" loop in builtin/rm.c just pass PATHSPEC_STRIP_SUBMODULE_SLASH_CHEAP to parse_pathspec. Signed-off-by: John Keeping <john@keeping.me.uk> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin')
-rw-r--r--builtin/rm.c20
1 files changed, 4 insertions, 16 deletions
diff --git a/builtin/rm.c b/builtin/rm.c
index 9b59ab3a64..3a0e0eaab7 100644
--- a/builtin/rm.c
+++ b/builtin/rm.c
@@ -298,22 +298,10 @@ int cmd_rm(int argc, const char **argv, const char *prefix)
if (read_cache() < 0)
die(_("index file corrupt"));
- /*
- * Drop trailing directory separators from directories so we'll find
- * submodules in the index.
- */
- for (i = 0; i < argc; i++) {
- size_t pathlen = strlen(argv[i]);
- if (pathlen && is_dir_sep(argv[i][pathlen - 1]) &&
- is_directory(argv[i])) {
- do {
- pathlen--;
- } while (pathlen && is_dir_sep(argv[i][pathlen - 1]));
- argv[i] = xmemdupz(argv[i], pathlen);
- }
- }
-
- parse_pathspec(&pathspec, 0, PATHSPEC_PREFER_CWD, prefix, argv);
+ parse_pathspec(&pathspec, 0,
+ PATHSPEC_PREFER_CWD |
+ PATHSPEC_STRIP_SUBMODULE_SLASH_CHEAP,
+ prefix, argv);
refresh_index(&the_index, REFRESH_QUIET, &pathspec, NULL, NULL);
seen = xcalloc(pathspec.nr, 1);