提交 f8bc2ac3 编写于 作者: J John Keeping 提交者: Junio C Hamano

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: NJohn Keeping <john@keeping.me.uk>
Signed-off-by: NJunio C Hamano <gitster@pobox.com>
上级 bb80ee09
......@@ -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);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册