From 17d1a471a47e51d8a4f298f49bcef833f0d1f91d Mon Sep 17 00:00:00 2001 From: go2null <1t1is2@gmail.com> Date: Sun, 20 Oct 2019 14:03:58 -0400 Subject: [PATCH] add --force option to continue on error --- bin/git-delete-submodule | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/bin/git-delete-submodule b/bin/git-delete-submodule index 948a652..f5f9831 100755 --- a/bin/git-delete-submodule +++ b/bin/git-delete-submodule @@ -2,9 +2,13 @@ abort() { error="$1" && shift - echo "FATAL: $*" 1>&2 && exit "$error" + echo "ERROR: $*" 1>&2 + test -z "$FORCE" && exit "$error" } +# Don't abort on failures. This allows to cleanup after a rpevious failure. +[ "$1" = '--force' ] && FORCE=1 && shift + test -z "$1" && abort 1 'Submodule required' cd "$(git root)" || abort 5 'Cannot change to repository root' test ! -f '.gitmodules' && abort 2 '.gitmodules file not found' @@ -30,7 +34,6 @@ git add '.gitmodules' [ "$(wc -l '.gitmodules' | cut -d' ' -f1)" = '0' ] && git rm -f '.gitmodules' # 3. Need to confirm and commit the changes for yourself -echo if git submodule status >/dev/null 2>&1 \ && ! git submodule status | grep "$NAME"; then echo "Successfully deleted $NAME." @@ -39,6 +42,5 @@ else fi echo git submodule status -echo echo 'Confirm the output of `git submodule status` above' \ ' and commit the changes for yourself.'