diff options
Diffstat (limited to 'builtin/rm.c')
-rw-r--r-- | builtin/rm.c | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/builtin/rm.c b/builtin/rm.c index 2aea3b5653..dabfcf6890 100644 --- a/builtin/rm.c +++ b/builtin/rm.c @@ -234,6 +234,21 @@ 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); + } + } + pathspec = get_pathspec(prefix, argv); refresh_index(&the_index, REFRESH_QUIET, pathspec, NULL, NULL); |