From 8c37f466e3f49bf5000c010be2369fa6d4dd9350 Mon Sep 17 00:00:00 2001 From: Ben Chatelain Date: Fri, 20 Mar 2015 18:54:05 -0700 Subject: [PATCH 1/2] Add NS_DESIGNATED_INITIALIZER macro to init methds --- ObjectiveGit/GTBlame.h | 2 +- ObjectiveGit/GTBlameHunk.h | 2 +- ObjectiveGit/GTBranch.h | 2 +- ObjectiveGit/GTConfiguration+Private.h | 2 +- ObjectiveGit/GTEnumerator.h | 2 +- ObjectiveGit/GTFetchHeadEntry.h | 2 +- ObjectiveGit/GTFilter.h | 2 +- ObjectiveGit/GTFilterList.h | 2 +- ObjectiveGit/GTFilterSource.h | 2 +- ObjectiveGit/GTIndex.h | 2 +- ObjectiveGit/GTIndexEntry.h | 2 +- ObjectiveGit/GTOID.h | 4 ++-- ObjectiveGit/GTObject.h | 2 +- ObjectiveGit/GTObjectDatabase.h | 2 +- ObjectiveGit/GTOdbObject.h | 2 +- ObjectiveGit/GTReference.h | 2 +- ObjectiveGit/GTReflog+Private.h | 2 +- ObjectiveGit/GTReflogEntry+Private.h | 2 +- ObjectiveGit/GTRemote.h | 2 +- ObjectiveGit/GTRepository.h | 2 +- ObjectiveGit/GTStatusDelta.h | 2 +- ObjectiveGit/GTSubmodule.h | 2 +- ObjectiveGit/GTTreeBuilder.h | 2 +- 23 files changed, 24 insertions(+), 24 deletions(-) diff --git a/ObjectiveGit/GTBlame.h b/ObjectiveGit/GTBlame.h index ec931424f..da4a67b7b 100644 --- a/ObjectiveGit/GTBlame.h +++ b/ObjectiveGit/GTBlame.h @@ -16,7 +16,7 @@ @interface GTBlame : NSObject /// Designated initializer. -- (instancetype)initWithGitBlame:(git_blame *)blame; +- (instancetype)initWithGitBlame:(git_blame *)blame NS_DESIGNATED_INITIALIZER; /// Get all the hunks in the blame. A convenience wrapper around `enumerateHunksUsingBlock:` @property (nonatomic, strong, readonly) NSArray *hunks; diff --git a/ObjectiveGit/GTBlameHunk.h b/ObjectiveGit/GTBlameHunk.h index de3f1abb0..d5a4e3ee9 100644 --- a/ObjectiveGit/GTBlameHunk.h +++ b/ObjectiveGit/GTBlameHunk.h @@ -15,7 +15,7 @@ /// A `GTBlameHunk` is an object that provides authorship info for a set of lines in a `GTBlame`. @interface GTBlameHunk : NSObject -- (instancetype)initWithGitBlameHunk:(git_blame_hunk)hunk; +- (instancetype)initWithGitBlameHunk:(git_blame_hunk)hunk NS_DESIGNATED_INITIALIZER; /// A NSRange where `location` is the (1 based) starting line number, /// and `length` is the number of lines in the hunk. diff --git a/ObjectiveGit/GTBranch.h b/ObjectiveGit/GTBranch.h index 43734ffb4..fffc16f1b 100644 --- a/ObjectiveGit/GTBranch.h +++ b/ObjectiveGit/GTBranch.h @@ -52,7 +52,7 @@ typedef NS_ENUM(NSInteger, GTBranchType) { + (NSString *)localNamePrefix; + (NSString *)remoteNamePrefix; -- (id)initWithReference:(GTReference *)ref repository:(GTRepository *)repo; +- (id)initWithReference:(GTReference *)ref repository:(GTRepository *)repo NS_DESIGNATED_INITIALIZER; + (id)branchWithReference:(GTReference *)ref repository:(GTRepository *)repo; /// Get the target commit for this branch diff --git a/ObjectiveGit/GTConfiguration+Private.h b/ObjectiveGit/GTConfiguration+Private.h index cb24b03ba..318602d94 100644 --- a/ObjectiveGit/GTConfiguration+Private.h +++ b/ObjectiveGit/GTConfiguration+Private.h @@ -18,6 +18,6 @@ /// repository - The repository in which the config resides. May be nil. /// /// Returns the initialized object. -- (id)initWithGitConfig:(git_config *)config repository:(GTRepository *)repository; +- (id)initWithGitConfig:(git_config *)config repository:(GTRepository *)repository NS_DESIGNATED_INITIALIZER; @end diff --git a/ObjectiveGit/GTEnumerator.h b/ObjectiveGit/GTEnumerator.h index 8f877485a..47cceaad4 100644 --- a/ObjectiveGit/GTEnumerator.h +++ b/ObjectiveGit/GTEnumerator.h @@ -66,7 +66,7 @@ typedef NS_OPTIONS(unsigned int, GTEnumeratorOptions) { /// error - If not NULL, set to any error that occurs. /// /// Returns an initialized enumerator, or nil if an error occurs. -- (id)initWithRepository:(GTRepository *)repo error:(NSError **)error; +- (id)initWithRepository:(GTRepository *)repo error:(NSError **)error NS_DESIGNATED_INITIALIZER; /// Marks a commit to start traversal from. /// diff --git a/ObjectiveGit/GTFetchHeadEntry.h b/ObjectiveGit/GTFetchHeadEntry.h index 3a926c862..66f75b359 100644 --- a/ObjectiveGit/GTFetchHeadEntry.h +++ b/ObjectiveGit/GTFetchHeadEntry.h @@ -33,6 +33,6 @@ /// remoteURLString - URL String where this was originally fetched from. Cannot be nil. /// targetOID - Target OID. Cannot be nil. /// merge - Indicates if this is pending a merge. -- (instancetype)initWithReference:(GTReference *)reference remoteURLString:(NSString *)remoteURLString targetOID:(GTOID *)targetOID isMerge:(BOOL)merge; +- (instancetype)initWithReference:(GTReference *)reference remoteURLString:(NSString *)remoteURLString targetOID:(GTOID *)targetOID isMerge:(BOOL)merge NS_DESIGNATED_INITIALIZER; @end diff --git a/ObjectiveGit/GTFilter.h b/ObjectiveGit/GTFilter.h index 8205b04f4..13f356d11 100644 --- a/ObjectiveGit/GTFilter.h +++ b/ObjectiveGit/GTFilter.h @@ -45,7 +45,7 @@ extern const NSInteger GTFilterErrorNameAlreadyRegistered; /// applyBlock - The block to use to apply the filter. Cannot be nil. /// /// Returns the initialized object. -- (id)initWithName:(NSString *)name attributes:(NSString *)attributes applyBlock:(NSData * (^)(void **payload, NSData *from, GTFilterSource *source, BOOL *applied))applyBlock; +- (id)initWithName:(NSString *)name attributes:(NSString *)attributes applyBlock:(NSData * (^)(void **payload, NSData *from, GTFilterSource *source, BOOL *applied))applyBlock NS_DESIGNATED_INITIALIZER; /// Look up a filter based on its name. /// diff --git a/ObjectiveGit/GTFilterList.h b/ObjectiveGit/GTFilterList.h index dbaa0a556..607b38af9 100644 --- a/ObjectiveGit/GTFilterList.h +++ b/ObjectiveGit/GTFilterList.h @@ -26,7 +26,7 @@ typedef NS_OPTIONS(NSInteger, GTFilterListOptions) { /// filterList - The filter list to wrap and take ownership of. This filter list /// will be automatically disposed when the receiver deallocates. /// Must not be NULL. -- (instancetype)initWithGitFilterList:(git_filter_list *)filterList; +- (instancetype)initWithGitFilterList:(git_filter_list *)filterList NS_DESIGNATED_INITIALIZER; /// Returns the underlying `git_filter_list`. - (git_filter_list *)git_filter_list __attribute__((objc_returns_inner_pointer)); diff --git a/ObjectiveGit/GTFilterSource.h b/ObjectiveGit/GTFilterSource.h index c99cf4c66..aeda4d38c 100644 --- a/ObjectiveGit/GTFilterSource.h +++ b/ObjectiveGit/GTFilterSource.h @@ -43,6 +43,6 @@ typedef NS_ENUM(NSInteger, GTFilterSourceMode) { /// source - The filter source. Cannot be NULL. /// /// Returns the initialized object. -- (id)initWithGitFilterSource:(const git_filter_source *)source; +- (id)initWithGitFilterSource:(const git_filter_source *)source NS_DESIGNATED_INITIALIZER; @end diff --git a/ObjectiveGit/GTIndex.h b/ObjectiveGit/GTIndex.h index 1ba255c36..b649e3455 100644 --- a/ObjectiveGit/GTIndex.h +++ b/ObjectiveGit/GTIndex.h @@ -76,7 +76,7 @@ /// repository - The repository in which the index resides. Cannot be nil. /// /// Returns the initialized index. -- (instancetype)initWithGitIndex:(git_index *)index repository:(GTRepository *)repository; +- (instancetype)initWithGitIndex:(git_index *)index repository:(GTRepository *)repository NS_DESIGNATED_INITIALIZER; /// The underlying `git_index` object. - (git_index *)git_index __attribute__((objc_returns_inner_pointer)); diff --git a/ObjectiveGit/GTIndexEntry.h b/ObjectiveGit/GTIndexEntry.h index b60713edf..bba4a7436 100644 --- a/ObjectiveGit/GTIndexEntry.h +++ b/ObjectiveGit/GTIndexEntry.h @@ -54,7 +54,7 @@ typedef NS_ENUM(NSInteger, GTIndexEntryStatus) { /// entry - The libgit2 index entry. Cannot be NULL. /// /// Returns the initialized object. -- (id)initWithGitIndexEntry:(const git_index_entry *)entry; +- (id)initWithGitIndexEntry:(const git_index_entry *)entry NS_DESIGNATED_INITIALIZER; /// The underlying `git_index_entry` object. - (const git_index_entry *)git_index_entry __attribute__((objc_returns_inner_pointer)); diff --git a/ObjectiveGit/GTOID.h b/ObjectiveGit/GTOID.h index ac402f2c2..97617f3df 100644 --- a/ObjectiveGit/GTOID.h +++ b/ObjectiveGit/GTOID.h @@ -25,7 +25,7 @@ /// git_oid - The underlying git_oid. Cannot be NULL. /// /// Returns the initialized receiver. -- (id)initWithGitOid:(const git_oid *)git_oid; +- (id)initWithGitOid:(const git_oid *)git_oid NS_DESIGNATED_INITIALIZER; /// Initializes the receiver by converting the given SHA to an OID. /// @@ -57,7 +57,7 @@ /// error - Will be filled with an error object in if the SHA cannot be parsed /// /// Returns the initialized receiver. -- (id)initWithSHACString:(const char *)string error:(NSError **)error; +- (id)initWithSHACString:(const char *)string error:(NSError **)error NS_DESIGNATED_INITIALIZER; /// Creates a new instance with the given git_oid using initWithGitOid: + (instancetype)oidWithGitOid:(const git_oid *)git_oid; diff --git a/ObjectiveGit/GTObject.h b/ObjectiveGit/GTObject.h index aa07d70e6..b1236dddd 100644 --- a/ObjectiveGit/GTObject.h +++ b/ObjectiveGit/GTObject.h @@ -56,7 +56,7 @@ typedef NS_ENUM(int, GTObjectType) { @property (nonatomic, readonly) GTOID *OID; /// Convenience initializers -- (id)initWithObj:(git_object *)theObject inRepository:(GTRepository *)theRepo; +- (id)initWithObj:(git_object *)theObject inRepository:(GTRepository *)theRepo NS_DESIGNATED_INITIALIZER; + (id)objectWithObj:(git_object *)theObject inRepository:(GTRepository *)theRepo; /// The underlying `git_object`. diff --git a/ObjectiveGit/GTObjectDatabase.h b/ObjectiveGit/GTObjectDatabase.h index 7220df2da..b898c144d 100644 --- a/ObjectiveGit/GTObjectDatabase.h +++ b/ObjectiveGit/GTObjectDatabase.h @@ -38,7 +38,7 @@ /// error - The error if one occurred. /// /// Returns the initialized object. -- (id)initWithRepository:(GTRepository *)repo error:(NSError **)error; +- (id)initWithRepository:(GTRepository *)repo error:(NSError **)error NS_DESIGNATED_INITIALIZER; /// The underlying `git_odb` object. - (git_odb *)git_odb __attribute__((objc_returns_inner_pointer)); diff --git a/ObjectiveGit/GTOdbObject.h b/ObjectiveGit/GTOdbObject.h index 4d9dc5df5..e90659aef 100644 --- a/ObjectiveGit/GTOdbObject.h +++ b/ObjectiveGit/GTOdbObject.h @@ -21,7 +21,7 @@ /// repository - The repository in which the object resides. Cannot be nil. /// /// Returns the initialized object. -- (id)initWithOdbObj:(git_odb_object *)object repository:(GTRepository *)repository; +- (id)initWithOdbObj:(git_odb_object *)object repository:(GTRepository *)repository NS_DESIGNATED_INITIALIZER; /// The underlying `git_odb_object`. - (git_odb_object *)git_odb_object __attribute__((objc_returns_inner_pointer)); diff --git a/ObjectiveGit/GTReference.h b/ObjectiveGit/GTReference.h index c97d7f96a..9eac90037 100644 --- a/ObjectiveGit/GTReference.h +++ b/ObjectiveGit/GTReference.h @@ -65,7 +65,7 @@ typedef NS_OPTIONS(NSInteger, GTReferenceType) { + (id)referenceByResolvingSymbolicReference:(GTReference *)symbolicRef error:(NSError **)error; - (id)initByResolvingSymbolicReference:(GTReference *)symbolicRef error:(NSError **)error; -- (id)initWithGitReference:(git_reference *)ref repository:(GTRepository *)repository; +- (id)initWithGitReference:(git_reference *)ref repository:(GTRepository *)repository NS_DESIGNATED_INITIALIZER; /// The underlying `git_reference` object. - (git_reference *)git_reference __attribute__((objc_returns_inner_pointer)); diff --git a/ObjectiveGit/GTReflog+Private.h b/ObjectiveGit/GTReflog+Private.h index 7cf11f298..e499621c6 100644 --- a/ObjectiveGit/GTReflog+Private.h +++ b/ObjectiveGit/GTReflog+Private.h @@ -17,6 +17,6 @@ /// reference - The reference whose reflog is being represented. Cannot be nil. /// /// Returns the initialized object. -- (id)initWithReference:(GTReference *)reference; +- (id)initWithReference:(GTReference *)reference NS_DESIGNATED_INITIALIZER; @end diff --git a/ObjectiveGit/GTReflogEntry+Private.h b/ObjectiveGit/GTReflogEntry+Private.h index 5582fd272..90d622d32 100644 --- a/ObjectiveGit/GTReflogEntry+Private.h +++ b/ObjectiveGit/GTReflogEntry+Private.h @@ -17,6 +17,6 @@ /// reflog - The reflog in which the entry resides. Cannot be nil. /// /// Returns the initialized object. -- (id)initWithGitReflogEntry:(const git_reflog_entry *)entry reflog:(GTReflog *)reflog; +- (id)initWithGitReflogEntry:(const git_reflog_entry *)entry reflog:(GTReflog *)reflog NS_DESIGNATED_INITIALIZER; @end diff --git a/ObjectiveGit/GTRemote.h b/ObjectiveGit/GTRemote.h index 3e0d57aa8..d686670fa 100644 --- a/ObjectiveGit/GTRemote.h +++ b/ObjectiveGit/GTRemote.h @@ -88,7 +88,7 @@ typedef enum { /// /// remote - The underlying `git_remote` object. Cannot be nil. /// repo - The repository the remote belongs to. Cannot be nil. -- (instancetype)initWithGitRemote:(git_remote *)remote inRepository:(GTRepository *)repo; +- (instancetype)initWithGitRemote:(git_remote *)remote inRepository:(GTRepository *)repo NS_DESIGNATED_INITIALIZER; /// The underlying `git_remote` object. - (git_remote *)git_remote __attribute__((objc_returns_inner_pointer)); diff --git a/ObjectiveGit/GTRepository.h b/ObjectiveGit/GTRepository.h index 950406491..bfc708629 100644 --- a/ObjectiveGit/GTRepository.h +++ b/ObjectiveGit/GTRepository.h @@ -187,7 +187,7 @@ extern NSString * const GTRepositoryInitOptionsOriginURLString; /// after this method is invoked. This must not be nil. /// /// Returns an initialized GTRepository. -- (id)initWithGitRepository:(git_repository *)repository; +- (id)initWithGitRepository:(git_repository *)repository NS_DESIGNATED_INITIALIZER; /// The underlying `git_repository` object. - (git_repository *)git_repository __attribute__((objc_returns_inner_pointer)); diff --git a/ObjectiveGit/GTStatusDelta.h b/ObjectiveGit/GTStatusDelta.h index 7717f2426..8c699a387 100644 --- a/ObjectiveGit/GTStatusDelta.h +++ b/ObjectiveGit/GTStatusDelta.h @@ -46,6 +46,6 @@ typedef NS_ENUM(NSInteger, GTStatusDeltaStatus) { @property (nonatomic, readonly) double similarity; /// Designated initializer. -- (instancetype)initWithGitDiffDelta:(const git_diff_delta *)delta; +- (instancetype)initWithGitDiffDelta:(const git_diff_delta *)delta NS_DESIGNATED_INITIALIZER; @end diff --git a/ObjectiveGit/GTSubmodule.h b/ObjectiveGit/GTSubmodule.h index 5e0103cd3..384e7b4d3 100644 --- a/ObjectiveGit/GTSubmodule.h +++ b/ObjectiveGit/GTSubmodule.h @@ -97,7 +97,7 @@ typedef NS_OPTIONS(NSInteger, GTSubmoduleStatus) { /// nil. /// /// Returns an initialized GTSubmodule, or nil if an error occurs. -- (id)initWithGitSubmodule:(git_submodule *)submodule parentRepository:(GTRepository *)repository; +- (id)initWithGitSubmodule:(git_submodule *)submodule parentRepository:(GTRepository *)repository NS_DESIGNATED_INITIALIZER; /// The underlying `git_submodule` object. - (git_submodule *)git_submodule __attribute__((objc_returns_inner_pointer)); diff --git a/ObjectiveGit/GTTreeBuilder.h b/ObjectiveGit/GTTreeBuilder.h index 424de5ef1..e85f84059 100644 --- a/ObjectiveGit/GTTreeBuilder.h +++ b/ObjectiveGit/GTTreeBuilder.h @@ -59,7 +59,7 @@ typedef NS_ENUM(NSInteger, GTFileMode) { /// error - The error if one occurred. /// /// Returns the initialized object, or nil if an error occurred. -- (id)initWithTree:(GTTree *)treeOrNil repository:(GTRepository *)repository error:(NSError **)error; +- (id)initWithTree:(GTTree *)treeOrNil repository:(GTRepository *)repository error:(NSError **)error NS_DESIGNATED_INITIALIZER; /// The underlying `git_treebuilder` object. - (git_treebuilder *)git_treebuilder __attribute__((objc_returns_inner_pointer)); From cb5998978a638c46f9e09b92968414ba3a2d7ee2 Mon Sep 17 00:00:00 2001 From: Ben Chatelain Date: Fri, 20 Mar 2015 19:08:23 -0700 Subject: [PATCH 2/2] NS_DESIGNATED_INITIALIZER for GTDiff* too --- ObjectiveGit/GTDiff.h | 2 +- ObjectiveGit/GTDiffDelta.m | 2 +- ObjectiveGit/GTDiffFile.h | 2 +- ObjectiveGit/GTDiffHunk.h | 2 +- ObjectiveGit/GTDiffLine.h | 2 +- ObjectiveGit/GTDiffPatch.h | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/ObjectiveGit/GTDiff.h b/ObjectiveGit/GTDiff.h index f5ce14f47..70c912d3d 100644 --- a/ObjectiveGit/GTDiff.h +++ b/ObjectiveGit/GTDiff.h @@ -263,7 +263,7 @@ typedef NS_OPTIONS(NSInteger, GTDiffFindOptionsFlags) { /// repository - The repository in which the diff lives. Cannot be nil. /// /// Returns the initialized object. -- (instancetype)initWithGitDiff:(git_diff *)diff repository:(GTRepository *)repository; +- (instancetype)initWithGitDiff:(git_diff *)diff repository:(GTRepository *)repository NS_DESIGNATED_INITIALIZER; /// The libgit2 diff object. - (git_diff *)git_diff __attribute__((objc_returns_inner_pointer)); diff --git a/ObjectiveGit/GTDiffDelta.m b/ObjectiveGit/GTDiffDelta.m index b1f374bf7..4c6bbc3bd 100644 --- a/ObjectiveGit/GTDiffDelta.m +++ b/ObjectiveGit/GTDiffDelta.m @@ -32,7 +32,7 @@ @interface GTDiffDelta () /// the given diff delta. Must not be nil. /// /// This is the designated initializer for this class. -- (instancetype)initWithGitDiffDeltaBlock:(git_diff_delta (^)(void))deltaAccessor patchGeneratorBlock:(int (^)(git_patch **patch))patchGenerator; +- (instancetype)initWithGitDiffDeltaBlock:(git_diff_delta (^)(void))deltaAccessor patchGeneratorBlock:(int (^)(git_patch **patch))patchGenerator NS_DESIGNATED_INITIALIZER; @end diff --git a/ObjectiveGit/GTDiffFile.h b/ObjectiveGit/GTDiffFile.h index a89904d45..1351feb08 100644 --- a/ObjectiveGit/GTDiffFile.h +++ b/ObjectiveGit/GTDiffFile.h @@ -51,6 +51,6 @@ typedef NS_OPTIONS(NSInteger, GTDiffFileFlag) { /// file - The git_diff_file wrapped by the receiver. /// /// Returns an initialized GTDiffFile. -- (instancetype)initWithGitDiffFile:(git_diff_file)file; +- (instancetype)initWithGitDiffFile:(git_diff_file)file NS_DESIGNATED_INITIALIZER; @end diff --git a/ObjectiveGit/GTDiffHunk.h b/ObjectiveGit/GTDiffHunk.h index feb4d2915..03361344d 100644 --- a/ObjectiveGit/GTDiffHunk.h +++ b/ObjectiveGit/GTDiffHunk.h @@ -24,7 +24,7 @@ /// /// The contents of a hunk are lazily loaded, therefore we initialise the object /// simply with the patch it originates from and which hunk index it represents. -- (instancetype)initWithPatch:(GTDiffPatch *)patch hunkIndex:(NSUInteger)hunkIndex; +- (instancetype)initWithPatch:(GTDiffPatch *)patch hunkIndex:(NSUInteger)hunkIndex NS_DESIGNATED_INITIALIZER; /// Perfoms the given block on each line in the hunk. /// diff --git a/ObjectiveGit/GTDiffLine.h b/ObjectiveGit/GTDiffLine.h index eaf2dcee8..7996bdee4 100644 --- a/ObjectiveGit/GTDiffLine.h +++ b/ObjectiveGit/GTDiffLine.h @@ -44,6 +44,6 @@ typedef NS_ENUM(char, GTDiffLineOrigin) { @property (nonatomic, readonly) NSInteger lineCount; /// Designated initialiser. -- (instancetype)initWithGitLine:(const git_diff_line *)line; +- (instancetype)initWithGitLine:(const git_diff_line *)line NS_DESIGNATED_INITIALIZER; @end diff --git a/ObjectiveGit/GTDiffPatch.h b/ObjectiveGit/GTDiffPatch.h index 3a27bf218..5fff1139e 100644 --- a/ObjectiveGit/GTDiffPatch.h +++ b/ObjectiveGit/GTDiffPatch.h @@ -36,7 +36,7 @@ /// automatically be freed when the receiver is deallocated. Must not be /// NULL. /// delta - The diff delta corresponding to this patch. Must not be nil. -- (instancetype)initWithGitPatch:(git_patch *)patch delta:(GTDiffDelta *)delta; +- (instancetype)initWithGitPatch:(git_patch *)patch delta:(GTDiffDelta *)delta NS_DESIGNATED_INITIALIZER; /// Returns the underlying patch object. - (git_patch *)git_patch __attribute__((objc_returns_inner_pointer));