This uses the same mechanisms as git to determine whether a file is
binary: By simply searching the first 8000 bytes for a 0-byte. This
gets rid of the call to "file" and is a much cleaner and shorter
implementation.
Signed-off-by: Johannes Gilger <heipei@hackvalue.de>
This patch prevents the plaintext display of files with binary content
in tree-view by connecting the content to the textContents attribute.
PBGitTree is extended with the method textContents, which returns the
textual representation of a PBGitTree-object. The methods first checks
the output of "git check-attr binary <file>" to see if the user
set/unset the binary attribute manually. Then it checks for common
binary file-extensions. If this method can't determine whether the file
is binary, the file-content is loaded and Unix "file" is run on the
first 100 bytes of the file to make a decision.
It also adds the -[PBGitTree fileSize] method to check the size
of the file before actually loading its contents.
Signed-off-by: Johannes Gilger <heipei@hackvalue.de>
Edited-by: Pieter de Bie <pdebie@ai.rug.nl>
path rather than the <PBGitTree: 0x...> object.
For example:
"This is a tree with path <PBGitTree: 0x1313000>"
..instead of:
"This is a tree with path Documentation/ReleaseNotes"
We used to fall back on the ASCII encoding if UTF-8 did not work out. However,
this causes its own problems; ASCII is only valid for the lower 7 bytes. We
solve this by using Latin-1, which should have a valid character for every
byte sequence
Instead of creating a file with a random prefix, create a file with the same name in a temporary directory name. This way the quicklook window shows the correct filename.
This adds a QuickLook button that will allow you to directly view any file in
the tree view in QuickLook. This is really nice for PDF's and images. You can
select multiple files and even play a slideshow if you want.
Currently it does not remove temporary files it created. This means that they
will probably stay around until you reboot.