Editors and Mergetools with drracket

This commit is contained in:
2026-08-14 11:30:56 +02:00
parent 7d8a5cd599
commit e33ffb906a
7 changed files with 578 additions and 63 deletions
+40 -1
View File
@@ -39,6 +39,7 @@ alias for `git*`.
(git* rebase main)
(git* merge feature)
(git* cherry-pick abc1234)
(git* mergetool)
(define branch "develop")
(git* switch (eval branch))
@@ -54,6 +55,7 @@ behavior:
- `git-remote` returns remote names; `git-remote -v` / `git-remote --verbose` returns separate `(name url fetch|push)` items.
- `git-stash list` returns `(stash-name description)` items; other stash subcommands keep Git's normal behavior.
- `git-restore`, `git-reset`, `git-revert`, `git-rebase`, `git-merge`, and `git-cherry-pick` pass Git's command syntax through unchanged.
- `git-mergetool` uses Git's mergetool interface and prefers a configured or well-known graphical merge tool.
- `git-diff` renders HTML by default; `--output=-` selects stdout and
`--output=string` returns a string.
- `git-show` renders a commit and its diff as HTML by default. `-l` /
@@ -66,7 +68,7 @@ credentials, SSH keys, pull strategy, and other repository configuration.
## Commands
The package currently registers commands including `status`, `add`, `commit`,
`push`, `pull`, `fetch`, `config`, `branch`, `remote`, `stash`, `restore`, `reset`, `revert`, `rebase`, `merge`, `cherry-pick`, `switch`, `clone`, `tag`, `log`,
`push`, `pull`, `fetch`, `config`, `branch`, `remote`, `stash`, `restore`, `reset`, `revert`, `rebase`, `merge`, `cherry-pick`, `mergetool`, `switch`, `clone`, `tag`, `log`,
`rev-list`, `diff`, `show`, `grep`, `help`, `version`, and `new-version`.
Most are also exported as direct procedures such as `git-status`, `git-add`,
@@ -131,3 +133,40 @@ raised. This prevents a bad token from remaining in the credential cache.
A custom handler can still be installed through
`current-git-authentication-handler`.
## GUI editor and merge tool
git-cli looks for a GUI editor and passes it to Git through `GIT_EDITOR` and
`GIT_SEQUENCE_EDITOR` in the environment of the Git subprocess only. It does
not change the user's global Git configuration.
The editor can be inspected or configured explicitly:
```racket
(find-editor)
(set-editor! "code --wait")
```
The editor search first checks `PATH` and then well-known platform locations.
On Windows this includes the normal per-user and Program Files locations for
VS Code, with Notepad as fallback. On macOS the standard Visual Studio Code
application bundle and TextEdit are recognized. On Linux common `/usr`,
`/usr/local`, and Snap locations are checked for VS Code, Kate, Gedit, and Xed.
`git-mergetool` stays on top of Git's own mergetool mechanism. If no tool is
specified explicitly, git-cli prefers a configured or well-known graphical
tool such as WinMerge, Meld, KDiff3, VS Code, TortoiseMerge, or opendiff.
The finder checks `PATH` first and then common platform installation locations.
When a merge tool is found outside `PATH`, git-cli adds that executable's
directory to the environment of the Git subprocess, so Git's own mergetool
integration can still find it. If no tool is found, Git is left to select its
own default.
```racket
(find-mergetool)
(find-mergetool-path)
(set-mergetool! "winmerge")
(git* mergetool)
(git* mergetool --tool=meld)
```