From b0cdb013fbb3adb2f49035e3d36ddb6e96b87253 Mon Sep 17 00:00:00 2001 From: Oleg Broytman Date: Mon, 15 Apr 2024 16:04:46 +0300 Subject: [PATCH] Feat(submodules/remove): Add option `-c` Run `git rm --cached submodule` to preserve submodule's tree. --- submodules/remove | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/submodules/remove b/submodules/remove index 1db57c2..f9436ce 100755 --- a/submodules/remove +++ b/submodules/remove @@ -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" && -- 2.39.5