BIN: Updates git-delete-submodule to remove them if they've been moved

The old script assumed that submodles name and path were the same, now
that isn't the case
Jonathan Hodgson 4 years ago
parent 3bb54003bb
commit 27cde2b004
  1. 9
      bin/.bin/git/git-delete-submodule

@ -9,15 +9,18 @@ test -z \
"$(git config --file=.gitmodules submodule."$NAME".url)" \ "$(git config --file=.gitmodules submodule."$NAME".url)" \
&& echo "submodule not found" 1>&2 && exit 3 && echo "submodule not found" 1>&2 && exit 3
path="$(git config --file=.gitmodules submodule."$NAME".path)"
url="$(git config --file=.gitmodules submodule."$NAME".url)"
# 1. Delete the relevant section from .git/config and clean submodule files # 1. Delete the relevant section from .git/config and clean submodule files
git submodule deinit -f "$NAME" || exit 4 git submodule deinit -f "$path" || exit 4
rmdir "$NAME" rmdir "$path"
rm -rf .git/modules/"$NAME" rm -rf .git/modules/"$NAME"
# 2. Delete the relevant line from .gitmodules # 2. Delete the relevant line from .gitmodules
git config --file=.gitmodules --remove-section submodule."$NAME" git config --file=.gitmodules --remove-section submodule."$NAME"
git add .gitmodules git add .gitmodules
# 3. Run git rm --cached path_to_submodule # 3. Run git rm --cached path_to_submodule
git rm --cached -rf "$NAME" git rm --cached -rf "$path"
# 4. Need to confirm and commit the changes for yourself # 4. Need to confirm and commit the changes for yourself
echo echo
echo "Now submodule $NAME is deleted." echo "Now submodule $NAME is deleted."

Loading…
Cancel
Save