From: Junio C Hamano Date: Thu, 29 Nov 2012 20:52:30 +0000 (-0800) Subject: Merge branch 'jl/submodule-rm' X-Git-Tag: v1.8.1-rc0~12 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/276d709305a8ac60e6165d1469122316e0bb1075?hp=-c 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 '/' --- 276d709305a8ac60e6165d1469122316e0bb1075 diff --combined builtin/rm.c index 2aea3b5653,4e5e8abeb6..dabfcf6890 --- a/builtin/rm.c +++ b/builtin/rm.c @@@ -12,7 -12,7 +12,7 @@@ #include "submodule.h" static const char * const builtin_rm_usage[] = { - "git rm [options] [--] ...", + N_("git rm [options] [--] ..."), NULL }; @@@ -203,13 -203,13 +203,13 @@@ static int show_only = 0, force = 0, in static int ignore_unmatch = 0; static struct option builtin_rm_options[] = { - OPT__DRY_RUN(&show_only, "dry run"), - OPT__QUIET(&quiet, "do not list removed files"), - OPT_BOOLEAN( 0 , "cached", &index_only, "only remove from the index"), - OPT__FORCE(&force, "override the up-to-date check"), - OPT_BOOLEAN('r', NULL, &recursive, "allow recursive removal"), + OPT__DRY_RUN(&show_only, N_("dry run")), + OPT__QUIET(&quiet, N_("do not list removed files")), + OPT_BOOLEAN( 0 , "cached", &index_only, N_("only remove from the index")), + OPT__FORCE(&force, N_("override the up-to-date check")), + OPT_BOOLEAN('r', NULL, &recursive, N_("allow recursive removal")), OPT_BOOLEAN( 0 , "ignore-unmatch", &ignore_unmatch, - "exit with a zero status even if nothing matched"), + N_("exit with a zero status even if nothing matched")), OPT_END(), }; @@@ -234,6 -234,21 +234,21 @@@ int cmd_rm(int argc, const char **argv 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);