From c2d73d73aec9c21ffdb0677a7e3ef96a42c1ba47 Mon Sep 17 00:00:00 2001 From: Christian Heusel Date: Mon, 9 Oct 2023 16:24:50 +0200 Subject: fix(commitpkg): prefer core.editor over $EDITOR and $VISUAL This is done to closer mimick the behaviour of git here, as it prefers core.editor setting over the other editor options as per git-var(1): > The order of preference is the $GIT_EDITOR environment variable, then > core.editor configuration, then $VISUAL, then $EDITOR, and then the > default chosen at compile time, which is usually vi. Fixes #192 Signed-off-by: Christian Heusel --- src/commitpkg.in | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/commitpkg.in b/src/commitpkg.in index f979d61..6d4b014 100644 --- a/src/commitpkg.in +++ b/src/commitpkg.in @@ -205,14 +205,14 @@ if [[ -n $(git status --porcelain --untracked-files=no) ]]; then echo "$msgtemplate" > "$msgfile" if [[ -n $GIT_EDITOR ]]; then $GIT_EDITOR "$msgfile" || die + elif giteditor=$(git config --get core.editor); then + $giteditor "$msgfile" || die elif [[ -n $VISUAL ]]; then $VISUAL "$msgfile" || die elif [[ -n $EDITOR ]]; then $EDITOR "$msgfile" || die - elif giteditor=$(git config --get core.editor); then - $giteditor "$msgfile" || die else - die "No usable editor found (tried \$GIT_EDITOR, \$VISUAL, \$EDITOR, git config [core.editor])." + die "No usable editor found (tried \$GIT_EDITOR, git config [core.editor], \$VISUAL, \$EDITOR)." fi [[ -s $msgfile ]] || die stat_busy 'Committing changes' -- cgit v1.2.3-54-g00ecf