Skip to content

Add diff-so-fancy.fileNameRulerShape - #545

Merged
scottchiefbaker merged 1 commit into
so-fancy:nextfrom
VXNCXNX:feat/file-name-ruler-shape
Sep 28, 2026
Merged

scottchiefbaker merged 1 commit into
so-fancy:nextfrom
VXNCXNX:feat/file-name-ruler-shape

Conversation

@VXNCXNX

@VXNCXNX VXNCXNX commented Aug 14, 2026

Copy link
Copy Markdown
Contributor

Closes #522.

Adds diff-so-fancy.fileNameRulerShape, using the option name @mzimnn proposed in the issue:

git config --global diff-so-fancy.fileNameRulerShape ruler
box (default)              ruler
────────────────┐          ────────────────────────────────────────────────────
modified: f.txt │          modified: f.txt
────────────────┘          ────────────────────────────────────────────────────

The motivation from the thread is that box width follows the file name, so a commit touching many files renders ragged, while the ruler is always full width.

Implementation

Two lines of behavior. The git show branch already set $ruler_shape = 'box' unconditionally; it now takes the configured value, read through the same git_config() helper as rulerWidth. draw_ruler itself is untouched.

Anything that isn't ruler (case-insensitively) falls back to box. That matters more than it looks: draw_ruler's if/elsif has no else, so an unrecognized shape would silently print nothing. Checked with an empty string, banana, RULER, box and unset.

Default is unchanged

Not just asserted — I ran the original and patched scripts over all 36 fixtures and diffed the output. stdout is byte-identical across every one. (The only difference anywhere is a line number inside a pre-existing Perl warning on latin1.diff, shifted by one because the file gained a line.)

Only git show is affected. Ordinary git diff rulers are untouched, per your note in the thread that changing those would cause riots.

Documentation

You asked for implementation and documentation, so both:

  • README.md, in the same format as the neighbouring options
  • the embedded POD =head1 OPTIONS block, so man diff-so-fancy lists it too

While there I noticed a pre-existing copy/paste slip in that POD: the shortHeaders entry is labelled B<rulerWidth:>. I left it alone to keep this diff focused, but happy to fix it here or separately.

Tests

One bats test added; make test goes 53 → 54 passing, 0 failures. Verified load-bearing against the unpatched script:

not ok 50 ... refute_line --index 6 --partial "┐" failed

(Submodules needed git submodule update --init --recursive for bats to run.)

git show draws file names in a box whose width follows the file name, which looks ragged across a commit touching many files. Setting this option to ruler restores the full width ruler. Default is box, so nothing changes unless the option is set. Documented in the README and the man page. Closes so-fancy#522.
@VXNCXNX
VXNCXNX force-pushed the feat/file-name-ruler-shape branch from c47e75b to a8b0807 Compare August 31, 2026 19:57
@scottchiefbaker
scottchiefbaker merged commit 621221a into so-fancy:next Sep 28, 2026
1 check passed
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.

Make ruler shape used for file names configurable

2 participants