astextplain: use mimetype to decide helper #624
Merged
+9
−16
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