Skip to content

Commit

Permalink
Format source code before next release
Browse files Browse the repository at this point in the history
  • Loading branch information
lucasderraugh committed May 25, 2022
1 parent 4a1bc7e commit a93dd8d
Show file tree
Hide file tree
Showing 12 changed files with 60 additions and 61 deletions.
4 changes: 2 additions & 2 deletions GitUp/Application/AppDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ - (void)_openRepositoryWithURL:(NSURL*)url inTab:(BOOL)inTab withCloneMode:(Clon
}
[document showWindows];
}

if (documentWasAlreadyOpen) {
if ((NSUInteger)windowModeID != NSNotFound) {
[(Document*)document setWindowModeID:windowModeID];
Expand Down Expand Up @@ -353,7 +353,7 @@ - (NSDictionary*)_processToolCommand:(NSDictionary*)input {

#pragma mark - Actions

- (BOOL)validateMenuItem:(NSMenuItem *)menuItem {
- (BOOL)validateMenuItem:(NSMenuItem*)menuItem {
if (menuItem.action == @selector(checkForUpdates:)) {
return [_updater validateMenuItem:menuItem];
}
Expand Down
2 changes: 1 addition & 1 deletion GitUp/Application/PreferencesWindowController.m
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ - (void)windowDidLoad {
];

self.selectedItemIdentifier = PreferencesWindowController_Identifier_General;

[self loadUserDefaults];
}

Expand Down
8 changes: 4 additions & 4 deletions GitUp/Tool/main.m
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ int main(int argc, const char* argv[]) {
@autoreleasepool {
const char* command = "open";
const char* option = "";

for (int i = 1; i < argc; i++) {
const char* arg = argv[i];
// Commands
Expand Down Expand Up @@ -177,14 +177,14 @@ BOOL isEqual(const char* stringA, const char* stringB) {

BOOL isEqualToAny(const char* string, int count, ...) {
va_list ap;
va_start (ap, count); /* Initialize the argument list. */
va_start(ap, count); /* Initialize the argument list. */

for (int i = 0; i < count; i++) {
const char* aString = va_arg(ap, const char*);
if (isEqual(string, aString)) {
return YES;
}
}
va_end (ap); /* Clean up. */
va_end(ap); /* Clean up. */
return NO;
}
2 changes: 1 addition & 1 deletion GitUpKit/Components/GIDiffContentsViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,7 @@ - (void)_reloadDeltas {

CFStringRef fileExtension = (__bridge CFStringRef)delta.canonicalPath.pathExtension;
CFStringRef fileUTI = UTTypeCreatePreferredIdentifierForTag(kUTTagClassFilenameExtension, fileExtension, NULL);
BOOL isImage = [NSImage.imageTypes containsObject:(__bridge NSString *)(fileUTI)];
BOOL isImage = [NSImage.imageTypes containsObject:(__bridge NSString*)(fileUTI)];
CFRelease(fileUTI);
if (isImage) {
GIImageDiffView* imageDiffView = [[GIImageDiffView alloc] initWithRepository:self.repository];
Expand Down
8 changes: 4 additions & 4 deletions GitUpKit/Core/GCDiff.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,21 +71,21 @@ typedef void (^GCDiffEndHunkHandler)(void);
@end

/* "x" means non-nil, "-" means nil and [X] means canonical path
Old New
Unmodified [X] -
Ignored [X] -
Untracked [X] -
Unreadable [X] -
Added - [X]
Deleted [X] -
Modified x [X]
Renamed x [X]
Copied x [X]
TypeChanged x [X]
Conflicted x [X]
*/
@interface GCDiffDelta : NSObject
Expand Down
16 changes: 8 additions & 8 deletions GitUpKit/Core/GCIndex.m
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,7 @@ - (BOOL)addLinesInWorkingDirectoryFile:(NSString*)path toIndex:(GCIndex*)index e
[patch enumerateUsingBeginHunkHandler:NULL
lineHandler:^(GCLineDiffChange change, NSUInteger oldLineNumber, NSUInteger newLineNumber, const char* contentBytes, NSUInteger contentLength) {
/* Comparing workdir to index:
Change | Filter | Write?
------------|------------|------------
Unmodified | - | YES
Expand All @@ -366,7 +366,7 @@ - (BOOL)addLinesInWorkingDirectoryFile:(NSString*)path toIndex:(GCIndex*)index e
------------|------------|------------
Deleted | YES | NO
| NO | YES
*/
BOOL shouldWrite = YES;
switch (change) {
Expand Down Expand Up @@ -452,7 +452,7 @@ - (BOOL)resetLinesInFile:(NSString*)path index:(GCIndex*)index toCommit:(GCCommi
[patch enumerateUsingBeginHunkHandler:NULL
lineHandler:^(GCLineDiffChange change, NSUInteger oldLineNumber, NSUInteger newLineNumber, const char* contentBytes, NSUInteger contentLength) {
/* Comparing index to commit:
Change | Filter | Write?
------------|------------|------------
Unmodified | - | YES
Expand All @@ -462,7 +462,7 @@ - (BOOL)resetLinesInFile:(NSString*)path index:(GCIndex*)index toCommit:(GCCommi
------------|------------|------------
Deleted | YES | YES
| NO | NO
*/
BOOL shouldWrite = YES;
switch (change) {
Expand Down Expand Up @@ -530,7 +530,7 @@ - (BOOL)checkoutLinesInFileToWorkingDirectory:(NSString*)path fromIndex:(GCIndex
[patch enumerateUsingBeginHunkHandler:NULL
lineHandler:^(GCLineDiffChange change, NSUInteger oldLineNumber, NSUInteger newLineNumber, const char* contentBytes, NSUInteger contentLength) {
/* Comparing workdir to index:
Change | Filter | Write?
------------|------------|------------
Unmodified | - | YES
Expand All @@ -540,7 +540,7 @@ - (BOOL)checkoutLinesInFileToWorkingDirectory:(NSString*)path fromIndex:(GCIndex
------------|------------|------------
Deleted | YES | YES
| NO | NO
*/
BOOL shouldWrite = YES;
switch (change) {
Expand Down Expand Up @@ -638,7 +638,7 @@ - (BOOL)copyLinesInFile:(NSString*)path fromOtherIndex:(GCIndex*)otherIndex toIn
[patch enumerateUsingBeginHunkHandler:NULL
lineHandler:^(GCLineDiffChange change, NSUInteger oldLineNumber, NSUInteger newLineNumber, const char* contentBytes, NSUInteger contentLength) {
/* Comparing other index to index:
Change | Filter | Write?
------------|------------|------------
Unmodified | - | YES
Expand All @@ -648,7 +648,7 @@ - (BOOL)copyLinesInFile:(NSString*)path fromOtherIndex:(GCIndex*)otherIndex toIn
------------|------------|------------
Deleted | YES | NO
| NO | YES
*/
BOOL shouldWrite = YES;
switch (change) {
Expand Down
14 changes: 7 additions & 7 deletions GitUpKit/Interface/GIImageDiffView.m
Original file line number Diff line number Diff line change
Expand Up @@ -151,12 +151,12 @@ - (void)updateOldImage {
- (NSSize)imageSizeWithoutLoadingFromPath:(NSString*)path {
NSURL* imageFileURL = [NSURL fileURLWithPath:path];
CFStringRef fileUTI = UTTypeCreatePreferredIdentifierForTag(kUTTagClassFilenameExtension, (__bridge CFStringRef)path.pathExtension, NULL);
BOOL isPDF = [(__bridge NSString *)fileUTI isEqualToString:@"com.adobe.pdf"];
BOOL isPDF = [(__bridge NSString*)fileUTI isEqualToString:@"com.adobe.pdf"];
CFRelease(fileUTI);

CGFloat width = 0.0f;
CGFloat height = 0.0f;

if (isPDF) {
CGPDFDocumentRef document = CGPDFDocumentCreateWithURL((CFURLRef)imageFileURL);
CGPDFPageRef page = CGPDFDocumentGetPage(document, 1);
Expand All @@ -171,7 +171,7 @@ - (NSSize)imageSizeWithoutLoadingFromPath:(NSString*)path {
}
CFDictionaryRef imageProperties = CGImageSourceCopyPropertiesAtIndex(imageSource, 0, NULL);
CFRelease(imageSource);

if (imageProperties != NULL) {
CFNumberRef widthNum = CFDictionaryGetValue(imageProperties, kCGImagePropertyPixelWidth);
if (widthNum != NULL) {
Expand All @@ -194,7 +194,7 @@ - (NSSize)imageSizeWithoutLoadingFromPath:(NSString*)path {
CFRelease(imageProperties);
}
}

return NSMakeSize(width, height);
}

Expand Down Expand Up @@ -297,7 +297,7 @@ - (CGRect)desiredImageFrame:(CGFloat)width {
CGSize originalImageSize = [self originalDiffImageSize];
CGFloat adjustedImageWidth = originalImageSize.width;
CGFloat adjustedImageHeight = originalImageSize.height;

if (adjustedImageWidth < CGFLOAT_EPSILON) {
adjustedImageWidth = 200;
}
Expand All @@ -318,7 +318,7 @@ - (CGRect)fittedImageFrame {
CGSize originalImageSize = [self originalDiffImageSize];
CGFloat adjustedImageWidth = originalImageSize.width;
CGFloat adjustedImageHeight = originalImageSize.height;

if (adjustedImageWidth < CGFLOAT_EPSILON) {
adjustedImageWidth = 200;
}
Expand Down
43 changes: 21 additions & 22 deletions GitUpKit/Utilities/GIAppKit.m
Original file line number Diff line number Diff line change
Expand Up @@ -170,8 +170,8 @@ - (void)awakeFromNib {
[super awakeFromNib];

[self updateFont];
NSUserDefaults *defaults = NSUserDefaults.standardUserDefaults;

NSUserDefaults* defaults = NSUserDefaults.standardUserDefaults;
self.continuousSpellCheckingEnabled = [defaults boolForKey:GICommitMessageViewUserDefaultKey_EnableSpellChecking];
self.automaticSpellingCorrectionEnabled = NO; // Don't trust IB
self.grammarCheckingEnabled = NO; // Don't trust IB
Expand All @@ -184,7 +184,7 @@ - (void)awakeFromNib {
self.textColor = NSColor.textColor; // Don't trust IB
self.backgroundColor = NSColor.textBackgroundColor; // Don't trust IB
[self.textContainer replaceLayoutManager:[[GILayoutManager alloc] init]];

self.layoutManager.showsInvisibleCharacters = [defaults boolForKey:GICommitMessageViewUserDefaultKey_ShowInvisibleCharacters];

[defaults addObserver:self forKeyPath:GICommitMessageViewUserDefaultKey_ShowInvisibleCharacters options:0 context:(__bridge void*)[GICommitMessageView class]];
Expand Down Expand Up @@ -326,7 +326,7 @@ - (void)keyDown:(NSEvent*)event {

@end

@interface GILayoutManager() <NSLayoutManagerDelegate>
@interface GILayoutManager () <NSLayoutManagerDelegate>
@end

@implementation GILayoutManager
Expand All @@ -336,45 +336,44 @@ - (instancetype)init {
if (self) {
self.delegate = self;
}

return self;
}

- (NSUInteger)layoutManager:(NSLayoutManager *)layoutManager shouldGenerateGlyphs:(const CGGlyph *)glyphs properties:(const NSGlyphProperty *)props characterIndexes:(const NSUInteger *)charIndexes font:(NSFont *)aFont forGlyphRange:(NSRange)glyphRange {

- (NSUInteger)layoutManager:(NSLayoutManager*)layoutManager shouldGenerateGlyphs:(const CGGlyph*)glyphs properties:(const NSGlyphProperty*)props characterIndexes:(const NSUInteger*)charIndexes font:(NSFont*)aFont forGlyphRange:(NSRange)glyphRange {
XLOG_DEBUG_CHECK([aFont.fontName isEqualToString:@"Menlo-Regular"]);

if (layoutManager.showsInvisibleCharacters) {
NSTextStorage *textStorage = layoutManager.textStorage;
NSTextStorage* textStorage = layoutManager.textStorage;
size_t glyphSize = sizeof(CGGlyph) * glyphRange.length;
size_t propertySize = sizeof(NSGlyphProperty) * glyphRange.length;
CGGlyph *replacementGlyphs = malloc(glyphSize);
NSGlyphProperty *replacementProperties = malloc(propertySize);
CGGlyph* replacementGlyphs = malloc(glyphSize);
NSGlyphProperty* replacementProperties = malloc(propertySize);
memcpy(replacementGlyphs, glyphs, glyphSize);
memcpy(replacementProperties, props, propertySize);
NSString *string = textStorage.string;
NSCharacterSet *spaceCharacterSet = [NSCharacterSet characterSetWithCharactersInString:@" "];
NSCharacterSet *newlineCharacterSet = [NSCharacterSet characterSetWithCharactersInString:@"\n"];
NSString* string = textStorage.string;

NSCharacterSet* spaceCharacterSet = [NSCharacterSet characterSetWithCharactersInString:@" "];
NSCharacterSet* newlineCharacterSet = [NSCharacterSet characterSetWithCharactersInString:@"\n"];

NSUInteger i = 0;
while (i < glyphRange.length) {
NSUInteger characterIndex = charIndexes[i];
unichar character = [string characterAtIndex:characterIndex];

if ([spaceCharacterSet characterIsMember:character]) {
replacementGlyphs[i] = (CGGlyph)[aFont glyphWithName:@"periodcentered"];

} else if ([newlineCharacterSet characterIsMember:character]) {
replacementGlyphs[i] = (CGGlyph)[aFont glyphWithName:@"carriagereturn"];
replacementProperties[i] = 0;
}

i += [string rangeOfComposedCharacterSequenceAtIndex:characterIndex].length;
}

[self setGlyphs:replacementGlyphs properties:replacementProperties characterIndexes:charIndexes font:aFont forGlyphRange:glyphRange];

free(replacementGlyphs);
free(replacementProperties);
} else {
Expand All @@ -384,7 +383,7 @@ - (NSUInteger)layoutManager:(NSLayoutManager *)layoutManager shouldGenerateGlyph
return glyphRange.length;
}

- (NSControlCharacterAction)layoutManager:(NSLayoutManager *)layoutManager shouldUseAction:(NSControlCharacterAction)action forControlCharacterAtIndex:(NSUInteger)characterIndex {
- (NSControlCharacterAction)layoutManager:(NSLayoutManager*)layoutManager shouldUseAction:(NSControlCharacterAction)action forControlCharacterAtIndex:(NSUInteger)characterIndex {
if (layoutManager.showsInvisibleCharacters && action & NSControlCharacterActionLineBreak) {
[layoutManager setNotShownAttribute:NO forGlyphAtIndex:[layoutManager glyphIndexForCharacterAtIndex:characterIndex]];
}
Expand Down
4 changes: 2 additions & 2 deletions GitUpKit/Utilities/GICustomToolbarItem.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
// Performs validation of a custom control view, or any one of two control
// children.
@interface GICustomToolbarItem : NSToolbarItem
@property (nonatomic, weak) IBOutlet NSControl* primaryControl;
@property (nonatomic, weak) IBOutlet NSControl* secondaryControl;
@property(nonatomic, weak) IBOutlet NSControl* primaryControl;
@property(nonatomic, weak) IBOutlet NSControl* secondaryControl;
+ (void)validateAsUserInterfaceItem:(id)item;
@end

Expand Down
2 changes: 1 addition & 1 deletion GitUpKit/Utilities/GILaunchServicesLocator.m
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ + (BOOL)hasInstalledApplicationForBundleIdentifier:(NSString*)bundleIdentifier {
CFErrorRef error = NULL;
NSArray* applications = CFBridgingRelease(LSCopyApplicationURLsForBundleIdentifier((__bridge CFStringRef)bundleIdentifier, &error));
if (error) {
//TODO: Handle error.
// TODO: Handle error.
CFRelease(error);
return NO;
}
Expand Down
16 changes: 8 additions & 8 deletions GitUpKit/Views/GIMapViewController+Operations.m
Original file line number Diff line number Diff line change
Expand Up @@ -808,14 +808,14 @@ - (void)_pushLocalBranch:(GCHistoryLocalBranch*)branch toRemote:(GCRemote*)remot
if (updatedBranch && remoteBranch) {
if (![updatedBranch.upstream isEqualToBranch:remoteBranch]) {
if (askSetUpstreamOnPush) {
[self confirmUserActionWithAlertType:kGIAlertType_Note
title:[NSString stringWithFormat:NSLocalizedString(@"Do you want to set the upstream for \"%@\"?", nil), updatedBranch.name]
message:[NSString stringWithFormat:NSLocalizedString(@"This will configure the local branch \"%@\" to track the remote branch \"%@\" you just pushed to.", nil), updatedBranch.name, remoteBranch.name]
button:NSLocalizedString(@"Set Upstream", nil)
suppressionUserDefaultKey:nil
block:^{
[self setUpstream:remoteBranch forLocalBranch:branch];
}];
[self confirmUserActionWithAlertType:kGIAlertType_Note
title:[NSString stringWithFormat:NSLocalizedString(@"Do you want to set the upstream for \"%@\"?", nil), updatedBranch.name]
message:[NSString stringWithFormat:NSLocalizedString(@"This will configure the local branch \"%@\" to track the remote branch \"%@\" you just pushed to.", nil), updatedBranch.name, remoteBranch.name]
button:NSLocalizedString(@"Set Upstream", nil)
suppressionUserDefaultKey:nil
block:^{
[self setUpstream:remoteBranch forLocalBranch:branch];
}];
} else {
[self setUpstream:remoteBranch forLocalBranch:branch];
}
Expand Down
2 changes: 1 addition & 1 deletion format-source.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# brew install clang-format

CLANG_FORMAT_VERSION=`clang-format -version | awk '{ print $3 }'`
if [[ "$CLANG_FORMAT_VERSION" != "11.0.0" ]]; then
if [[ "$CLANG_FORMAT_VERSION" < "11.0.0" ]]; then
echo "Unsupported clang-format version"
exit 1
fi
Expand Down

0 comments on commit a93dd8d

Please sign in to comment.