commit 9de96a1877090ae4f049ba6710d226e5a50a29ed parent b82435746b54355496907e6466563cb2db06105b Author: hhvn <dev@hhvn.uk> Date: Fri, 15 Apr 2022 11:55:17 +0100 Remove add-commit script I realized that hand crafted commits are probably better. If someone wants to see the files changed, they could get that info from git themselves. Diffstat:
D | .config/git/add-commit | | | 54 | ------------------------------------------------------ |
M | .config/git/config | | | 1 | - |
2 files changed, 0 insertions(+), 55 deletions(-)
diff --git a/.config/git/add-commit b/.config/git/add-commit @@ -1,54 +0,0 @@ -#!/bin/sh -# - recognize file names from inside commit message -# example: git ac -m "LICENSE project.c: new email addr" -# output: git add LICENSE project.c; git commit -m "LICENSE project.c: new email addr" - -shorten=y - -die(){ - echo "error: no filenames extracted from commit message" - exit 1 -} - -for n in $(seq $#) -do - [ "$(eval "echo \$$n")" = "-m" ] && inline=y && break -done - -[ "$inline" = "y" ] && { - echo "$@" | grep ".*-m *[^:]*:" >/dev/null || die - - # [][][^][]*[][] is one of the ugliest regexes I've ever constructed - # It is meant to get rid of the [NEW] from "thing.1[NEW]: add manpage" - files=$(echo "$@" | sed 's/[][][^][]*[][]//g' | sed -E 's/.*-m *([^:]*):.*/\1/') - - git add $files - - while [ $# != 0 ] - do - printf '%s\0' "$1" - shift - done | xargs -0 git commit -} - -[ "$inline" != "y" ] && { - # in non-inline mode, take list of files to add - # then format these into the COMMIT_EDITMSG file - - [ "$shorten" = "y" ] && { - echo "$@:" | sed -E 's~([a-zA-Z])[^ /]*/~\1/~g;s~(^| )--?[a-z]*( |$)~~g' > .git/COMMIT_EDITMSG - } || echo "$@:" > .git/COMMIT_EDITMSG - sum=$(sha256sum .git/COMMIT_EDITMSG) - ${EDITOR:-vim} .git/COMMIT_EDITMSG - sum2=$(sha256sum .git/COMMIT_EDITMSG) - - [ "$sum" != "$sum2" ] && { - git add "$@" || exit 1 - git commit -F .git/COMMIT_EDITMSG - } || { - echo "error: COMMIT_EDITMSG not changed" - exit 1 - } -} - - diff --git a/.config/git/config b/.config/git/config @@ -18,7 +18,6 @@ [alias] hs = !sh ~/.config/git/hist fm = !sh ~/.config/git/format-patch - ac = !sh ~/.config/git/add-commit re = !sh ~/.config/git/remote pu = !sh ~/.config/git/push pa = !sh ~/.config/git/push --all