mirror of
https://github.com/kennethreitz-archive/gitx.git
synced 2026-06-05 23:40:18 +00:00
8243cf58b3
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>
44 lines
957 B
Objective-C
44 lines
957 B
Objective-C
//
|
|
// PBGitTree.h
|
|
// GitTest
|
|
//
|
|
// Created by Pieter de Bie on 15-06-08.
|
|
// Copyright 2008 __MyCompanyName__. All rights reserved.
|
|
//
|
|
|
|
#import <Cocoa/Cocoa.h>
|
|
#import "PBGitRepository.h"
|
|
|
|
@interface PBGitTree : NSObject {
|
|
long long _fileSize;
|
|
|
|
NSString* sha;
|
|
NSString* path;
|
|
PBGitRepository* repository;
|
|
__weak PBGitTree* parent;
|
|
NSArray* children;
|
|
BOOL leaf;
|
|
|
|
NSString* localFileName;
|
|
NSDate* localMtime;
|
|
}
|
|
|
|
+ (PBGitTree*) rootForCommit: (id) commit;
|
|
+ (PBGitTree*) treeForTree: (PBGitTree*) tree andPath: (NSString*) path;
|
|
- (void) saveToFolder: (NSString *) directory;
|
|
|
|
- (NSString*) tmpFileNameForContents;
|
|
- (long long)fileSize;
|
|
|
|
@property(copy) NSString* sha;
|
|
@property(copy) NSString* path;
|
|
@property(assign) BOOL leaf;
|
|
@property(retain) PBGitRepository* repository;
|
|
@property(assign) __weak PBGitTree* parent;
|
|
|
|
@property(readonly) NSArray* children;
|
|
@property(readonly) NSString* fullPath;
|
|
@property(readonly) NSString* contents;
|
|
|
|
@end
|