config/git: improve repo shortcuts

This commit is contained in:
xeruf 2021-11-17 15:55:46 +01:00
parent ba44dd2888
commit 65201a3ba8
2 changed files with 9 additions and 2 deletions

View File

@ -3,6 +3,7 @@
git diff --name-only --cached >/tmp/staged git diff --name-only --cached >/tmp/staged
root=$(git rev-parse --show-toplevel) root=$(git rev-parse --show-toplevel)
git add "$root" git add "$root"
git status --porcelain --find-renames=.3 | git status --porcelain --find-renames=.2 |
grep -vf /tmp/staged | cut -c4- | sed 's/ -> /\n/' | grep -vf /tmp/staged | cut -c4- | sed 's/ -> /\n/' |
xargs git -C "$root" restore --staged xargs git -C "$root" restore --staged
git status -s --find-renames=.2

View File

@ -6,5 +6,11 @@
case "$1" in case "$1" in
(http*) echo "$1" | sed "s|.*//\([^/]*\)/\(.*\)|git@\1:\2.git|" ;; (http*) echo "$1" | sed "s|.*//\([^/]*\)/\(.*\)|git@\1:\2.git|" ;;
(git:*) echo "$1" ;; (git:*) echo "$1" ;;
(*) echo "${1:-git.jfischer.org}:${3:-$(git config user.name)}/${2:-$(basename $PWD)}.git" ;; (*) host=$1
case $1 in
(hub) host=git@github.com;;
(lab) host=git@gitlab.com;;
(*) host=$1;;
esac
echo "${host:-git.jfischer.org}:${3:-$(git config user.name)}/${2:-$(basename $PWD)}.git" ;;
esac esac