;bin: hledger-git: record: better error output

This commit is contained in:
Simon Michael 2023-02-03 19:07:28 -10:00
parent ae26ae6294
commit a37da26ee9

View File

@ -76,12 +76,12 @@ record() {
ensure_git ensure_git
ensure_git_repo ensure_git_repo
cd "$DIR" cd "$DIR"
for F in $FILES; do $GIT add "$F"; done || echo "(ignored)" for F in $FILES; do $GIT add "$F"; done || echo "(ignored)" >&2
MSG=${1:-$(date +'%Y-%m-%d %H:%M:%S %Z')} MSG=${1:-$(date +'%Y-%m-%d %H:%M:%S %Z')}
if [ $# -ge 1 ]; then if [ $# -ge 1 ]; then
shift shift
fi fi
$GIT commit -m "$MSG" "$@" || $GIT reset $GIT commit -m "$MSG" "$@" || (echo "error: commit failed" >&2; $GIT reset -q)
} }
r() { record "$@"; } r() { record "$@"; }