Add git-fixup.sh

This commit is contained in:
Dirk Nederveen 2023-11-07 10:44:25 +01:00
parent e8527f3526
commit b45af8a047
Signed by untrusted user who does not match committer: dirk
GPG Key ID: 30C016E96E2219B8
2 changed files with 23 additions and 0 deletions

View File

@ -1,2 +1,4 @@
# git-fixup
Link git-fixup.sh somewhere in your `PATH`.
Omit the `.sh` file extension to use `git fixup <commit-ref>` as a shorthand.

21
git-fixup.sh Executable file
View File

@ -0,0 +1,21 @@
#!/bin/bash -e
if [[ $# -lt 1 ]]; then
(
echo "Usage:"
echo " $0 <commit-id>"
) >&2
exit 2
fi
COMMIT_ID="$1"
shift
COMMIT_ID="$(git rev-parse "$COMMIT_ID")"
exitcode=$?
if [[ $exitcode -ne 0 ]]; then
echo >&2 "Invalid ref \"$COMMIT_ID\""
exit 1
fi
exec git commit -m "fixup! $COMMIT_ID" "$@"