astextplain: use mimetype to decide helper#624
Merged
dscho merged 2 commits intogit-for-windows:mainfrom Jun 9, 2025
Merged
Conversation
c72c8a9 to
2a05a0d
Compare
We use the file extension to determine which helper to call to convert a file to text. We currently match an all upper case version and an all lower case version of each extension, but sometimes variations like 'foo.Rtf' fall though our raster. To cover all variations in this established way we'd have to add every permutation of upper and lower case for each extension to the script. That's a big maintainance burden. We could also convert the passed filename to a known case and match against that. Since POSIX has no easy way for sh to do case conversion in-process we'd have to shell out to tr, awk or similar. For the antiword helper we already need to make sure the file is of the type it claims by it's extension. We use file to tell us the mimetype for this. file can also tell us the types of other files we care about for astextplain, so we can use it for the decision which helper to use in the first place. This fixes git-for-windows/git#5641 Signed-off-by: Matthias Aßhauer <mha1993@live.de>
2a05a0d to
e3eddae
Compare
Member
|
/deploy git-extra The i686/x86_64 and the arm64 workflow runs were started. |
dscho
approved these changes
Jun 9, 2025
Member
|
/updpkgsums The workflow run was started. |
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Member
|
/deploy git-extra The i686/x86_64 and the arm64 workflow runs were started. |
rimrul
added a commit
to rimrul/build-extra
that referenced
this pull request
Jan 8, 2026
Our astextplain helper used to pass through empty files and plaintext with the an expected extension. WHen we changed it to work based on mimetype rather than a predefined list of extensions in git-for-windows#624, both those passthroughs got lost. Plaintext passthrough has been restored in git-for-windows#626, but passthrough of empty files is still missing. Restore this functionality. This fixes git-for-windows/git#5977 Signed-off-by: Matthias Aßhauer <mha1993@live.de>
rimrul
added a commit
to rimrul/build-extra
that referenced
this pull request
Jan 8, 2026
Our astextplain helper used to pass through empty files and plaintext with the an expected extension. WHen we changed it to work based on mimetype rather than a predefined list of extensions in git-for-windows#624, both those passthroughs got lost. Plaintext passthrough has been restored in git-for-windows#626, but passthrough of empty files is still missing. Restore this functionality. This fixes git-for-windows/git#5977 Signed-off-by: Matthias Aßhauer <mha1993@live.de>
dscho
added a commit
that referenced
this pull request
Jan 9, 2026
Our `astextplain` helper used to pass through empty files and plaintext with the an expected extension. When we changed it to work based on mimetype rather than a predefined list of extensions in #624, both those passthroughs got lost. Plaintext passthrough has been restored in #626, but passthrough of empty files is still missing. Restore this functionality. This fixes git-for-windows/git#5977
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
We use the file extension to determine which helper to call to convert a file to text. We currently match an all upper case version and an all lower case version of each extension, but sometimes variations like 'foo.Rtf' fall though our raster.
To cover all variations in this established way we'd have to add every permutation of upper and lower case for each extension to the script. That's a big maintainance burden.
We could also convert the passed filename to a known case and match against that. Since POSIX has no easy way for sh to do case conversion in-process we'd have to shell out to tr, awk or similar.
For the antiword helper we already need to make sure the file is of the type it claims by it's extension. We use file to tell us the mimetype for this. file can also tell us the types of other files we care about for astextplain, so we can use it for the decision which helper to use in the first place.
This fixes git-for-windows/git#5641