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>

John Keeping committed Sep 12, 2013 at 20:25 UTC f8bc2ac3bf2df76ae864041a5496fab6446ad189
1 file changed +4 -16
builtin/rm.c
+4 -16
@@ -298,22 +298,10 @@ int cmd_rm(int argc, const char **argv, const char *prefix)
298 if (read_cache() < 0)
299 die(_("index file corrupt"));
300
301 - /*
302 - * Drop trailing directory separators from directories so we'll find
303 - * submodules in the index.
304 - */
305 - for (i = 0; i < argc; i++) {
306 - size_t pathlen = strlen(argv[i]);
307 - if (pathlen && is_dir_sep(argv[i][pathlen - 1]) &&
308 - is_directory(argv[i])) {
309 - do {
310 - pathlen--;
311 - } while (pathlen && is_dir_sep(argv[i][pathlen - 1]));
312 - argv[i] = xmemdupz(argv[i], pathlen);
313 - }
314 - }
315 -
316 - parse_pathspec(&pathspec, 0, PATHSPEC_PREFER_CWD, prefix, argv);
301 + parse_pathspec(&pathspec, 0,
302 + PATHSPEC_PREFER_CWD |
303 + PATHSPEC_STRIP_SUBMODULE_SLASH_CHEAP,
304 + prefix, argv);
305 refresh_index(&the_index, REFRESH_QUIET, &pathspec, NULL, NULL);
306
307 seen = xcalloc(pathspec.nr, 1);