Skip to content

fix: drop the TAB git adds after file names with spaces - #600

Open
jayhemnani9910 wants to merge 1 commit into
rtfpessoa:masterfrom
jayhemnani9910:fix/filename-trailing-tab
Open

jayhemnani9910 wants to merge 1 commit into
rtfpessoa:masterfrom
jayhemnani9910:fix/filename-trailing-tab

Conversation

@jayhemnani9910

Copy link
Copy Markdown

For a path with a space, git ends the ---/+++ file name with a TAB (so patch can tell where the name ends), and parse keeps it:

git diff   # --- a/My Docs/app.js<TAB>
parse(diff).map(f => [f.oldName, f.newName, f.language])
// [["My Docs/app.js\t", "My Docs/app.js\t", "js\t"]]

The extension then comes out as js\t, so diff2html-ui finds no language for highlighting, and the names carry an invisible tab. This is the case from the 2024 comment on #387.

getFilename now drops a trailing TAB along with the prefix and timestamp. git quotes file names that really contain a tab, so a literal trailing TAB is always the separator.

Added a parser test with a My Docs/app.js diff; it fails without the change. The tests pass.

This branch has not been deployed

No deployments
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