Skip to content

Commit 73037a4

Browse files
committed
Style fixes per @tiennou feedback
1 parent c27e838 commit 73037a4

File tree

5 files changed

+30
-24
lines changed

5 files changed

+30
-24
lines changed

ObjectiveGit/GTNote.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ NS_ASSUME_NONNULL_BEGIN
8585
/// May be NULL.
8686
///
8787
/// Returns default reference name (usually "refs/notes/commits").
88-
+ (NSString*)defaultReferenceNameForRepository:(GTRepository *)repository error:(NSError **)error;
88+
+ (NSString *)defaultReferenceNameForRepository:(GTRepository *)repository error:(NSError **)error;
8989

9090
@end
9191

ObjectiveGit/GTNote.m

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ - (git_note *)git_note {
4141
return _note;
4242
}
4343

44-
- (NSString*)note {
44+
- (NSString *)note {
4545
return @(git_note_message(self.git_note));
4646
}
4747

@@ -53,7 +53,7 @@ - (GTSignature *)committer {
5353
return [[GTSignature alloc] initWithGitSignature:git_note_committer(self.git_note)];
5454
}
5555

56-
- (GTOID*)targetOID {
56+
- (GTOID *)targetOID {
5757
return [GTOID oidWithGitOid:git_note_id(self.git_note)];
5858
}
5959

@@ -89,8 +89,8 @@ - (instancetype)init {
8989
return nil;
9090
}
9191

92-
+ (NSString*)defaultReferenceNameForRepository:(GTRepository *)repository error:(NSError **)error {
93-
NSString* noteRef = nil;
92+
+ (NSString *)defaultReferenceNameForRepository:(GTRepository *)repository error:(NSError **)error {
93+
NSString *noteRef = nil;
9494

9595
git_buf default_ref_name = { 0 };
9696
int gitErr = git_note_default_ref(&default_ref_name, repository.git_repository);
@@ -104,7 +104,13 @@ + (NSString*)defaultReferenceNameForRepository:(GTRepository *)repository error:
104104
return nil;
105105
}
106106

107-
noteRef = [NSString stringWithUTF8String:default_ref_name.ptr];
107+
if (default_ref_name.ptr != NULL) {
108+
noteRef = @(default_ref_name.ptr);
109+
} else {
110+
if (error != NULL) {
111+
*error = [NSError git_errorFor:GIT_ERROR description:@"Unable to get default git notes reference name"];
112+
}
113+
}
108114

109115
git_buf_free(&default_ref_name);
110116

ObjectiveGit/GTRepository+RemoteOperations.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ typedef NS_ENUM(NSInteger, GTFetchPruneOption) {
115115
///
116116
/// Returns YES if the push was successful, NO otherwise (and `error`, if provided,
117117
/// will point to an error describing what happened).
118-
- (BOOL)pushBranches:(NSArray<GTBranch *> *)branches toRemote:(GTRemote *)remote withOptions:(nullable NSDictionary *)options withNotesReferenceName:(nullable NSString*)notesReferenceName error:(NSError **)error progress:(nullable void (^)(unsigned int current, unsigned int total, size_t bytes, BOOL *stop))progressBlock;
118+
- (BOOL)pushBranches:(NSArray<GTBranch *> *)branches toRemote:(GTRemote *)remote withOptions:(nullable NSDictionary *)options withNotesReferenceName:(nullable NSString *)notesReferenceName error:(NSError **)error progress:(nullable void (^)(unsigned int current, unsigned int total, size_t bytes, BOOL *stop))progressBlock;
119119

120120
/// Push a given Git notes reference name to a remote.
121121
///

ObjectiveGit/GTRepository+RemoteOperations.m

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -178,56 +178,56 @@ - (BOOL)pushBranches:(NSArray *)branches toRemote:(GTRemote *)remote withOptions
178178
return [self pushBranches:branches toRemote:remote withOptions:options withNotesReferenceName:nil error:error progress:progressBlock];
179179
}
180180

181-
- (BOOL)pushBranches:(NSArray *)branches toRemote:(GTRemote *)remote withOptions:(NSDictionary *)options withNotesReferenceName:(NSString*)referenceName error:(NSError **)error progress:(GTRemotePushTransferProgressBlock)progressBlock {
181+
- (BOOL)pushBranches:(NSArray *)branches toRemote:(GTRemote *)remote withOptions:(NSDictionary *)options withNotesReferenceName:(NSString *)referenceName error:(NSError **)error progress:(GTRemotePushTransferProgressBlock)progressBlock {
182182
NSParameterAssert(branches != nil);
183183
NSParameterAssert(branches.count != 0);
184184
NSParameterAssert(remote != nil);
185-
185+
186186
NSMutableArray *refspecs = nil;
187187
// Build refspecs for the passed in branches
188188
refspecs = [NSMutableArray arrayWithCapacity:branches.count];
189189
for (GTBranch *branch in branches) {
190190
// Default remote reference for when branch doesn't exist on remote - create with same short name
191191
NSString *remoteBranchReference = [NSString stringWithFormat:@"refs/heads/%@", branch.shortName];
192-
192+
193193
BOOL success = NO;
194194
GTBranch *trackingBranch = [branch trackingBranchWithError:error success:&success];
195-
195+
196196
if (success && trackingBranch != nil) {
197197
// Use remote branch short name from trackingBranch, which could be different
198198
// (e.g. refs/heads/master:refs/heads/my_master)
199199
remoteBranchReference = [NSString stringWithFormat:@"refs/heads/%@", trackingBranch.shortName];
200200
}
201-
201+
202202
[refspecs addObject:[NSString stringWithFormat:@"refs/heads/%@:%@", branch.shortName, remoteBranchReference]];
203203
}
204204

205205
// Also push the notes reference, if needed.
206206
if (referenceName != nil) {
207207
// but check whether the reference exists for the repo, otherwise, our push will fail
208-
GTReference* notesRef = [self lookUpReferenceWithName:referenceName error:nil];
209-
210-
if (notesRef != nil)
208+
GTReference *notesRef = [self lookUpReferenceWithName:referenceName error:nil];
209+
210+
if (notesRef != nil) {
211211
[refspecs addObject:[NSString stringWithFormat:@"%@:%@", referenceName, referenceName]];
212+
}
212213
}
213214

214215
return [self pushRefspecs:refspecs toRemote:remote withOptions:options error:error progress:progressBlock];
215216
}
216217

217218
- (BOOL)pushNotes:(NSString *)noteRef toRemote:(GTRemote *)remote withOptions:(NSDictionary *)options error:(NSError **)error progress:(GTRemotePushTransferProgressBlock)progressBlock {
218219
NSParameterAssert(remote != nil);
219-
220+
220221
if (noteRef == nil) {
221222
noteRef = [GTNote defaultReferenceNameForRepository:self error:error];
222223

223224
if (noteRef == nil) return NO;
224225
}
225-
226-
GTReference* notesReference = [self lookUpReferenceWithName:noteRef error:error];
227-
228-
if (notesReference == nil)
229-
return NO; // error will be pre-filled with the lookUpReferenceWithName call
230-
226+
227+
GTReference *notesReference = [self lookUpReferenceWithName:noteRef error:error];
228+
229+
if (notesReference == nil) return NO;
230+
231231
return [self pushRefspecs:@[[NSString stringWithFormat:@"%@:%@", noteRef, noteRef]] toRemote:remote withOptions:options error:error progress:progressBlock];
232232
}
233233

ObjectiveGit/GTRepository.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -621,7 +621,7 @@ typedef NS_ENUM(NSInteger, GTRepositoryStateType) {
621621
/// Returns the newly created note or nil on error.
622622
- (nullable GTNote *)createNote:(NSString *)note target:(GTObject *)theTarget referenceName:(nullable NSString *)referenceName author:(GTSignature *)author committer:(GTSignature *)committer overwriteIfExists:(BOOL)overwrite error:(NSError **)error;
623623

624-
/// Removes a note attached to object in this repo (using a default notes reference, e.g. "refs/notes/commits")
624+
/// Removes a note attached to object in this repo
625625
///
626626
/// parentObject - Object (usually a commit) to which the note to be removed is attached to.
627627
/// This object must belong to this repository.
@@ -635,7 +635,7 @@ typedef NS_ENUM(NSInteger, GTRepositoryStateType) {
635635
/// Returns the YES on success and NO on error.
636636
- (BOOL)removeNoteFromObject:(GTObject *)parentObject referenceName:(nullable NSString *)referenceName author:(GTSignature *)author committer:(GTSignature *)committer error:(NSError **)error;
637637

638-
/// Enumerates through all stored notes in this repo (using a default notes reference, e.g. "refs/notes/commits")
638+
/// Enumerates through all stored notes in this repo
639639
///
640640
/// referenceName - Name for the notes reference in the repo, or nil for default ("refs/notes/commits")
641641
/// error - Will be filled with a NSError object in case of error.

0 commit comments

Comments
 (0)