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

Refactoring. MRC removal. Part one. #827

Merged
merged 6 commits into from
Aug 15, 2022
Merged
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
19 changes: 0 additions & 19 deletions GitUpKit/Core/GCCommitDatabase.m
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,6 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.

#if __has_feature(objc_arc)
#error This file requires MRC
#endif

#import <sqlite3.h>

#import "GCPrivate.h"
Expand Down Expand Up @@ -368,7 +364,6 @@ - (instancetype)initWithRepository:(GCRepository*)repository databasePath:(NSStr
_options = options;

if (![self _initializeDatabase:path error:error]) {
[self release];
return nil;
}

Expand All @@ -377,32 +372,27 @@ - (instancetype)initWithRepository:(GCRepository*)repository databasePath:(NSStr
NSInteger currentVersion = [self _readVersion];
if (currentVersion == version) {
if (![self _checkReady:error]) {
[self release];
return nil;
}
} else {
if (_options & kGCCommitDatabaseOptions_QueryOnly) {
GC_SET_GENERIC_ERROR(@"Database is query-only");
[self release];
return nil;
}
sqlite3_close(_database);
_database = NULL;
XLOG_WARNING(@"Commit database for \"%@\" has an incompatible version (%li) and must be regenerated", _repository.repositoryPath, (long)currentVersion);
if (![[NSFileManager defaultManager] removeItemAtPath:path error:error] || ![self _initializeDatabase:path error:error] || ![self _initializeSchema:version error:error]) {
[self release];
return nil;
}
}
} else {
if (![self _initializeSchema:version error:error]) {
[self release];
return nil;
}
}

if (![self _initializeStatements:error]) {
[self release];
return nil;
}
}
Expand All @@ -417,10 +407,6 @@ - (void)dealloc {
free(_statements);
}
sqlite3_close(_database);

[_databasePath release];

[super dealloc];
}

#if DEBUG
Expand Down Expand Up @@ -903,10 +889,6 @@ - (BOOL)_addCommitsForTip:(const git_oid*)tipOID handler:(BOOL (^)())handler err
success = YES;

cleanup:
[deletedWords release];
[addedWords release];
[deletedLines release];
[addedLines release];
git_commit_free(mainParent);
GC_LIST_FOR_LOOP_POINTER(newRow, itemPtr) {
git_commit_free(itemPtr->commit);
Expand Down Expand Up @@ -1190,7 +1172,6 @@ - (NSArray*)findCommitsUsingHistory:(GCHistory*)history matching:(NSString*)matc
CHECK_LIBGIT2_FUNCTION_CALL(goto cleanup, status, == GIT_OK);
GCCommit* commit = [[GCCommit alloc] initWithRepository:_repository commit:rawCommit];
[results addObject:commit];
[commit release];
}
}
CALL_SQLITE_FUNCTION_GOTO(cleanup, sqlite3_reset, statements[kStatement_SearchCommits]);
Expand Down
10 changes: 5 additions & 5 deletions GitUpKit/Core/GCMacros.h
Original file line number Diff line number Diff line change
Expand Up @@ -177,13 +177,13 @@ static inline BOOL __GCPointerListContains(GCPointerList* list, void* pointer) {

#define GC_POINTER_LIST_CONTAINS(name, pointer) __GCPointerListContains(&name, pointer)

#define GC_POINTER_LIST_FOR_LOOP_VARIABLE(name, variable) \
variable = GC_POINTER_LIST_GET(name, 0); \
for (size_t __##variable = 0; (__##variable < name.count) && (variable = GC_POINTER_LIST_GET(name, __##variable), 1); ++__##variable)
#define GC_POINTER_LIST_FOR_LOOP_NO_BRIDGE(name, type, variable) \
type variable = (type)GC_POINTER_LIST_GET(name, 0); \
for (size_t __##variable = 0; (__##variable < name.count) && (variable = (type)GC_POINTER_LIST_GET(name, __##variable), 1); ++__##variable)

#define GC_POINTER_LIST_FOR_LOOP(name, type, variable) \
type variable; \
GC_POINTER_LIST_FOR_LOOP_VARIABLE(name, variable)
type variable = (__bridge type)GC_POINTER_LIST_GET(name, 0); \
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have to use __bridge casting to adapt ARC rules.

for (size_t __##variable = 0; (__##variable < name.count) && (variable = (__bridge type)GC_POINTER_LIST_GET(name, __##variable), 1); ++__##variable)

#define GC_POINTER_LIST_REVERSE_FOR_LOOP(name, type, variable) \
type variable = name.count ? GC_POINTER_LIST_GET(name, name.count - 1) : NULL; \
Expand Down
2 changes: 1 addition & 1 deletion GitUpKit/Core/GCRemote.m
Original file line number Diff line number Diff line change
Expand Up @@ -523,7 +523,7 @@ - (BOOL)_pushAllReferencesToRemote:(git_remote*)remote branches:(BOOL)branches t
if (success) {
success = [self _pushToRemote:remote refspecs:(const char**)GC_POINTER_LIST_ROOT(buffers) count:GC_POINTER_LIST_COUNT(buffers) error:error];
}
GC_POINTER_LIST_FOR_LOOP(buffers, char*, buffer) {
GC_POINTER_LIST_FOR_LOOP_NO_BRIDGE(buffers, char*, buffer) {
free(buffer);
}
GC_POINTER_LIST_FREE(buffers);
Expand Down
8 changes: 4 additions & 4 deletions GitUpKit/GitUpKit.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@
E267E1D01B84D80500BAB377 /* GCRepository+Status.h in Headers */ = {isa = PBXBuildFile; fileRef = E20EB08D19FC76160031A075 /* GCRepository+Status.h */; settings = {ATTRIBUTES = (Public, ); }; };
E267E1D11B84D83100BAB377 /* GCBranch.m in Sources */ = {isa = PBXBuildFile; fileRef = E2C338DC19F85C8600063D95 /* GCBranch.m */; };
E267E1D21B84D83100BAB377 /* GCCommit.m in Sources */ = {isa = PBXBuildFile; fileRef = E2C338DE19F85C8600063D95 /* GCCommit.m */; };
E267E1D31B84D83100BAB377 /* GCCommitDatabase.m in Sources */ = {isa = PBXBuildFile; fileRef = E2FEED451AEAA6AD00CBED80 /* GCCommitDatabase.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; };
E267E1D31B84D83100BAB377 /* GCCommitDatabase.m in Sources */ = {isa = PBXBuildFile; fileRef = E2FEED451AEAA6AD00CBED80 /* GCCommitDatabase.m */; };
E267E1D41B84D83100BAB377 /* GCDiff.m in Sources */ = {isa = PBXBuildFile; fileRef = E2B14B5D1A8A764400003E64 /* GCDiff.m */; };
E267E1D51B84D83100BAB377 /* GCFoundation.m in Sources */ = {isa = PBXBuildFile; fileRef = E2790D411ACB1B1100965A98 /* GCFoundation.m */; };
E267E1D61B84D83100BAB377 /* GCFunctions.m in Sources */ = {isa = PBXBuildFile; fileRef = E21739F21A4FE39E00EC6777 /* GCFunctions.m */; };
Expand Down Expand Up @@ -224,13 +224,13 @@
E267E2121B84DB4200BAB377 /* GINode.h in Headers */ = {isa = PBXBuildFile; fileRef = E2D4DEA61A4D57AA00B6AF66 /* GINode.h */; settings = {ATTRIBUTES = (Public, ); }; };
E267E2131B84DB4200BAB377 /* GISplitDiffView.h in Headers */ = {isa = PBXBuildFile; fileRef = E2891AB11AE15BB600E58C77 /* GISplitDiffView.h */; settings = {ATTRIBUTES = (Public, ); }; };
E267E2141B84DB4200BAB377 /* GIUnifiedDiffView.h in Headers */ = {isa = PBXBuildFile; fileRef = E2C9FF861AA510170051B2AE /* GIUnifiedDiffView.h */; settings = {ATTRIBUTES = (Public, ); }; };
E267E2151B84DB6E00BAB377 /* GIBranch.m in Sources */ = {isa = PBXBuildFile; fileRef = E2D4DEAE1A4D592000B6AF66 /* GIBranch.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; };
E267E2151B84DB6E00BAB377 /* GIBranch.m in Sources */ = {isa = PBXBuildFile; fileRef = E2D4DEAE1A4D592000B6AF66 /* GIBranch.m */; };
E267E2161B84DB6E00BAB377 /* GIDiffView.m in Sources */ = {isa = PBXBuildFile; fileRef = E2891AB51AE1684A00E58C77 /* GIDiffView.m */; };
E267E2171B84DB6E00BAB377 /* GIFunctions.m in Sources */ = {isa = PBXBuildFile; fileRef = E2B1BF321A85923800A999DF /* GIFunctions.m */; };
E267E2181B84DB6E00BAB377 /* GIGraph.m in Sources */ = {isa = PBXBuildFile; fileRef = E2D4DEA11A4D562300B6AF66 /* GIGraph.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; };
E267E2191B84DB6E00BAB377 /* GIGraphView.m in Sources */ = {isa = PBXBuildFile; fileRef = E2D4DEA31A4D562300B6AF66 /* GIGraphView.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; };
E267E21A1B84DB6E00BAB377 /* GILayer.m in Sources */ = {isa = PBXBuildFile; fileRef = E2D4DEB11A4D599200B6AF66 /* GILayer.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; };
E267E21B1B84DB6E00BAB377 /* GILine.m in Sources */ = {isa = PBXBuildFile; fileRef = E2D4DEAB1A4D587800B6AF66 /* GILine.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; };
E267E21A1B84DB6E00BAB377 /* GILayer.m in Sources */ = {isa = PBXBuildFile; fileRef = E2D4DEB11A4D599200B6AF66 /* GILayer.m */; };
E267E21B1B84DB6E00BAB377 /* GILine.m in Sources */ = {isa = PBXBuildFile; fileRef = E2D4DEAB1A4D587800B6AF66 /* GILine.m */; };
E267E21C1B84DB6E00BAB377 /* GINode.m in Sources */ = {isa = PBXBuildFile; fileRef = E2D4DEA71A4D57AA00B6AF66 /* GINode.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; };
E267E21D1B84DB6E00BAB377 /* GIPrivate.m in Sources */ = {isa = PBXBuildFile; fileRef = E21A88F21A9471B300255AC3 /* GIPrivate.m */; };
E267E21E1B84DB6E00BAB377 /* GISplitDiffView.m in Sources */ = {isa = PBXBuildFile; fileRef = E2891AB21AE15BB600E58C77 /* GISplitDiffView.m */; };
Expand Down
4 changes: 0 additions & 4 deletions GitUpKit/Interface/GIBranch.m
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,6 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.

#if __has_feature(objc_arc)
#error This file requires MRC
#endif

#import "GIPrivate.h"

@implementation GIBranch
Expand Down
10 changes: 2 additions & 8 deletions GitUpKit/Interface/GILayer.m
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,6 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.

#if __has_feature(objc_arc)
#error This file requires MRC
#endif

#import "GIPrivate.h"

@implementation GILayer {
Expand All @@ -37,16 +33,14 @@ - (instancetype)initWithIndex:(NSUInteger)index {
- (void)dealloc {
CFRelease(_lines);
CFRelease(_nodes);

[super dealloc];
}

- (NSArray*)nodes {
return (NSArray*)_nodes;
return (__bridge NSArray*)_nodes;
}

- (NSArray*)lines {
return (NSArray*)_lines;
return (__bridge NSArray*)_lines;
}

- (void)addNode:(GINode*)node {
Expand Down
11 changes: 1 addition & 10 deletions GitUpKit/Interface/GILine.m
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,6 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.

#if __has_feature(objc_arc)
#error This file requires MRC
#endif

#import "GIPrivate.h"

@implementation GILine {
Expand All @@ -34,16 +30,11 @@ - (instancetype)initWithBranch:(GIBranch*)branch {
}

- (void)dealloc {
#if __GI_HAS_APPKIT__
[_color release];
#endif
CFRelease(_nodes);

[super dealloc];
}

- (NSArray*)nodes {
return (NSArray*)_nodes;
return (__bridge NSArray*)_nodes;
}

- (void)addNode:(GINode*)node {
Expand Down