Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
dbd4ab8
Change inconsistent "SHA" uses to "OID"
tiennou Jul 12, 2014
86b0019
Just use the ref's OID directly.
tiennou Jul 12, 2014
56cd7a6
Use URLs for locating the working directory.
tiennou Jul 15, 2014
37db497
Private ivars go in class extensions.
tiennou Jul 15, 2014
af1c4b5
Property-fy PBGitIndex.
tiennou Jul 15, 2014
e05a628
Move some common actions up in the responder chain.
tiennou Jul 15, 2014
65ebec8
Show HEAD in the sidebar if it's detached
tiennou Feb 13, 2015
73cf163
added stashes property to PBGitRepository.
muhqu Aug 1, 2013
86801cf
add Stashes list to Sidebar.
muhqu Aug 1, 2013
5e950cb
keep stashes in sidebar updated when repository changes
muhqu Aug 6, 2013
650fbd9
wire-up stash actions: pop, apply, drop
muhqu Aug 6, 2013
3fdc4a3
added "Stash Changes" button and "Keep Index" checkbox to Commit View.
muhqu Aug 7, 2013
297d345
wire-up stash save, with keep index option
muhqu Aug 7, 2013
9d0767e
make "Stash Changes" button inactive if working copy is clean.
muhqu Aug 7, 2013
4402136
out-comment too verbose logging
muhqu Aug 11, 2013
3b38652
added App Menu items under "Repository"
muhqu Aug 11, 2013
88442a1
improve keyboard navigation in commit dialog
muhqu Aug 7, 2013
8e0615a
quick and dirty show stash error messages via showErrorSheet
muhqu Aug 21, 2013
381cc3d
Missing initialization
tiennou Feb 13, 2015
ba99cf3
Cosmetics
tiennou Feb 13, 2015
8440a3b
Silence the analyzer
tiennou Feb 13, 2015
1aa7aae
Prevents refs/stash from being deleted
tiennou Feb 13, 2015
90a07b1
Workaround because the commit controller isn't part of the responder …
tiennou Feb 13, 2015
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
Prev Previous commit
Next Next commit
Use URLs for locating the working directory.
  • Loading branch information
tiennou committed Feb 13, 2015
commit 56cd7a6d564122f29010c0a6b1025dd59faf134d
23 changes: 10 additions & 13 deletions Classes/Controllers/PBGitHistoryController.m
Original file line number Diff line number Diff line change
Expand Up @@ -566,27 +566,24 @@ - (void)showCommitsFromTree:(id)sender

- (void)showInFinderAction:(id)sender
{
NSString *workingDirectory = [[repository workingDirectory] stringByAppendingString:@"/"];
NSString *path;
NSWorkspace *ws = [NSWorkspace sharedWorkspace];
NSURL *workingDirectoryURL = self.repository.workingDirectoryURL;
NSMutableArray *URLs = [NSMutableArray array];

for (NSString *filePath in [sender representedObject]) {
path = [workingDirectory stringByAppendingPathComponent:filePath];
[ws selectFile: path inFileViewerRootedAtPath:path];
}

[URLs addObject:[workingDirectoryURL URLByAppendingPathComponent:filePath]];
}
[[NSWorkspace sharedWorkspace] activateFileViewerSelectingURLs:URLs];
}

- (void)openFilesAction:(id)sender
{
NSString *workingDirectory = [[repository workingDirectory] stringByAppendingString:@"/"];
NSString *path;
NSWorkspace *ws = [NSWorkspace sharedWorkspace];
NSURL *workingDirectoryURL = self.repository.workingDirectoryURL;
NSMutableArray *URLs = [NSMutableArray array];

for (NSString *filePath in [sender representedObject]) {
path = [workingDirectory stringByAppendingPathComponent:filePath];
[ws openFile:path];
}
[URLs addObject:[workingDirectoryURL URLByAppendingPathComponent:filePath]];
}
[[NSWorkspace sharedWorkspace] openURLs:URLs withAppBundleIdentifier:nil options:0 additionalEventParamDescriptor:nil launchIdentifiers:NULL];
}

- (void) checkoutFiles:(id)sender
Expand Down
29 changes: 14 additions & 15 deletions Classes/Controllers/PBGitIndexController.m
Original file line number Diff line number Diff line change
Expand Up @@ -210,9 +210,9 @@ - (void) unstageFilesAction:(id) sender
- (void) openFilesAction:(id) sender
{
NSArray *files = [sender representedObject];
NSString *workingDirectory = [commitController.repository workingDirectory];
NSURL *workingDirectoryURL = commitController.repository.workingDirectoryURL;
for (PBChangedFile *file in files)
[[NSWorkspace sharedWorkspace] openFile:[workingDirectory stringByAppendingPathComponent:[file path]]];
[[NSWorkspace sharedWorkspace] openURL:[workingDirectoryURL URLByAppendingPathComponent:[file path]]];
}

- (void) ignoreFilesAction:(id) sender
Expand Down Expand Up @@ -244,23 +244,22 @@ - (void) showInFinderAction:(id) sender
NSArray *selectedFiles = [sender representedObject];
if ([selectedFiles count] == 0)
return;
NSString *workingDirectory = [[commitController.repository workingDirectory] stringByAppendingString:@"/"];
NSString *path = [workingDirectory stringByAppendingPathComponent:[[selectedFiles objectAtIndex:0] path]];
NSWorkspace *ws = [NSWorkspace sharedWorkspace];
[ws selectFile: path inFileViewerRootedAtPath:nil];
NSURL *workingDirectoryURL = commitController.repository.workingDirectoryURL;
NSURL *filePath = [workingDirectoryURL URLByAppendingPathComponent:[[selectedFiles objectAtIndex:0] path]];

[[NSWorkspace sharedWorkspace] activateFileViewerSelectingURLs:@[filePath]];
}

- (void)moveToTrashAction:(id)sender
{
NSArray *selectedFiles = [sender representedObject];

NSString *workingDirectory = [commitController.repository workingDirectory];
NSURL* workDirURL = [NSURL fileURLWithPath:workingDirectory isDirectory:YES];
NSURL *workingDirectoryURL = commitController.repository.workingDirectoryURL;

BOOL anyTrashed = NO;
for (PBChangedFile* file in selectedFiles)
for (PBChangedFile *file in selectedFiles)
{
NSURL* fileURL = [workDirURL URLByAppendingPathComponent:[file path]];
NSURL* fileURL = [workingDirectoryURL URLByAppendingPathComponent:[file path]];

NSError* error = nil;
NSURL* resultURL = nil;
Expand Down Expand Up @@ -343,14 +342,14 @@ - (BOOL)tableView:(NSTableView *)tv

// External, to drag them to for example XCode or Textmate
NSArrayController *controller = [tv tag] == 0 ? unstagedFilesController : stagedFilesController;
NSArray *files = [[controller arrangedObjects] objectsAtIndexes:rowIndexes];
NSString *workingDirectory = [commitController.repository workingDirectory];
NSArray *files = [controller.arrangedObjects objectsAtIndexes:rowIndexes];
NSURL *workingDirectoryURL = commitController.repository.workingDirectoryURL;

NSMutableArray *filenames = [NSMutableArray arrayWithCapacity:[rowIndexes count]];
NSMutableArray *URLs = [NSMutableArray arrayWithCapacity:rowIndexes.count];
for (PBChangedFile *file in files)
[filenames addObject:[workingDirectory stringByAppendingPathComponent:[file path]]];
[URLs addObject:[workingDirectoryURL URLByAppendingPathComponent:file.path]];

[pboard setPropertyList:filenames forType:NSFilenamesPboardType];
[pboard setPropertyList:URLs forType:NSURLPboardType];
return YES;
}

Expand Down
11 changes: 3 additions & 8 deletions Classes/Controllers/PBGitWindowController.m
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,7 @@ - (void)synchronizeWindowTitleWithDocumentName
[super synchronizeWindowTitleWithDocumentName];

// Point window proxy icon at project directory, not internal .git dir
NSString *workingDirectory = [self.repository workingDirectory];
if (workingDirectory)
{
[[self window] setRepresentedURL:[NSURL fileURLWithPath:workingDirectory
isDirectory:YES]];
}
[[self window] setRepresentedURL:self.repository.workingDirectoryURL];
}

- (void)windowWillClose:(NSNotification *)notification
Expand Down Expand Up @@ -176,13 +171,13 @@ - (void)showErrorSheetTitle:(NSString *)title message:(NSString *)message argume

- (IBAction) revealInFinder:(id)sender
{
[[NSWorkspace sharedWorkspace] openFile:[repository workingDirectory]];
[[NSWorkspace sharedWorkspace] openURL:self.repository.workingDirectoryURL];
}

- (IBAction) openInTerminal:(id)sender
{
TerminalApplication *term = [SBApplication applicationWithBundleIdentifier: @"com.apple.Terminal"];
NSString *workingDirectory = [[repository workingDirectory] stringByAppendingString:@"/"];
NSString *workingDirectory = [self.repository.workingDirectoryURL.path stringByAppendingString:@"/"];
NSString *cmd = [NSString stringWithFormat: @"cd \"%@\"; clear; echo '# Opened by GitX:'; git status", workingDirectory];
[term doScript: cmd in: nil];
[NSThread sleepForTimeInterval: 0.1];
Expand Down
6 changes: 2 additions & 4 deletions Classes/Views/PBRemoteProgressSheet.m
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ + (void) beginRemoteProgressSheetForArguments:(NSArray *)args
[PBRemoteProgressSheet beginRemoteProgressSheetForArguments:args
title:theTitle
description:theDescription
inDir:[repo workingDirectory]
inDir:repo.workingDirectoryURL.path
windowController:repo.windowController];
}

Expand All @@ -110,7 +110,7 @@ + (void) beginRemoteProgressSheetForArguments:(NSArray *)args
[PBRemoteProgressSheet beginRemoteProgressSheetForArguments:args
title:theTitle
description:theDescription
inDir:[repo workingDirectory]
inDir:repo.workingDirectoryURL.path
windowController:repo.windowController
hideSuccessScreen:hideSucc];
}
Expand Down Expand Up @@ -162,8 +162,6 @@ - (void) beginRemoteProgressSheetForArguments:(NSArray *)args
[gitTask launch];
}



#pragma mark Notifications

- (void) taskCompleted:(NSNotification *)notification
Expand Down
1 change: 1 addition & 0 deletions Classes/git/PBGitIndex.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ extern NSString *PBGitIndexOperationFailed;
// Whether we want the changes for amending,
// or for
@property BOOL amend;
@property (weak, readonly) PBGitRepository *repository;

- (id)initWithRepository:(PBGitRepository *)repository;

Expand Down
17 changes: 8 additions & 9 deletions Classes/git/PBGitIndex.m
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ - (void)postOperationFailed:(NSString *)description;

@implementation PBGitIndex

@synthesize repository=repository; /* WIP: Switch to automatic synthesize */

- (id)initWithRepository:(PBGitRepository *)theRepository
{
if (!(self = [super init]))
Expand All @@ -64,11 +66,8 @@ - (id)initWithRepository:(PBGitRepository *)theRepository
NSAssert(theRepository, @"PBGitIndex requires a repository");

repository = theRepository;
NSString* workingPath = theRepository.workingDirectory;
if (workingPath)
{
workingDirectory = [NSURL fileURLWithPath:workingPath];
}
workingDirectory = repository.workingDirectoryURL;

files = [NSMutableArray array];

return self;
Expand Down Expand Up @@ -455,10 +454,10 @@ - (NSString *)diffForFile:(PBChangedFile *)file staged:(BOOL)staged contextLines
if (file.status == NEW) {
NSStringEncoding encoding;
NSError *error = nil;
NSString *path = [[repository workingDirectory] stringByAppendingPathComponent:file.path];
NSString *contents = [NSString stringWithContentsOfFile:path
usedEncoding:&encoding
error:&error];
NSURL *fileURL = [self.repository.workingDirectoryURL URLByAppendingPathComponent:file.path];
NSString *contents = [NSString stringWithContentsOfURL:fileURL
usedEncoding:&encoding
error:&error];
if (error)
return nil;

Expand Down
5 changes: 3 additions & 2 deletions Classes/git/PBGitRepository.h
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,9 @@ static NSString * PBStringFromBranchFilterType(PBGitXBranchFilterType type) {
- (BOOL)executeHook:(NSString *)name output:(NSString **)output GITX_DEPRECATED;
- (BOOL)executeHook:(NSString *)name withArgs:(NSArray*) arguments output:(NSString **)output GITX_DEPRECATED;

- (NSString *)workingDirectory;
- (NSString *) projectName;
- (NSString *)workingDirectory GITX_DEPRECATED;
- (NSURL *)workingDirectoryURL;
- (NSString *)projectName;
- (NSString *)gitIgnoreFilename;
- (BOOL)isBareRepository;

Expand Down
17 changes: 6 additions & 11 deletions Classes/git/PBGitRepository.m
Original file line number Diff line number Diff line change
Expand Up @@ -555,18 +555,13 @@ - (void) readCurrentBranch
self.currentBranch = [self addBranch: [self headRef]];
}

- (NSString *) workingDirectory
- (NSURL *)workingDirectoryURL {
return self.gtRepo.fileURL;
}

- (NSString *)workingDirectory
{
const char* workdir = git_repository_workdir(self.gtRepo.git_repository);
if (workdir)
{
NSString* result = [[NSString stringWithUTF8String:workdir] stringByStandardizingPath];
return result;
}
else
{
return self.fileURL.path;
}
return [self.workingDirectoryURL path];
}

#pragma mark Remotes
Expand Down