Skip to content

Name files whose diffs have no hunks - #75

Open
gnutix wants to merge 1 commit into
banga:mainfrom
gnutix:name-files-without-hunks
Open

gnutix wants to merge 1 commit into
banga:mainfrom
gnutix:name-files-without-hunks

Conversation

@gnutix

@gnutix gnutix commented Nov 7, 2026 •

Copy link
Copy Markdown

Some diffs have no hunks, and so no --- / +++ lines, which are currently the only source of file names:

  • empty new or deleted files,
  • mode-only changes (chmod +x).

Their header shows ■■ with no name. A deleted empty file also gets the green "added" marker, since both names are empty.

This takes the name from the diff --git a/<name> b/<name> line, and uses new file mode / deleted file mode to mark which side is missing. Since spaces in that line aren't escaped, the name is only taken when both halves name the same file (with or without the a/ b/ prefixes). Renames and quoted paths keep their existing handling via rename from/to and ---/+++.

Before:

────────────────────
 ■■
────────────────────

After:

────────────────────
 ■■ empty.txt
────────────────────

Tests

  • New case with an empty added file, an empty deleted file (with a space in its name) and a mode change.
  • The existing "commit with file deletion" snapshots change: its fixture opens with a diff --git block that has only an index line, which used to render a blank header and now shows .github/workflows/main.yml.

🤖 Generated with Claude Code Opus 5.5

Empty new or deleted files and mode-only changes produce no "---" and
"+++" lines, which were the only source of file names, so their header
showed no name. A deleted empty file also got the green "added" marker,
since both names were empty.

Take the name from the "diff --git" line when both halves name the same
file, and use "new file mode" / "deleted file mode" to mark which side
is missing.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Y1vvcRJ5ENt6vxWCCT4WbJ
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.

1 participant