]> git.phdru.name Git - git-scripts.git/commitdiff
Feat(submodules/remove): Add option `-c`
authorOleg Broytman <phd@phdru.name>
Mon, 15 Apr 2024 13:04:46 +0000 (16:04 +0300)
committerOleg Broytman <phd@phdru.name>
Mon, 15 Apr 2024 13:04:46 +0000 (16:04 +0300)
Run `git rm --cached submodule` to preserve submodule's tree.

submodules/remove

index 1db57c2f06353df4a4b405bd392fee3fb8f544a4..f9436cead70e12fdd84b414fb746d3c89aff7e83 100755 (executable)
@@ -1,8 +1,12 @@
 #! /bin/sh
 # See https://stackoverflow.com/q/1260748/7976758
 
+case "$1" in
+    -c|--cached) cached=--cached; shift ;;
+esac &&
+
 if [ $# != 1 ]; then
-    echo "Usage: $0 submodule_name" >&2
+    echo "Usage: $0 [-c|--cached] submodule_name" >&2
     exit 1
 fi
 
@@ -21,7 +25,7 @@ if [ -z "$path" ]; then
     exit 1
 fi
 
-git rm "$path" &&
+git rm $cached "$path" &&
 rm -rf "`git rev-parse --git-dir`"/modules/"$name" &&
 git config --remove-section submodule."$name" &&