From 6eb61dc70b6bc4233a9f6126564826b1d152932b Mon Sep 17 00:00:00 2001 From: xeruf <27jf@pm.me> Date: Sun, 7 Nov 2021 00:22:45 +0100 Subject: [PATCH] config/git: fix newline issue in git-get --- .local/bin/scripts/git-get | 2 +- .local/bin/scripts/git-repo | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/.local/bin/scripts/git-get b/.local/bin/scripts/git-get index 70079c1..a43f96a 100755 --- a/.local/bin/scripts/git-get +++ b/.local/bin/scripts/git-get @@ -4,5 +4,5 @@ set -e remote=$(git-repo "$@") echo "Cloning $remote" git clone $remote ${@:4} --recurse-submodules -cd "$(expr "$2" || basename ${remote%.git})" +cd "$(test -n "$2" && echo "$2" || basename ${remote%.git})" exec "$SHELL" diff --git a/.local/bin/scripts/git-repo b/.local/bin/scripts/git-repo index 2416479..1b7b26e 100755 --- a/.local/bin/scripts/git-repo +++ b/.local/bin/scripts/git-repo @@ -1,7 +1,10 @@ #!/bin/sh -# Translates different repo notations into ssh +# Translate different repo notations into ssh +# Usage: +# git repo +# git repo [user] case "$1" in - (http*) echo $1 | sed "s|.*//\([^/]*\)/\(.*\)|git@\1:\2.git|";; + (http*) echo "$1" | sed "s|.*//\([^/]*\)/\(.*\)|git@\1:\2.git|" ;; (git:*) echo "$1" ;; (*) echo "${1:-git.jfischer.org}:${3:-$(git config user.name)}/${2:-$(basename $PWD)}.git" ;; esac