Files
Dan Davison 54578752f4 Add a TUI based on a fork of gitu (#2323)
* Add delta --tui: an embedded gitu fork

delta --tui (alias --gitu) runs the delta-gitu fork of gitu with this executable as its diff
renderer.

* Let feature keys start from what the user's config enables now, at any width

delta --tui told gitu once, at startup, which features were in force at the starting width. So a
change to git config during the session was missed. With side-by-side = 140 in a narrower terminal,
S forced side-by-side on instead of disabling the user's rule, and L disabled the line numbers that
side-by-side brings in as a default, which were not in effect, so no press of L changed anything.

Now gitu asks, each time it needs to know, which features the user's config enables. delta reads
the git config again and settles its options as if every minimum width were met, without asking
the terminal anything. It counts only the features the user names (in --features, DELTA_FEATURES,
a flag, a features list, or an option in git config), which it now records as it gathers features,
and not those a builtin feature brings in as defaults.

cargo test test_gitu_is_told

* Test that delta --tui gives gitu the git config delta reads, for gitu to offer themes from

gitu offered themes from git config as it opens it, which can differ from delta's: with
GIT_CONFIG_GLOBAL set, choosing a theme in the picker changed nothing, with no error.

cargo test test_gitu_reads_the_git_config

* Give gitu the git config delta reads, so its theme picker offers only themes delta can find

delta --tui now tells gitu how delta opens git config, shared with GitConfig::try_create. With
GIT_CONFIG_GLOBAL set, delta finds no themes there today, so gitu says none are defined instead of
offering themes that change nothing.

cargo test test_gitu_reads_the_git_config

* delta-gitu v0.1.14

* Document H for the feature list, space to toggle in it, + and - for context, and every feature offered by default

The manual described - for the list and + for the +/- markers, and a default list without the
user's own features.

* Document shell commands, search as you type and its history, and stat rows of patches asked for with --stat

The TUI page did not cover shell commands bound to keys, said search moved
only on enter, left / out of the prompt histories, and did not say how a patch
asked for with --stat, or git log --stat, is shown.

* Document views, and H's columns for features, commands and views

Views, git commands of the user's opened from a key with what is under the
cursor, were not documented, and H was described as one list with commands
marked $.

* Document {command}, the git command the screen is showing, in views and commands

* Document that shell commands get the width and features the TUI draws with

* delta-gitu v0.1.15

* Stop recording which features the user names, to merge main, whose gathering code replaced the code it was built on

#2330 rewrote the gathering of features that 83df1902 recorded the user's features in. Until that
is redone on the new code, delta --tui counts a feature that a builtin feature brings in as a
default, such as side-by-side's line-numbers, as enabled by the user's config, and two tests say so.

cargo test test_gitu_is_told

* Test that a builtin feature named in a features list is in effect

Since #2330, features = raw, color-only, diff-highlight or diff-so-fancy in git config had no
effect: a style feature does not set an option of its own name, so its own option counted as off,
and the feature was left out. In 0.20.1, each gave the same output as its flag.

cargo test a_builtin_feature_named_in_a_features_list

* Leave out a builtin feature only when its own option is set to off, so features = diff-so-fancy works again

#2330 left out a builtin feature whose own option was not on, counting an option that nothing sets
as off. A style feature such as raw, color-only, diff-highlight or diff-so-fancy does not set an
option of its own name, so naming it in a features list in git config had no effect. Now a feature
is left out only when something sets its option to off.

Rendering with every theme in themes.gitconfig, with each switch and style feature set in [delta],
given as a flag, or named in a features list, on three diffs: against #2330, only the 240 cases
that name a style feature in a features list differ; against 0.20.1, those 240 are the same again.

cargo test a_builtin_feature_named_in_a_features_list

* Record again which features the user names, on main's gathering code, for delta --tui

As features are gathered, each now comes either from the user (--features, DELTA_FEATURES, a flag, a
features list, or an option in git config) or as a builtin feature's default, as side-by-side
brings in line-numbers. gather_features returns the features the user names with the rest of what
it gathers, and delta --tui counts only those as enabled by the user's config, as 83df1902 did on
the gathering code that main replaced.

Rendering with every theme in themes.gitconfig, with each switch and style feature set in [delta],
given as a flag, or named in a features list, on three diffs, is unchanged by this commit.

cargo test test_gitu_is_told

* Don't require --pager, add --tui to CLI, update manual and docs

* delta-gitu v0.1.16

* Say that start-folded folds every patch, as the fork now does

* delta-gitu v0.1.17

* Test that delta --tui says where delta's options go when given them, and that --tui must come first

* Tell a user who gives delta's options to delta --tui, or puts --tui after them, where delta's options go

* delta-gitu v0.1.18
2026-11-15 16:14:02 +00:00

63 lines
2.1 KiB
Makefile

build:
cargo build --release
format:
git ls-files | grep '\.rs$$' | xargs -P 0 rustfmt
lint:
cargo clippy
test: unit-test end-to-end-test
unit-test:
cargo test
end-to-end-test: build
./tests/test_raw_output_matches_git_on_full_repo_history
./tests/test_deprecated_options > /dev/null
./tests/test_navigate_less_history_file
shell-completion:
for shell in bash fish zsh; do ./target/release/delta --generate-completion $$shell > etc/completion/completion.$$shell; done
# Piped, delta wraps --help at a fixed width, so the page does not depend on the terminal
help-output: build
{ printf '# Full --help output\n\n```txt\n'; ./target/release/delta --help; printf '```\n'; } > manual/src/full---help-output.md
release:
@make -f etc/release.Makefile release
version:
@grep version Cargo.toml | head -n1 | sed -E 's,.*version = "([^"]+)",\1,'
# Depend on the latest published delta-gitu
bump-gitu:
v=$$(cargo search delta-gitu --limit 1 | sed -n 's/^delta-gitu = "\([^"]*\)".*/\1/p') && \
perl -pi -e 's/^(delta-gitu = \{ version = ")[^"]+/$${1}'$$v'/' Cargo.toml && \
cargo update -p delta-gitu && \
$(MAKE) build && \
git commit -m "delta-gitu v$$v" Cargo.toml Cargo.lock
BENCHMARK_INPUT_FILE = /tmp/delta-benchmark-input.gitdiff
BENCHMARK_COMMAND = git log -p 23c292d3f25c67082a2ba315a187268be1a9b0ab
benchmark: build
$(BENCHMARK_COMMAND) > $(BENCHMARK_INPUT_FILE)
hyperfine --warmup 10 --min-runs 20 \
'target/release/delta --no-gitconfig < $(BENCHMARK_INPUT_FILE) > /dev/null'
# https://github.com/brendangregg/FlameGraph
flamegraph: build
$(BENCHMARK_COMMAND) | target/release/delta > /dev/null &
sample delta | stackcollapse-sample | flamegraph > etc/performance/flamegraph.svg
chronologer:
chronologer etc/performance/chronologer.yaml
# Records the TUI demo videos; see etc/demo/README.md. VOICE is none, me or elevenlabs.
VOICE ?= none
THEMES ?= light dark
video:
etc/demo/demo record --voice $(VOICE) --themes $(THEMES)
.PHONY: bump-gitu build format lint test unit-test end-to-end-test help-output release shell-completion version benchmark flamegraph chronologer video