diff --git a/GitUp/Application/Base.lproj/PreferencesWindowController.xib b/GitUp/Application/Base.lproj/PreferencesWindowController.xib index d6f7bc99..04f0a448 100644 --- a/GitUp/Application/Base.lproj/PreferencesWindowController.xib +++ b/GitUp/Application/Base.lproj/PreferencesWindowController.xib @@ -1,8 +1,8 @@ - + - + @@ -22,22 +22,22 @@ - + - - + + - + - + - + @@ -45,7 +45,7 @@ - + @@ -69,9 +69,9 @@ - + - + @@ -104,7 +104,7 @@ - + @@ -112,9 +112,9 @@ - + - + @@ -147,7 +147,7 @@ - + @@ -155,7 +155,7 @@ - + In "Simple" commit mode, GitUp unifies the working directory and index i.e. there is no staging area. @@ -181,7 +181,7 @@ You must close and reopen any opened repositories in GitUp after changing this s - + @@ -189,10 +189,10 @@ You must close and reopen any opened repositories in GitUp after changing this s - + + - + @@ -348,6 +365,7 @@ You must close and reopen any opened repositories in GitUp after changing this s + @@ -360,6 +378,7 @@ You must close and reopen any opened repositories in GitUp after changing this s + @@ -370,10 +389,10 @@ You must close and reopen any opened repositories in GitUp after changing this s - + - + @@ -381,10 +400,10 @@ You must close and reopen any opened repositories in GitUp after changing this s - + - + @@ -408,7 +427,7 @@ You must close and reopen any opened repositories in GitUp after changing this s - + @@ -416,10 +435,10 @@ You must close and reopen any opened repositories in GitUp after changing this s - + - + @@ -451,10 +470,10 @@ You must close and reopen any opened repositories in GitUp after changing this s - + - + @@ -477,7 +496,7 @@ You must close and reopen any opened repositories in GitUp after changing this s - + @@ -485,7 +504,7 @@ You must close and reopen any opened repositories in GitUp after changing this s - + @@ -493,10 +512,10 @@ You must close and reopen any opened repositories in GitUp after changing this s - + - + @@ -517,7 +536,7 @@ You must close and reopen any opened repositories in GitUp after changing this s - + @@ -535,7 +554,7 @@ You must close and reopen any opened repositories in GitUp after changing this s - + @@ -543,10 +562,10 @@ You must close and reopen any opened repositories in GitUp after changing this s - + - + @@ -627,11 +646,15 @@ You must close and reopen any opened repositories in GitUp after changing this s + + + + @@ -642,10 +665,28 @@ You must close and reopen any opened repositories in GitUp after changing this s - + + diff --git a/GitUpKit/Core/GCLiveRepository.h b/GitUpKit/Core/GCLiveRepository.h index fa9bef96..2cafdcc0 100644 --- a/GitUpKit/Core/GCLiveRepository.h +++ b/GitUpKit/Core/GCLiveRepository.h @@ -99,6 +99,8 @@ extern NSString* const GCLiveRepositoryAmendOperationReason; @property(nonatomic, readonly) GCDiff* workingDirectoryStatus; // Nil on error @property(nonatomic, readonly) GCDiff* indexStatus; // Nil on error @property(nonatomic, readonly) NSDictionary* indexConflicts; // Nil on error +@property(nonatomic, copy) NSString *filePattern; +- (void)updateFilePattern:(NSString *)filePattern; @property(nonatomic, getter=areStashesEnabled) BOOL stashesEnabled; // Default is NO - Should be enabled *after* setting delegate so any error can be received @property(nonatomic, readonly) NSArray* stashes; // Nil on error diff --git a/GitUpKit/Core/GCLiveRepository.m b/GitUpKit/Core/GCLiveRepository.m index 5c39c340..9b61d465 100644 --- a/GitUpKit/Core/GCLiveRepository.m +++ b/GitUpKit/Core/GCLiveRepository.m @@ -629,7 +629,7 @@ - (void)_updateStatus:(BOOL)notify { CFAbsoluteTime time = CFAbsoluteTimeGetCurrent(); if (_statusMode == kGCLiveRepositoryStatusMode_Unified) { - unifiedDiff = [self diffWorkingDirectoryWithHEAD:nil + unifiedDiff = [self diffWorkingDirectoryWithHEAD:self.filePattern options:(self.diffBaseOptions | kGCDiffOption_IncludeUntracked | kGCDiffOption_FindRenames) maxInterHunkLines:_diffMaxInterHunkLines maxContextLines:_diffMaxContextLines @@ -639,13 +639,13 @@ - (void)_updateStatus:(BOOL)notify { } } else { XLOG_DEBUG_CHECK(_statusMode == kGCLiveRepositoryStatusMode_Normal); - indexDiff = [self diffRepositoryIndexWithHEAD:nil + indexDiff = [self diffRepositoryIndexWithHEAD:self.filePattern options:(self.diffBaseOptions | kGCDiffOption_FindRenames) maxInterHunkLines:_diffMaxInterHunkLines maxContextLines:_diffMaxContextLines error:&error]; if (indexDiff) { - workdirDiff = [self diffWorkingDirectoryWithRepositoryIndex:nil + workdirDiff = [self diffWorkingDirectoryWithRepositoryIndex:self.filePattern options:(self.diffBaseOptions | kGCDiffOption_IncludeUntracked) maxInterHunkLines:_diffMaxInterHunkLines maxContextLines:_diffMaxContextLines @@ -725,6 +725,15 @@ - (void)_updateStashes:(BOOL)notify { } } +#pragma mark - FilePattern +- (void)updateFilePattern:(NSString *)filePattern { + if ([self.filePattern isEqualToString:filePattern]) { + return; + } + self.filePattern = filePattern == nil ? nil : [NSString stringWithFormat:@"*%@*", filePattern]; + [self _updateStatus:YES]; +} + #pragma mark - Operations - (void)setUndoManager:(NSUndoManager*)undoManager { diff --git a/GitUpKit/Extensions/NSView+Embedding.h b/GitUpKit/Extensions/NSView+Embedding.h new file mode 100644 index 00000000..6b2a76de --- /dev/null +++ b/GitUpKit/Extensions/NSView+Embedding.h @@ -0,0 +1,16 @@ +// +// NSView+Embedding.h +// GitUpKit (OSX) +// +// Created by Dmitry Lobanov on 06.04.2020. +// + +#import + +NS_ASSUME_NONNULL_BEGIN + +@interface NSView (Embedding) +- (void)embedView:(NSView *)view; +@end + +NS_ASSUME_NONNULL_END diff --git a/GitUpKit/Extensions/NSView+Embedding.m b/GitUpKit/Extensions/NSView+Embedding.m new file mode 100644 index 00000000..95cbbece --- /dev/null +++ b/GitUpKit/Extensions/NSView+Embedding.m @@ -0,0 +1,37 @@ +// +// NSView+Embedding.m +// GitUpKit (OSX) +// +// Created by Dmitry Lobanov on 06.04.2020. +// + +#import "NSView+Embedding.h" + +@implementation NSView (Embedding) +- (void)embedView:(NSView *)view { + [self.class embedView:view inView:self]; +} + ++ (void)embedView:(NSView *)view inView:(NSView *)superview { + [superview addSubview:view]; + view.translatesAutoresizingMaskIntoConstraints = NO; + + if (superview != nil && view != nil) { + if (@available(macOS 10.11, *)) { + NSArray *constraints = @[ + [view.leftAnchor constraintEqualToAnchor:superview.leftAnchor], + [view.topAnchor constraintEqualToAnchor:superview.topAnchor], + [view.bottomAnchor constraintEqualToAnchor:superview.bottomAnchor], + [view.rightAnchor constraintEqualToAnchor:superview.rightAnchor] + ]; + [NSLayoutConstraint activateConstraints:constraints]; + } else { + // Fallback on earlier versions + NSArray *verticalConstraints = [NSLayoutConstraint constraintsWithVisualFormat:@"V:|[view]|" options:0 metrics:nil views:@{@"view": view}]; + NSArray *horizontalConstraints = [NSLayoutConstraint constraintsWithVisualFormat:@"H:|[view]|" options:0 metrics:nil views:@{@"view": view}]; + NSArray *constraints = [[NSArray arrayWithArray:verticalConstraints] arrayByAddingObjectsFromArray:horizontalConstraints]; + [NSLayoutConstraint activateConstraints:constraints]; + } + } +} +@end diff --git a/GitUpKit/GitUpKit.xcodeproj/project.pbxproj b/GitUpKit/GitUpKit.xcodeproj/project.pbxproj index 51d02971..779d5d2a 100644 --- a/GitUpKit/GitUpKit.xcodeproj/project.pbxproj +++ b/GitUpKit/GitUpKit.xcodeproj/project.pbxproj @@ -7,6 +7,8 @@ objects = { /* Begin PBXBuildFile section */ + 0A5BF6A62578EFB300B98F4F /* NSView+Embedding.h in Headers */ = {isa = PBXBuildFile; fileRef = 0A5BF6A42578EFB200B98F4F /* NSView+Embedding.h */; }; + 0A5BF6A72578EFB300B98F4F /* NSView+Embedding.m in Sources */ = {isa = PBXBuildFile; fileRef = 0A5BF6A52578EFB300B98F4F /* NSView+Embedding.m */; }; 0AC8525923A122C400479160 /* GILaunchServicesLocator.h in Headers */ = {isa = PBXBuildFile; fileRef = 0AC8525723A122C400479160 /* GILaunchServicesLocator.h */; settings = {ATTRIBUTES = (Public, ); }; }; 0AC8525A23A122C400479160 /* GILaunchServicesLocator.m in Sources */ = {isa = PBXBuildFile; fileRef = 0AC8525823A122C400479160 /* GILaunchServicesLocator.m */; }; 1DF371CD22F5262300EF7BD9 /* GCLiveRepository+Utilities.h in Headers */ = {isa = PBXBuildFile; fileRef = 1DF371CB22F5262300EF7BD9 /* GCLiveRepository+Utilities.h */; }; @@ -427,6 +429,8 @@ /* End PBXContainerItemProxy section */ /* Begin PBXFileReference section */ + 0A5BF6A42578EFB200B98F4F /* NSView+Embedding.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSView+Embedding.h"; sourceTree = ""; }; + 0A5BF6A52578EFB300B98F4F /* NSView+Embedding.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSView+Embedding.m"; sourceTree = ""; }; 0AC8525723A122C400479160 /* GILaunchServicesLocator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GILaunchServicesLocator.h; sourceTree = ""; }; 0AC8525823A122C400479160 /* GILaunchServicesLocator.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GILaunchServicesLocator.m; sourceTree = ""; }; 1DF371CB22F5262300EF7BD9 /* GCLiveRepository+Utilities.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "GCLiveRepository+Utilities.h"; sourceTree = ""; }; @@ -870,6 +874,8 @@ E2735B2119FF763300ED0CC4 /* Extensions */ = { isa = PBXGroup; children = ( + 0A5BF6A42578EFB200B98F4F /* NSView+Embedding.h */, + 0A5BF6A52578EFB300B98F4F /* NSView+Embedding.m */, E259C2D41A64FAA40079616B /* GCHistory+Rewrite-Tests.m */, E2D414891A02D68700B99634 /* GCHistory+Rewrite.h */, E2D4148A1A02D68700B99634 /* GCHistory+Rewrite.m */, @@ -1187,6 +1193,7 @@ E267E2281B84DBE700BAB377 /* GIWindowController.h in Headers */, E267E2361B84DC3900BAB377 /* GICommitListViewController.h in Headers */, E267E2371B84DC3900BAB377 /* GIDiffContentsViewController.h in Headers */, + 0A5BF6A62578EFB300B98F4F /* NSView+Embedding.h in Headers */, E267E2381B84DC3900BAB377 /* GIDiffFilesViewController.h in Headers */, E267E2391B84DC3900BAB377 /* GISnapshotListViewController.h in Headers */, 1DF371CD22F5262300EF7BD9 /* GCLiveRepository+Utilities.h in Headers */, @@ -1470,6 +1477,7 @@ E267E1D11B84D83100BAB377 /* GCBranch.m in Sources */, E267E1D21B84D83100BAB377 /* GCCommit.m in Sources */, E267E1D31B84D83100BAB377 /* GCCommitDatabase.m in Sources */, + 0A5BF6A72578EFB300B98F4F /* NSView+Embedding.m in Sources */, E267E1D41B84D83100BAB377 /* GCDiff.m in Sources */, E267E1D51B84D83100BAB377 /* GCFoundation.m in Sources */, E267E1D61B84D83100BAB377 /* GCFunctions.m in Sources */, diff --git a/GitUpKit/Views/Base.lproj/GIAdvancedCommitViewController.xib b/GitUpKit/Views/Base.lproj/GIAdvancedCommitViewController.xib index eeeb1ec7..faa5e4eb 100644 --- a/GitUpKit/Views/Base.lproj/GIAdvancedCommitViewController.xib +++ b/GitUpKit/Views/Base.lproj/GIAdvancedCommitViewController.xib @@ -16,6 +16,7 @@ + @@ -103,30 +104,80 @@ - + - - - + + - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + NSNegateBoolean + + + + - - - - - + + + + + + + + + + + + + + + + + @@ -271,5 +322,6 @@ DQ + diff --git a/GitUpKit/Views/GIAdvancedCommitViewController.m b/GitUpKit/Views/GIAdvancedCommitViewController.m index f9afaa20..c6ece9cc 100644 --- a/GitUpKit/Views/GIAdvancedCommitViewController.m +++ b/GitUpKit/Views/GIAdvancedCommitViewController.m @@ -25,9 +25,12 @@ #import "GIColorView.h" #import "GIInterface.h" #import "GIWindowController.h" + +#import "NSView+Embedding.h" + #import "XLFacilityMacros.h" -@interface GIAdvancedCommitViewController () +@interface GIAdvancedCommitViewController () @property(nonatomic, weak) IBOutlet GIColorView* workdirHeaderView; @property(nonatomic, weak) IBOutlet NSView* workdirFilesView; @property(nonatomic, weak) IBOutlet GIColorView* indexHeaderView; @@ -37,6 +40,7 @@ @interface GIAdvancedCommitViewController ()