diff options
author | Silvio Rhatto <rhatto@riseup.net> | 2017-11-07 16:16:19 -0200 |
---|---|---|
committer | Silvio Rhatto <rhatto@riseup.net> | 2017-11-07 16:16:19 -0200 |
commit | 1fdd87c81c87368efff54d0cc318b491398a7594 (patch) | |
tree | 045e9ac921acd9f3315aa813944f76efcfcf5209 | |
parent | 720ae2033e342223abfbd41b76c4622aea938320 (diff) | |
download | utils-git-1fdd87c81c87368efff54d0cc318b491398a7594.tar.gz utils-git-1fdd87c81c87368efff54d0cc318b491398a7594.tar.bz2 |
Checks and enhancements at git-submodule-move-git-dir
-rwxr-xr-x | git-submodule-move-git-dir | 25 |
1 files changed, 22 insertions, 3 deletions
diff --git a/git-submodule-move-git-dir b/git-submodule-move-git-dir index cd89517..b30f247 100755 --- a/git-submodule-move-git-dir +++ b/git-submodule-move-git-dir @@ -32,12 +32,31 @@ elif [ ! -d ".git" ]; then exit 1 fi +if [ ! -f "$MODULE/.git" ]; then + echo "$BASENAME: not a file, or file not found: $MODULE/.git" + exit 1 +fi + # Additional parameters +RELATIVE_REPO_DIR="$(cd $MODULE &> /dev/null && cd `cut -d : -f 2 .git` &> /dev/null && pwd)" REPO_DIR="`pwd`" MODULE_DIR="`cd $MODULE &> /dev/null && pwd`" -RELATIVE_REPO_DIR="$(echo $MODULE_DIR | sed -e "s|^$REPO_DIR/||")" + +if [ -z "$RELATIVE_REPO_DIR" ] || [ ! -d "$RELATIVE_REPO_DIR" ]; then + RELATIVE_REPO_DIR=".git/modules/$RELATIVE_REPO_DIR/$(echo $MODULE_DIR | sed -e "s|^$REPO_DIR/||")" +fi + +if [ -z "$RELATIVE_REPO_DIR" ] || [ ! -d "$RELATIVE_REPO_DIR" ]; then + echo "$BASENAME: no git folder found for submodule $MODULE" + exit 1 +fi + +if [ ! -e "$RELATIVE_REPO_DIR/config" ]; then + echo "$BASENAME: config not found at $RELATIVE_REPO_DIR/config" + exit 1 +fi # Convert -rm $MODULE/.git -mv ".git/modules/$RELATIVE_REPO_DIR" "$MODULE/.git" +rm $MODULE/.git && \ +mv "$RELATIVE_REPO_DIR" "$MODULE/.git" && \ sed -i -e '/worktree =/d' "$MODULE/.git/config" |