Skip to content

git: Use git's own editor precedence via git var GIT_EDITOR - #290

Open
aaron-skydio wants to merge 1 commit into
mainfrom
aaron/revup/main/editor
Open

git: Use git's own editor precedence via git var GIT_EDITOR#290
aaron-skydio wants to merge 1 commit into
mainfrom
aaron/revup/main/editor

Conversation

@aaron-skydio

Copy link
Copy Markdown
Contributor

Editor resolution put core.editor ahead of $GIT_EDITOR, ignored $VISUAL
entirely, and fell back to nano. Git's actual order (see git-var(1)) is
$GIT_EDITOR, core.editor, $VISUAL, $EDITOR, then its compile-time
default, so a caller setting GIT_EDITOR to force an editor for a single
invocation was silently overridden by config.

Ask git var GIT_EDITOR instead of reimplementing the precedence. This
also picks up git's handling of dumb terminals, where $VISUAL is skipped
because it conventionally names a full-screen editor, and where git
refuses to fall back to its compile-time default at all.

When git reports no usable editor, error out at the point we need one
rather than guessing at nano. Resolution stays in make_git so the many
commands that never open an editor are unaffected, and the result is
typed Optional[str] so the unavailable case is visible in signatures
instead of hiding behind an empty-string sentinel.

Co-Authored-By: Claude Opus 5 noreply@anthropic.com
Topic: editor
Reviewers: jerry,brian-k

Editor resolution put core.editor ahead of $GIT_EDITOR, ignored $VISUAL
entirely, and fell back to nano. Git's actual order (see git-var(1)) is
$GIT_EDITOR, core.editor, $VISUAL, $EDITOR, then its compile-time
default, so a caller setting GIT_EDITOR to force an editor for a single
invocation was silently overridden by config.

Ask `git var GIT_EDITOR` instead of reimplementing the precedence. This
also picks up git's handling of dumb terminals, where $VISUAL is skipped
because it conventionally names a full-screen editor, and where git
refuses to fall back to its compile-time default at all.

When git reports no usable editor, error out at the point we need one
rather than guessing at nano. Resolution stays in make_git so the many
commands that never open an editor are unaffected, and the result is
typed Optional[str] so the unavailable case is visible in signatures
instead of hiding behind an empty-string sentinel.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Topic: editor
Reviewers: jerry,brian-k
@aaron-skydio

Copy link
Copy Markdown
Contributor Author

Reviews in this chain:
#290 git: Use git's own editor precedence via git var GIT_EDITOR

@aaron-skydio

Copy link
Copy Markdown
Contributor Author
# head base diff date summary
0 d41a1c4b 00cec75f diff Aug 18 19:37 PM 4 files changed, 49 insertions(+), 13 deletions(-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants