Skip to content

Commit f8bc2ac

Browse files
johnkeepinggitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent bb80ee0 commit f8bc2ac

File tree

1 file changed

+4
-16
lines changed

1 file changed

+4
-16
lines changed

builtin/rm.c

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -298,22 +298,10 @@ int cmd_rm(int argc, const char **argv, const char *prefix)
298298
if (read_cache() < 0)
299299
die(_("index file corrupt"));
300300

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);
317305
refresh_index(&the_index, REFRESH_QUIET, &pathspec, NULL, NULL);
318306

319307
seen = xcalloc(pathspec.nr, 1);

0 commit comments

Comments
 (0)