config/git: better commit message preparations

This commit is contained in:
xeruf 2022-03-06 22:04:22 +01:00
parent 673b138f62
commit e239d2f554
6 changed files with 18 additions and 14 deletions

View File

@ -173,7 +173,7 @@
fa = fetch --all
fs = !git fetch && git st
lr = pull --rebase
lu = !git pull upstream ${1:-$(git curbranch)}
lu = !git pull --rebase upstream ${1:-$(git curbranch)}
# Push
ruu = !git fetch upstream && git reset --keep upstream/${1:-$(git curbranch)} && git push --no-verify --force-with-lease

View File

@ -23,10 +23,11 @@ if beginswith $'\n#' "$original"; then
# Find common path prefix of changed files
path=$(while read file
do test -z "$count" && common="$file" && count=$(expr length "$file") ||
while expr substr "$file" $count 1 != substr "$common" $count 1 >/dev/null; do let count--; done
while expr substr "$file" 1 $count != substr "$common" 1 $count >/dev/null; do let count--; done
done <<<"$(git -P diff --cached --name-only -r)" &&
expr substr "${common%.}" 1 "$count")
expr substr "$common" 1 "$count")
case "$path" in ([0-9]*) path="${path#*/}";; esac
path="${path#.}"
{
echo "${path%/}:"
echo "$original"

View File

@ -7,9 +7,9 @@ y() {
test "$#" -eq 0 && yadm s || yadm "$@"
}
yc() {
local folder="$(test -e "${1:-$PWD}" && realpath --relative-to="$XDG_CONFIG_HOME" "${1:-$PWD}" || echo "$1")"
echo "config/$folder:" >/tmp/yc-msg
yadm commit -v --template /tmp/yc-msg ${@:2} -- "$XDG_CONFIG_HOME/$folder*"
local folder="$(test -e "${1:-$PWD}" && realpath "${1:-$PWD}" || echo "$XDG_CONFIG_HOME/$1")"
echo "${folder#$HOME\/.}:" >/tmp/yc-msg
yadm commit -v --template /tmp/yc-msg ${@:2} -- "$folder*"
}
gcn() {

View File

@ -2,6 +2,6 @@
# Create a new repo, commit and push
git init
git add .
git commit -m "First strike"
git commit -m "First Strike"
git origin "$@"
git push

View File

@ -10,14 +10,17 @@ fzfpipe() {
cut -c3-
}
test $(git ls-tree HEAD . | wc -l) -gt 1 && wd=$PWD
cd "$(git rev-parse --show-toplevel)"
prefix="/tmp/git/fuzz"
mkdir -p "$prefix"
case "$1" in
(add) shift
git status -z --porcelain --no-renames --untracked-files=all |
git status -z --porcelain --no-renames --untracked-files=all $wd |
grep -zv '^\\w ' | fzfpipe |
git -c advice.addEmptyPathspec=false add --verbose --pathspec-from-file=- "$@";;
(*) git status -z --porcelain --no-renames |
sed -z 's/^\\(\\w\\) / \\1/' | fzfpipe >/tmp/git-fuzz
git -c advice.addEmptyPathspec=false add --intent-to-add --pathspec-from-file=/tmp/git-fuzz
git commit -v --only --pathspec-from-file=/tmp/git-fuzz "$@";;
(*) git status -z --porcelain --no-renames $wd |
sed -z 's/^\\(\\w\\) / \\1/' | fzfpipe >"$prefix/files"
git -c advice.addEmptyPathspec=false add --intent-to-add --pathspec-from-file="$prefix/files"
git commit -v --only --pathspec-from-file="$prefix/files" "$@";;
esac

View File

@ -1,5 +1,5 @@
#!/bin/bash
set -o pipefail
upCount=$(git rev-list --count HEAD...@{push} 2>/dev/null)
count=$(expr ${upCount:-0} + 3 \& ${upCount:-0} \> 3 \| 6)
git --no-pager lo -$count --color=always --graph HEAD @{upstream} | head -9 || git --no-pager lo -7
count=$(expr ${upCount:-0} + 3 \& ${upCount:-0} \> 3 \& ${upCount:-0} \< 6 \| 6)
git --no-pager lo -$count --color=always --graph HEAD @{upstream} || git --no-pager lo -7