Skip to content

Commit

Permalink
Use clang-format to format source code
Browse files Browse the repository at this point in the history
  • Loading branch information
swisspol committed Aug 31, 2016
1 parent 4bd51e3 commit 727673b
Show file tree
Hide file tree
Showing 107 changed files with 4,793 additions and 4,418 deletions.
11 changes: 11 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
Language: Cpp
BasedOnStyle: Google
ColumnLimit: 0
AlignTrailingComments: false
DerivePointerAlignment: false
AlwaysBreakBeforeMultilineStrings: false
AccessModifierOffset: -2
ObjCSpaceBeforeProtocolList: true
SortIncludes: false
...
16 changes: 8 additions & 8 deletions Examples/GitDiff/AppDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,15 @@ - (instancetype)initWithRepository:(GCLiveRepository*)repository {
- (void)viewWillShow {
// Configure the repo to automatically compute the HEAD to workdir diff (aka "unified status")
self.repository.statusMode = kGCLiveRepositoryStatusMode_Unified;

// Refresh contents immediately
[self _reloadContents];
}

- (void)viewDidHide {
// Unload the diff to save memory
[self setDeltas:nil usingConflicts:nil];

// Stop watching the repo status as it's not needed anymore
self.repository.statusMode = kGCLiveRepositoryStatusMode_Disabled;
}
Expand Down Expand Up @@ -76,7 +76,7 @@ @implementation AppDelegate {

- (void)applicationDidFinishLaunching:(NSNotification*)notification {
NSError* error;

// Prompt user for a directory
NSOpenPanel* openPanel = [NSOpenPanel openPanel];
openPanel.canChooseDirectories = YES;
Expand All @@ -85,26 +85,26 @@ - (void)applicationDidFinishLaunching:(NSNotification*)notification {
[NSApp terminate:nil];
}
NSString* path = openPanel.URL.path;

// Attempt to open the directory as a Git repo
_repository = [[GCLiveRepository alloc] initWithExistingLocalRepository:path error:&error];
if (_repository == nil) {
[NSApp presentError:error];
[NSApp terminate:nil];
}

// A repo must have an associated NSUndoManager for the undo/redo system to work
// We simply use the one of the window
_repository.undoManager = _window.undoManager;

// Each GIWindow expects a GIWindowController around
_windowController = [[GIWindowController alloc] initWithWindow:_window];

// Create the view controller and add its view to the window
_viewController = [[LiveDiffViewController alloc] initWithRepository:_repository];
_viewController.view.frame = [_window.contentView bounds];
[_window.contentView addSubview:_viewController.view];

// Show the window
[_window makeKeyAndOrderFront:nil];
}
Expand Down
14 changes: 7 additions & 7 deletions Examples/GitDown/AppDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ @implementation AppDelegate {

- (void)applicationDidFinishLaunching:(NSNotification*)notification {
NSError* error;

// Prompt user for a directory
NSOpenPanel* openPanel = [NSOpenPanel openPanel];
openPanel.canChooseDirectories = YES;
Expand All @@ -38,30 +38,30 @@ - (void)applicationDidFinishLaunching:(NSNotification*)notification {
[NSApp terminate:nil];
}
NSString* path = openPanel.URL.path;

// Attempt to open the directory as a Git repo
_repository = [[GCLiveRepository alloc] initWithExistingLocalRepository:path error:&error];
if (_repository == nil) {
[NSApp presentError:error];
[NSApp terminate:nil];
}

// A repo must have an associated NSUndoManager for the undo/redo system to work
// We simply use the one of the window
_repository.undoManager = _window.undoManager;

// Each GIWindow expects a GIWindowController around
_windowController = [[GIWindowController alloc] initWithWindow:_window];
// Create the view controller and add its view to the window

// Create the view controller and add its view to the window
#if 1
_viewController = [[GIStashListViewController alloc] initWithRepository:_repository];
#else
_viewController = [[GIAdvancedCommitViewController alloc] initWithRepository:_repository];
#endif
_viewController.view.frame = [_window.contentView bounds];
[_window.contentView addSubview:_viewController.view];

// Show the window
[_window makeKeyAndOrderFront:nil];
}
Expand Down
22 changes: 11 additions & 11 deletions Examples/GitY/Document.m
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ - (BOOL)readFromURL:(NSURL*)url ofType:(NSString*)typeName error:(NSError**)outE
if (_repository) {
if (_repository.bare) {
if (outError) {
*outError = [NSError errorWithDomain:NSCocoaErrorDomain code:-1 userInfo:@{NSLocalizedDescriptionKey: @"Bare repositories are not supported!"}];
*outError = [NSError errorWithDomain:NSCocoaErrorDomain code:-1 userInfo:@{ NSLocalizedDescriptionKey : @"Bare repositories are not supported!" }];
}
} else {
_repository.delegate = self;
Expand All @@ -60,7 +60,7 @@ - (BOOL)readFromURL:(NSURL*)url ofType:(NSString*)typeName error:(NSError**)outE

- (void)close {
[super close];

_repository.delegate = nil;
_repository = nil;
}
Expand All @@ -70,28 +70,28 @@ - (void)makeWindowControllers {
[self addWindowController:_windowController];
}

- (void)windowControllerDidLoadNib:(NSWindowController *)aController {
- (void)windowControllerDidLoadNib:(NSWindowController*)aController {
[super windowControllerDidLoadNib:aController];

_toolbar = [[NSToolbar alloc] initWithIdentifier:@"default"];
_toolbar.delegate = self;
_windowController.window.toolbar = _toolbar;

NSSortDescriptor* descriptor = [[NSSortDescriptor alloc] initWithKey:@"date" ascending:NO selector:@selector(compare:)];
_arrayController.sortDescriptors = @[descriptor];
_arrayController.sortDescriptors = @[ descriptor ];

_diffContentsViewController = [[GIDiffContentsViewController alloc] initWithRepository:_repository];
_diffContentsViewController.delegate = self;
_diffContentsViewController.headerView = _headerView;
_diffContentsViewController.view.frame = _diffView.frame;
[_diffView.superview replaceSubview:_diffView with:_diffContentsViewController.view];

_commitViewController = [[GIAdvancedCommitViewController alloc] initWithRepository:_repository];
[[_tabView tabViewItemAtIndex:1] setView:_commitViewController.view];

_headerViewMinHeight = _headerView.frame.size.height - _messageTextField.frame.size.height;
_messageTextFieldMargins = _headerView.frame.size.width - _messageTextField.frame.size.width;

[self repositoryDidUpdateHistory:nil];
}

Expand All @@ -115,7 +115,7 @@ - (NSToolbarItem*)toolbar:(NSToolbar*)toolbar itemForItemIdentifier:(NSString*)i
}

- (NSArray*)toolbarDefaultItemIdentifiers:(NSToolbar*)toolbar {
return @[kToolbarItem_LeftView, NSToolbarFlexibleSpaceItemIdentifier, kToolbarItem_RightView];
return @[ kToolbarItem_LeftView, NSToolbarFlexibleSpaceItemIdentifier, kToolbarItem_RightView ];
}

- (NSArray*)toolbarAllowedItemIdentifiers:(NSToolbar*)toolbar {
Expand Down
12 changes: 6 additions & 6 deletions Examples/iGit/ViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -21,27 +21,27 @@ @implementation ViewController

- (void)viewDidLoad {
[super viewDidLoad];

NSString* path = [[NSTemporaryDirectory() stringByAppendingPathComponent:[[NSProcessInfo processInfo] globallyUniqueString]] stringByAppendingPathExtension:@"git"];
[[NSFileManager defaultManager] removeItemAtPath:path error:NULL];
GCRepository* repo = [[GCRepository alloc] initWithNewLocalRepository:path bare:YES error:NULL];
assert(repo);

GCRemote* remote = [repo addRemoteWithName:@"origin" url:[NSURL URLWithString:@"https://github.com/git-up/test-repo-base.git"] error:NULL];
assert(remote);
assert([repo cloneUsingRemote:remote recursive:NO error:NULL]);

assert([repo writeConfigOptionForLevel:kGCConfigLevel_Local variable:@"user.name" withValue:@"User" error:NULL]);
assert([repo writeConfigOptionForLevel:kGCConfigLevel_Local variable:@"user.email" withValue:@"user@example.com" error:NULL]);

GCIndex* index = [repo createInMemoryIndex:NULL];
assert([repo addFile:@"empty.data" withContents:[NSData data] toIndex:index error:NULL]);
GCCommit* commit = [repo createCommitFromIndex:index withParents:nil message:@"Initial commit" error:NULL];
assert(commit);

GCLocalBranch* branch = [repo createLocalBranchFromCommit:commit withName:@"empty" force:NO error:NULL];
assert(branch);

self.view.backgroundColor = [UIColor greenColor];
}

Expand Down
Loading

0 comments on commit 727673b

Please sign in to comment.