summaryrefslogtreecommitdiff
path: root/builtin
diff options
context:
space:
mode:
authorLibravatar Junio C Hamano <gitster@pobox.com>2012-11-29 12:52:30 -0800
committerLibravatar Junio C Hamano <gitster@pobox.com>2012-11-29 12:52:30 -0800
commit276d709305a8ac60e6165d1469122316e0bb1075 (patch)
tree16ae7cb26eac8b708418d7a5cbb91fbeb5d0fd95 /builtin
parentMerge branch 'pp/gitweb-config-underscore' (diff)
parentTeach rm to remove submodules when given with a trailing '/' (diff)
downloadtgif-276d709305a8ac60e6165d1469122316e0bb1075.tar.xz
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')
-rw-r--r--builtin/rm.c15
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);