diff --git a/.config/git/config b/.config/git/config index d012f2b..df1a7d1 100644 --- a/.config/git/config +++ b/.config/git/config @@ -119,10 +119,10 @@ # diffs d = diff - dm = !git diff $(git merge-base $(git main) HEAD) - dw = diff --color-words - dc = diff --color-words="[^[:space:]]|([[:alnum:]]|UTF_8_GUARD)+" - du = diff @{push} + dm = !git diff $(git merge-base $(git main) HEAD) # [d]iff to [m]ain + dw = diff --color-words # [d]iff [w]ords + dc = diff --color-words="[^[:space:]]|([[:alnum:]]|UTF_8_GUARD)+" # [d]iff [c]haracters + du = diff @{push} # [d]iff [u]pstream # MODIFY diff --git a/.config/git/prepare-commit-msg b/.config/git/prepare-commit-msg index dd568a0..ac98a86 100755 --- a/.config/git/prepare-commit-msg +++ b/.config/git/prepare-commit-msg @@ -25,10 +25,9 @@ if beginswith $'\n#' "$original"; then done done <<<"$(git -P diff --cached --name-only -r)" && expr substr "$common" 1 "$count" | sed 's|.local/bin/scripts|bin|') || exit 0 - case "$path" in ([0-9]*) path="${path#*/}";; esac - path="${path#.}" + case "$path" in ([0-9]-*) path="${path#*-}";; esac { - echo "${path%-}:" + echo "$path" | sed 's|^\.||;s|/\?$|: |' echo "$original" } > "$COMMIT_MSG_FILE" fi diff --git a/.local/bin/scripts/git-get b/.local/bin/scripts/git-get index 5c188c2..39e6528 100755 --- a/.local/bin/scripts/git-get +++ b/.local/bin/scripts/git-get @@ -1,6 +1,6 @@ -#!/bin/sh -ex +#!/bin/sh -e # Clones from resolving the arguments and switches into the new directory -# ARGS see git-repo, all arguments beyond the first three are forwarded to git-clone +# ARGS: see git-repo, all arguments beyond the first three are forwarded to git clone remote=$(git-repo "$@") echo "Cloning $remote" test $1 = https && shift @@ -14,7 +14,8 @@ case $# in (*) dir="${prefix}_$2";; esac;; esac -shift $(expr $# \& $# \< 3 \| 3) +case "$4" in (-*|"") cdir="$2";; (*) cdir="$4";; esac +shift $(expr 3 \& $# \> 3 \| $#) git clone $remote "$@" $dir --recurse-submodules -cd "${dir:-${4:-$2}}" +cd "${dir:-$cdir}" exec diff --git a/.local/bin/scripts/git-repo b/.local/bin/scripts/git-repo index 74b1a23..0d6657a 100755 --- a/.local/bin/scripts/git-repo +++ b/.local/bin/scripts/git-repo @@ -3,21 +3,26 @@ # Usage: # git repo # git repo [user] -test "$1" = https && https=true && shift case "$1" in - (http*) echo "$1" | sed "s|.*//\([^/]*\)/\(.*\)|git@\1:\2.git|" ;; - (git:*|ssh:*) echo "$1" ;; - (*) - case $1 in - (socha) user=software-challenge; host=git@github.com;; - (hub) host=git@github.com;; - (lab) host=git@gitlab.com;; - (*) host=${1:-gitea@git.jfischer.org};; - esac - user=${3:-${user:-$(git config user.name)}} - repo=${2:-$(basename $PWD)} - if test "$https" - then echo "https://${host#git*@}/$user/$repo.git" - else echo "$host:$user/$repo.git" - fi + (http*) + if expr "$1" : ".*:" >/dev/null + then echo "$1" | sed "s|.*//\([^/]*\)/\(.*\)|git@\1:\2.git|" + exit + else http=$1 && shift + fi;; + (git:*|ssh:*) + echo "$1" + exit;; esac +case $1 in + (socha) user=software-challenge; host=git@github.com;; + (hub) host=git@github.com;; + (lab) host=git@gitlab.com;; + (*) host=${1:-gitea@git.jfischer.org};; +esac +user=${3:-${user:-$(git config user.name)}} +repo=${2:-$(basename $PWD)} +if test "$http" +then echo "$http://${host#git*@}/$user/$repo.git" +else echo "$host:$user/$repo.git" +fi