-
Notifications
You must be signed in to change notification settings - Fork 281
/
Copy pathGTFilterSource.m
51 lines (38 loc) · 1.13 KB
/
GTFilterSource.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
//
// GTFilterSource.m
// ObjectiveGitFramework
//
// Created by Josh Abernathy on 2/14/14.
// Copyright (c) 2014 GitHub, Inc. All rights reserved.
//
#import "GTFilterSource.h"
#import "GTRepository.h"
#import "GTOID.h"
#import "git2/repository.h"
@implementation GTFilterSource
#pragma mark Lifecycle
- (instancetype)init {
NSAssert(NO, @"Call to an unavailable initializer.");
return nil;
}
- (instancetype)initWithGitFilterSource:(const git_filter_source *)source {
NSParameterAssert(source != NULL);
self = [super init];
if (self == nil) return nil;
NSString *path = @(git_repository_workdir(git_filter_source_repo(source)));
NSAssert(path, @"workdir was nil");
_repositoryURL = [NSURL fileURLWithPath:path];
path = @(git_filter_source_path(source));
NSAssert(path, @"path was nil");
_path = path;
const git_oid *gitOid = git_filter_source_id(source);
if (gitOid != NULL) _OID = [[GTOID alloc] initWithGitOid:gitOid];
git_filter_mode_t mode = git_filter_source_mode(source);
if (mode == GIT_FILTER_TO_WORKTREE) {
_mode = GTFilterSourceModeSmudge;
} else {
_mode = GTFilterSourceModeClean;
}
return self;
}
@end