Skip to content

[FEAT] The preview in the FILES tab respect git's textconv settings #2592

Description

@mjfs

Currently SourceGit respects the git's diff settings but ignores the textconv settings in the [FILES] tab.

With git textconv defining a (text) viewer for binary files is possible, which is then applied via show (e.g. git show --textconv HEAD:document.docx). SourceGit should follow this rule as well.

A minor annoyance with the [FILES] tab is also that (in contrast with the [CHANGES] tab) SourceGit does not select the first file displayed for preview when navigating the history.

Attached bellow is a minimal Powershell git CLI example of this:

New-Item -ItemType Directory docx-diff-show-example
Set-Location docx-diff-show-example
git init --initial-branch=main
git config user.name "DOCX View and Diff Demo"
git config user.email "demo@example.invalid"
git config diff.docx.textconv "pandoc --to=plain"
git config diff.docx.cachetextconv true
Set-Content .gitattributes "*.docx binary diff=docx"

New-Item -ItemType Directory staging/word, staging/_rels | Out-Null
Set-Content -LiteralPath staging/'[Content_Types].xml' '<Types xmlns="http://schemas.openxmlformats.org/package/2006/content-types"><Default Extension="rels" ContentType="application/vnd.openxmlformats-package.relationships+xml"/><Override PartName="/word/document.xml" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.document.main+xml"/></Types>'
Set-Content staging/_rels/.rels '<Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships"><Relationship Id="rId1" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument" Target="word/document.xml"/></Relationships>'
Set-Content staging/word/document.xml '<w:document xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main"><w:body><w:p><w:r><w:t>Original text</w:t></w:r></w:p></w:body></w:document>'
[IO.Compression.ZipFile]::CreateFromDirectory("$PWD/staging", "$PWD/document.docx")
Remove-Item -Recurse -Force staging

git add .gitattributes document.docx
git commit -m "add Word document"

echo "TEXT CONTENT:"
git show --textconv HEAD:document.docx

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions