diff options
author | Junio C Hamano <gitster@pobox.com> | 2012-11-29 12:52:30 -0800 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2012-11-29 12:52:30 -0800 |
commit | 276d709305a8ac60e6165d1469122316e0bb1075 (patch) | |
tree | 16ae7cb26eac8b708418d7a5cbb91fbeb5d0fd95 /builtin/rm.c | |
parent | 36ea7cea13ad57ee48b1616dd29f508f473ec604 (diff) | |
parent | 53e4c5dcab33d2718476867b865da9679bd2c24a (diff) | |
download | git-276d709305a8ac60e6165d1469122316e0bb1075.tar.gz |
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.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); |