Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Misc small fixes and improvements #226

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions Classes/Controllers/PBRefController.m
Original file line number Diff line number Diff line change
Expand Up @@ -430,13 +430,12 @@ - (BOOL)tableView:(NSTableView *)aTableView
NSString *subject = [dropCommit subject];
if ([subject length] > 99)
subject = [[subject substringToIndex:99] stringByAppendingString:@"…"];
NSString *infoText = [NSString stringWithFormat:@"Move the %@ to point to the commit: %@", [ref refishType], subject];

NSAlert *alert = [NSAlert alertWithMessageText:[NSString stringWithFormat:@"Move %@: %@", [ref refishType], [ref shortName]]
defaultButton:@"Move"
alternateButton:@"Cancel"
otherButton:nil
informativeTextWithFormat:infoText];
informativeTextWithFormat:@"Move the %@ to point to the commit: %@", [ref refishType], subject];
[alert setShowsSuppressionButton:YES];

[alert beginSheetModalForWindow:[historyController.repository.windowController window]
Expand Down
34 changes: 0 additions & 34 deletions Classes/Util/NSString_RegEx.h

This file was deleted.

97 changes: 0 additions & 97 deletions Classes/Util/NSString_RegEx.m

This file was deleted.

17 changes: 10 additions & 7 deletions Classes/git/PBGitIndex.m
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
#import "PBGitRepository.h"
#import "PBGitBinary.h"
#import "PBEasyPipe.h"
#import "NSString_RegEx.h"
#import "PBChangedFile.h"

NSString *PBGitIndexIndexRefreshStatus = @"PBGitIndexIndexRefreshStatus";
Expand Down Expand Up @@ -96,12 +95,16 @@ - (void)setAmend:(BOOL)newAmend
// We do this by reading in the previous commit, and storing the information
// in a dictionary. This dictionary will then later be read by [self commit:]
NSString *message = [repository outputForCommand:@"cat-file commit HEAD"];
NSArray *match = [message substringsMatchingRegularExpression:@"\nauthor ([^\n]*) <([^\n>]*)> ([0-9]+[^\n]*)\n" count:3 options:0 ranges:nil error:nil];
if (match)
amendEnvironment = [NSDictionary dictionaryWithObjectsAndKeys:[match objectAtIndex:1], @"GIT_AUTHOR_NAME",
[match objectAtIndex:2], @"GIT_AUTHOR_EMAIL",
[match objectAtIndex:3], @"GIT_AUTHOR_DATE",
nil];

NSRegularExpression *regex = [[NSRegularExpression alloc] initWithPattern: @"\nauthor ([^\n]*) <([^\n>]*)> ([0-9]+[^\n]*)\n" options:0 error: NULL];
NSTextCheckingResult *result = [regex firstMatchInString: message options: 0 range: NSMakeRange( 0, message.length )];
if (result.numberOfRanges == 4) {
amendEnvironment = @{
@"GIT_AUTHOR_NAME": [message substringWithRange: [result rangeAtIndex: 1]],
@"GIT_AUTHOR_EMAIL": [message substringWithRange: [result rangeAtIndex: 2]],
@"GIT_AUTHOR_DATE": [message substringWithRange: [result rangeAtIndex: 3]]
};
}

// Find the commit message
NSRange r = [message rangeOfString:@"\n\n"];
Expand Down
11 changes: 0 additions & 11 deletions Classes/git/PBGitLane.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,6 @@ class PBGitLane {
d_sha = *sha;
}

PBGitLane(NSString *sha)
{
git_oid_fromstr(&d_sha, [sha UTF8String]);
d_index = s_colorIndex++;
}

PBGitLane()
{
d_index = s_colorIndex++;
}

bool isCommit(git_oid sha) const
{
return !git_oid_cmp(&d_sha, &sha);
Expand Down
14 changes: 0 additions & 14 deletions Classes/git/PBGitLane.mm
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,6 @@
//

#import "PBGitLane.h"
//class PBGitLane {
// static int s_colorIndex;
//
// char d_sha[20];
// int d_index;
//
//public:
// PBGitLane(NSString *sha);
//
// bool isCommit(NSString *sha) const;
// int index(); const;
//
// static resetColors();
//};

int PBGitLane::s_colorIndex = 0;

Expand Down
28 changes: 9 additions & 19 deletions Classes/git/PBGitRepository.m
Original file line number Diff line number Diff line change
Expand Up @@ -224,28 +224,18 @@ - (void) addRef:(GTReference*)gtRef
[refs setObject:[NSMutableArray arrayWithObject:ref] forKey:sha];
}

int addSubmoduleName(git_submodule *module, const char* name, void * context)
- (void) loadSubmodules
{
PBGitRepository *me = (__bridge PBGitRepository *)context;
PBGitSubmodule *sub = [[PBGitSubmodule alloc] init];
[sub setWorkingDirectory:me.workingDirectory];
[sub setSubmodule:module];
NSMutableArray *newSubmodules = [NSMutableArray array];


[me.submodules addObject:sub];
[self.gtRepo enumerateSubmodulesRecursively: NO usingBlock:^(GTSubmodule *submodule, BOOL *stop) {
PBGitSubmodule *sub = [[PBGitSubmodule alloc] init];
sub.workingDirectory = self.workingDirectory;
sub.submodule = submodule.git_submodule;
[newSubmodules addObject: sub];
}];

return 0;
}

- (void) loadSubmodules
{
self.submodules = [NSMutableArray array];
git_repository* theRepo = self.gtRepo.git_repository;
if (!theRepo)
{
return;
}
git_submodule_foreach(theRepo, addSubmoduleName, (__bridge void *)self);
self.submodules = newSubmodules;
}

- (void) reloadRefs
Expand Down
12 changes: 7 additions & 5 deletions Classes/git/PBGitRevList.mm
Original file line number Diff line number Diff line change
Expand Up @@ -267,14 +267,16 @@ - (void) walkRevisionListWithSpecifier:(PBGitRevSpecifier*)rev
}

if (![currentThread isCancelled]) {
#if DEBUG
NSTimeInterval duration = [[NSDate date] timeIntervalSinceDate:start];
//NSLog(@"Loaded %i commits in %f seconds (%f/sec)", num, duration, num/duration);
NSLog(@"Loaded %i commits in %f seconds (%f/sec)", num, duration, num/duration);
#endif
// Make sure the commits are stored before exiting.
NSDictionary *update = [NSDictionary dictionaryWithObjectsAndKeys:currentThread, kRevListThreadKey, revisions, kRevListRevisionsKey, nil];
[self performSelectorOnMainThread:@selector(updateCommits:) withObject:update waitUntilDone:YES];

[self performSelectorOnMainThread:@selector(finishedParsing) withObject:nil waitUntilDone:NO];
dispatch_async(dispatch_get_main_queue(), ^{
[self updateCommits:update];
[self finishedParsing];
});
}
else {
NSLog(@"[%@ %@] thread has been canceled", [self class], NSStringFromSelector(_cmd));
Expand Down
6 changes: 0 additions & 6 deletions GitX.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,6 @@
4A5D771D14A9A9CC00DF6C68 /* NSApplication+GitXScripting.m in Sources */ = {isa = PBXBuildFile; fileRef = 4A5D76A614A9A9CC00DF6C68 /* NSApplication+GitXScripting.m */; };
4A5D771E14A9A9CC00DF6C68 /* NSFileHandleExt.m in Sources */ = {isa = PBXBuildFile; fileRef = 4A5D76A814A9A9CC00DF6C68 /* NSFileHandleExt.m */; };
4A5D771F14A9A9CC00DF6C68 /* NSOutlineViewExt.m in Sources */ = {isa = PBXBuildFile; fileRef = 4A5D76AA14A9A9CC00DF6C68 /* NSOutlineViewExt.m */; };
4A5D772014A9A9CC00DF6C68 /* NSString_RegEx.m in Sources */ = {isa = PBXBuildFile; fileRef = 4A5D76AC14A9A9CC00DF6C68 /* NSString_RegEx.m */; };
4A5D772114A9A9CC00DF6C68 /* NSString_Truncate.m in Sources */ = {isa = PBXBuildFile; fileRef = 4A5D76AE14A9A9CC00DF6C68 /* NSString_Truncate.m */; };
4A5D772214A9A9CC00DF6C68 /* PBEasyFS.m in Sources */ = {isa = PBXBuildFile; fileRef = 4A5D76B014A9A9CC00DF6C68 /* PBEasyFS.m */; };
4A5D772314A9A9CC00DF6C68 /* PBEasyPipe.m in Sources */ = {isa = PBXBuildFile; fileRef = 4A5D76B214A9A9CC00DF6C68 /* PBEasyPipe.m */; };
Expand Down Expand Up @@ -563,8 +562,6 @@
4A5D76A814A9A9CC00DF6C68 /* NSFileHandleExt.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = NSFileHandleExt.m; sourceTree = "<group>"; };
4A5D76A914A9A9CC00DF6C68 /* NSOutlineViewExt.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NSOutlineViewExt.h; sourceTree = "<group>"; };
4A5D76AA14A9A9CC00DF6C68 /* NSOutlineViewExt.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = NSOutlineViewExt.m; sourceTree = "<group>"; };
4A5D76AB14A9A9CC00DF6C68 /* NSString_RegEx.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NSString_RegEx.h; sourceTree = "<group>"; };
4A5D76AC14A9A9CC00DF6C68 /* NSString_RegEx.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = NSString_RegEx.m; sourceTree = "<group>"; };
4A5D76AD14A9A9CC00DF6C68 /* NSString_Truncate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NSString_Truncate.h; sourceTree = "<group>"; };
4A5D76AE14A9A9CC00DF6C68 /* NSString_Truncate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = NSString_Truncate.m; sourceTree = "<group>"; };
4A5D76AF14A9A9CC00DF6C68 /* PBEasyFS.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PBEasyFS.h; sourceTree = "<group>"; };
Expand Down Expand Up @@ -1110,8 +1107,6 @@
4A5D76A814A9A9CC00DF6C68 /* NSFileHandleExt.m */,
4A5D76A914A9A9CC00DF6C68 /* NSOutlineViewExt.h */,
4A5D76AA14A9A9CC00DF6C68 /* NSOutlineViewExt.m */,
4A5D76AB14A9A9CC00DF6C68 /* NSString_RegEx.h */,
4A5D76AC14A9A9CC00DF6C68 /* NSString_RegEx.m */,
4A5D76AD14A9A9CC00DF6C68 /* NSString_Truncate.h */,
4A5D76AE14A9A9CC00DF6C68 /* NSString_Truncate.m */,
4A5D76AF14A9A9CC00DF6C68 /* PBEasyFS.h */,
Expand Down Expand Up @@ -1610,7 +1605,6 @@
4A5D771D14A9A9CC00DF6C68 /* NSApplication+GitXScripting.m in Sources */,
4A5D771E14A9A9CC00DF6C68 /* NSFileHandleExt.m in Sources */,
4A5D771F14A9A9CC00DF6C68 /* NSOutlineViewExt.m in Sources */,
4A5D772014A9A9CC00DF6C68 /* NSString_RegEx.m in Sources */,
4A5D772114A9A9CC00DF6C68 /* NSString_Truncate.m in Sources */,
4A5D772214A9A9CC00DF6C68 /* PBEasyFS.m in Sources */,
4A5D772314A9A9CC00DF6C68 /* PBEasyPipe.m in Sources */,
Expand Down