summaryrefslogtreecommitdiff
path: root/builtin/rm.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2012-11-29 20:52:30 (GMT)
committerJunio C Hamano <gitster@pobox.com>2012-11-29 20:52:30 (GMT)
commit276d709305a8ac60e6165d1469122316e0bb1075 (patch)
tree16ae7cb26eac8b708418d7a5cbb91fbeb5d0fd95 /builtin/rm.c
parent36ea7cea13ad57ee48b1616dd29f508f473ec604 (diff)
parent53e4c5dcab33d2718476867b865da9679bd2c24a (diff)
downloadgit-276d709305a8ac60e6165d1469122316e0bb1075.zip
git-276d709305a8ac60e6165d1469122316e0bb1075.tar.gz
git-276d709305a8ac60e6165d1469122316e0bb1075.tar.bz2
Merge branch 'jl/submodule-rm'
Finishing touches to "git rm $submodule" that removes the working tree of a submodule. * jl/submodule-rm: Teach rm to remove submodules when given with a trailing '/'
Diffstat (limited to 'builtin/rm.c')
-rw-r--r--builtin/rm.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/builtin/rm.c b/builtin/rm.c
index 2aea3b5..dabfcf6 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);