From: Alex Linden Levy <lindenle@gmail.com>
To: gitster@pobox.com, git@vger.kernel.org
Cc: Alex Linden Levy <lindenle@gmail.com>
Subject: [PATCH] Add rm to submodule command.
Date: Fri, 2 Nov 2012 10:26:11 -0700 [thread overview]
Message-ID: <1351877171-3176-1-git-send-email-lindenle@gmail.com> (raw)
This change removes the config entries in .gitmodules and adds it.
---
git-submodule.sh | 62 +++++++++++++++++++++++++++++++++++++++++++++++++++++++-
1 file changed, 61 insertions(+), 1 deletion(-)
diff --git a/git-submodule.sh b/git-submodule.sh
index ab6b110..29d950f 100755
--- a/git-submodule.sh
+++ b/git-submodule.sh
@@ -6,6 +6,7 @@
dashless=$(basename "$0" | sed -e 's/-/ /')
USAGE="[--quiet] add [-b branch] [-f|--force] [--reference <repository>] [--] <repository> [<path>]
+ or: $dashless [--quiet] rm [-b branch] [-f|--force] [--] [<path>]
or: $dashless [--quiet] status [--cached] [--recursive] [--] [<path>...]
or: $dashless [--quiet] init [--] [<path>...]
or: $dashless [--quiet] update [--init] [-N|--no-fetch] [-f|--force] [--rebase] [--reference <repository>] [--merge] [--recursive] [--] [<path>...]
@@ -370,6 +371,65 @@ Use -f if you really want to add it." >&2
die "$(eval_gettext "Failed to register submodule '\$sm_path'")"
}
+cmd_rm()
+{
+ # parse $args after "submodule ... rm".
+ while test $# -ne 0
+ do
+ case "$1" in
+ -b | --branch)
+ case "$2" in '') usage ;; esac
+ branch=$2
+ shift
+ ;;
+ -f | --force)
+ force=$1
+ ;;
+ -q|--quiet)
+ GIT_QUIET=1
+ ;;
+ --)
+ shift
+ break
+ ;;
+ -*)
+ usage
+ ;;
+ *)
+ break
+ ;;
+ esac
+ shift
+ done
+
+ sm_path=$1
+
+ # normalize path:
+ # multiple //; leading ./; /./; /../; trailing /
+ sm_path=$(printf '%s/\n' "$sm_path" |
+ sed -e '
+ s|//*|/|g
+ s|^\(\./\)*||
+ s|/\./|/|g
+ :start
+ s|\([^/]*\)/\.\./||
+ tstart
+ s|/*$||
+ ')
+
+
+ #edit .gitmodules
+ git config -f .gitmodules --remove-section submodule."$sm_path" ||
+ die "$(eval_gettext "Failed to rm submodule '\$sm_path' section")"
+
+ #get rid of the submodule
+ git rm --cached $force "$sm_path" ||
+ die "$(eval_gettext "Failed to rm submodule '\$sm_path'")"
+
+ #now add the .gitmodules change
+ git add ${force} .gitmodules ||
+ die "$(eval_gettext "Failed to remove submodule '\$sm_path'")"
+}
#
# Execute an arbitrary command sequence in each checked out
# submodule
@@ -1076,7 +1136,7 @@ cmd_sync()
while test $# != 0 && test -z "$command"
do
case "$1" in
- add | foreach | init | update | status | summary | sync)
+ add | rm | foreach | init | update | status | summary | sync)
command=$1
;;
-q|--quiet)
--
1.8.0.1.g3039071.dirty
next reply other threads:[~2012-11-02 17:36 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-11-02 17:26 Alex Linden Levy [this message]
2012-11-04 13:43 ` [PATCH] Add rm to submodule command Jeff King
2012-11-04 14:29 ` Jens Lehmann
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1351877171-3176-1-git-send-email-lindenle@gmail.com \
--to=lindenle@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).