Skip to content

Commit c179bbc

Browse files
committed
Rename -fileURL to -workingDirectoryURL
The rationale is that it's clearer, because worktrees muddy the water quite a bit.
1 parent c294035 commit c179bbc

14 files changed

+44
-37
lines changed

ObjectiveGit/GTFilterList.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ - (NSData *)applyToPath:(NSString *)relativePath inRepository:(GTRepository *)re
7373
// fixme: This is a workaround for an issue where `git_filter_list_apply_to_file`
7474
// will not resolve relative paths against the worktree. It should be reverted when
7575
// libgit2 has been updated to resolve that.
76-
NSString *absolutePath = relativePath.absolutePath ? relativePath : [repository.fileURL URLByAppendingPathComponent:relativePath].path;
76+
NSString *absolutePath = relativePath.absolutePath ? relativePath : [repository.workingDirectoryURL URLByAppendingPathComponent:relativePath].path;
7777
int gitError = git_filter_list_apply_to_file(&output, self.git_filter_list, repository.git_repository, absolutePath.UTF8String);
7878

7979
if (gitError != GIT_OK) {

ObjectiveGit/GTRepository.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,9 +152,12 @@ typedef NS_ENUM(NSInteger, GTRepositoryStateType) {
152152

153153
@interface GTRepository : NSObject
154154

155-
/// The file URL for the repository's working directory.
155+
/// The URL for the repository's working directory.
156156
/// Returns nil for a bare repository.
157-
@property (nonatomic, readonly, strong) NSURL * _Nullable fileURL;
157+
@property (nonatomic, readonly, strong) NSURL * _Nullable workingDirectoryURL;
158+
159+
@property (nonatomic, readonly, strong) NSURL * _Nullable fileURL DEPRECATED_MSG_ATTRIBUTE("use -workingDirectoryURL");
160+
158161
/// The file URL for the repository's .git directory.
159162
@property (nonatomic, readonly, strong) NSURL * _Nullable gitDirectoryURL;
160163

ObjectiveGit/GTRepository.m

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ - (NSString *)description {
9999
if (self.isBare) {
100100
return [NSString stringWithFormat:@"<%@: %p> (bare) gitDirectoryURL: %@", self.class, self, self.gitDirectoryURL];
101101
}
102-
return [NSString stringWithFormat:@"<%@: %p> fileURL: %@", self.class, self, self.fileURL];
102+
return [NSString stringWithFormat:@"<%@: %p> fileURL: %@", self.class, self, self.workingDirectoryURL];
103103
}
104104

105105
- (BOOL)isEqual:(GTRepository *)repo {
@@ -633,6 +633,10 @@ - (NSArray *)referenceNamesWithError:(NSError **)error {
633633
}
634634

635635
- (NSURL *)fileURL {
636+
return self.workingDirectoryURL;
637+
}
638+
639+
- (NSURL *)workingDirectoryURL {
636640
const char *path = git_repository_workdir(self.git_repository);
637641
// bare repository, you may be looking for gitDirectoryURL
638642
if (path == NULL) return nil;

ObjectiveGitTests/GTBlobSpec.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@
7575
it(@"works with valid parameters", ^{
7676
NSString *fileContent = @"Test contents\n";
7777
NSString *fileName = @"myfile.txt";
78-
NSURL *fileURL = [repository.fileURL URLByAppendingPathComponent:fileName];
78+
NSURL *fileURL = [repository.workingDirectoryURL URLByAppendingPathComponent:fileName];
7979

8080
NSError *error = nil;
8181
BOOL success = [fileContent writeToURL:fileURL atomically:YES encoding:NSUTF8StringEncoding error:&error];

ObjectiveGitTests/GTFilterListSpec.m

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
repository = self.testAppFixtureRepository;
2727

2828
NSString *attributes = @"READ* rf=true\n*.txt tf=true\n";
29-
BOOL success = [attributes writeToURL:[repository.fileURL URLByAppendingPathComponent:@".gitattributes"] atomically:YES encoding:NSUTF8StringEncoding error:NULL];
29+
BOOL success = [attributes writeToURL:[repository.workingDirectoryURL URLByAppendingPathComponent:@".gitattributes"] atomically:YES encoding:NSUTF8StringEncoding error:NULL];
3030
expect(@(success)).to(beTruthy());
3131

3232
readFilter = [[GTFilter alloc] initWithName:@"read-filter" attributes:@"rf=true" applyBlock:^(void **payload, NSData *from, GTFilterSource *source, BOOL *applied) {
@@ -146,7 +146,7 @@
146146
NSString *inputFilename = @"README";
147147
GTRepository *inputRepo = self.conflictedFixtureRepository;
148148

149-
NSString *content = [NSString stringWithContentsOfURL:[inputRepo.fileURL URLByAppendingPathComponent:inputFilename] encoding:NSUTF8StringEncoding error:NULL];
149+
NSString *content = [NSString stringWithContentsOfURL:[inputRepo.workingDirectoryURL URLByAppendingPathComponent:inputFilename] encoding:NSUTF8StringEncoding error:NULL];
150150
expect(content).notTo(contain(readFilterContent));
151151
expect(content).notTo(contain(textFilterContent));
152152

ObjectiveGitTests/GTFilterSpec.m

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,10 @@
3232
expect(repository).notTo(beNil());
3333

3434
NSString *attributes = @"*.txt special\n";
35-
BOOL success = [attributes writeToURL:[repository.fileURL URLByAppendingPathComponent:@".gitattributes"] atomically:YES encoding:NSUTF8StringEncoding error:NULL];
35+
BOOL success = [attributes writeToURL:[repository.workingDirectoryURL URLByAppendingPathComponent:@".gitattributes"] atomically:YES encoding:NSUTF8StringEncoding error:NULL];
3636
expect(@(success)).to(beTruthy());
3737

38-
success = [@"some stuff" writeToURL:[repository.fileURL URLByAppendingPathComponent:testFile] atomically:YES encoding:NSUTF8StringEncoding error:NULL];
38+
success = [@"some stuff" writeToURL:[repository.workingDirectoryURL URLByAppendingPathComponent:testFile] atomically:YES encoding:NSUTF8StringEncoding error:NULL];
3939
expect(@(success)).to(beTruthy());
4040

4141
setUpFilterWithApplyBlock = ^(GTFilterApplyBlock applyBlock) {
@@ -155,7 +155,7 @@
155155
return replacementData;
156156
});
157157

158-
NSURL *testFileURL = [repository.fileURL URLByAppendingPathComponent:testFile];
158+
NSURL *testFileURL = [repository.workingDirectoryURL URLByAppendingPathComponent:testFile];
159159
BOOL success = [NSFileManager.defaultManager removeItemAtURL:testFileURL error:NULL];
160160
expect(@(success)).to(beTruthy());
161161

ObjectiveGitTests/GTIndexSpec.m

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@
142142
NSString *fileName = @"REAME_";
143143
beforeEach(^{
144144
index = [self.testAppFixtureRepository indexWithError:NULL];
145-
NSString *filePath = [self.testAppFixtureRepository.fileURL.path stringByAppendingPathComponent:fileName];
145+
NSString *filePath = [self.testAppFixtureRepository.workingDirectoryURL.path stringByAppendingPathComponent:fileName];
146146
[@"The wild west..." writeToFile:filePath atomically:NO encoding:NSUTF8StringEncoding error:NULL];
147147

148148
expect(index).notTo(beNil());
@@ -175,7 +175,7 @@
175175

176176
it(@"should stop be able to stop early", ^{
177177
NSString *otherFileName = @"TestAppDelegate.h";
178-
[@"WELP" writeToFile:[self.testAppFixtureRepository.fileURL.path stringByAppendingPathComponent:otherFileName] atomically:NO encoding:NSUTF8StringEncoding error:NULL];
178+
[@"WELP" writeToFile:[self.testAppFixtureRepository.workingDirectoryURL.path stringByAppendingPathComponent:otherFileName] atomically:NO encoding:NSUTF8StringEncoding error:NULL];
179179
BOOL success = [index updatePathspecs:NULL error:NULL passingTest:^(NSString *matchedPathspec, NSString *path, BOOL *stop) {
180180
if ([path.lastPathComponent isEqualToString:fileName]) {
181181
*stop = YES;
@@ -220,10 +220,10 @@
220220

221221
index = [repo indexWithError:NULL];
222222

223-
NSString *path = [repo.fileURL.path stringByAppendingPathComponent:filename];
223+
NSString *path = [repo.workingDirectoryURL.path stringByAppendingPathComponent:filename];
224224
fileURL = [NSURL fileURLWithPath:path isDirectory:NO];
225225

226-
NSString *newPath = [repo.fileURL.path stringByAppendingPathComponent:renamedFilename];
226+
NSString *newPath = [repo.workingDirectoryURL.path stringByAppendingPathComponent:renamedFilename];
227227
renamedFileURL = [NSURL fileURLWithPath:newPath isDirectory:NO];
228228
});
229229

ObjectiveGitTests/GTRepository+PullSpec.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@
254254
BOOL result = [localRepo pullBranch:masterBranch fromRemote:remote withOptions:nil error:&error progress:^(const git_transfer_progress *progress, BOOL *stop) {
255255
transferProgressed = YES;
256256
}];
257-
NSString *fileContents = [NSString stringWithContentsOfURL:[localRepo.fileURL URLByAppendingPathComponent:@"test.txt"] encoding:NSUTF8StringEncoding error:nil];
257+
NSString *fileContents = [NSString stringWithContentsOfURL:[localRepo.workingDirectoryURL URLByAppendingPathComponent:@"test.txt"] encoding:NSUTF8StringEncoding error:nil];
258258
expect(@(result)).to(beFalsy());
259259
expect(error.domain).to(equal(@"GTGitErrorDomain"));
260260
expect(error.userInfo[GTPullMergeConflictedFiles]).to(equal(@[@"test.txt"]));

ObjectiveGitTests/GTRepository+StatusSpec.m

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323

2424
beforeEach(^{
2525
repository = self.testAppFixtureRepository;
26-
targetFileURL = [repository.fileURL URLByAppendingPathComponent:@"main.m"];
26+
targetFileURL = [repository.workingDirectoryURL URLByAppendingPathComponent:@"main.m"];
2727
expect(repository).notTo(beNil());
2828
});
2929

@@ -73,7 +73,7 @@
7373
});
7474

7575
it(@"should recognize copied files", ^{
76-
NSURL *copyLocation = [repository.fileURL URLByAppendingPathComponent:@"main2.m"];
76+
NSURL *copyLocation = [repository.workingDirectoryURL URLByAppendingPathComponent:@"main2.m"];
7777
expect(@([NSFileManager.defaultManager copyItemAtURL:targetFileURL toURL:copyLocation error:&err])).to(beTruthy());
7878
expect(err).to(beNil());
7979
updateIndexForSubpathAndExpectStatus(copyLocation.lastPathComponent, GTDeltaTypeCopied);
@@ -86,7 +86,7 @@
8686
});
8787

8888
it(@"should recognize renamed files", ^{
89-
NSURL *moveLocation = [repository.fileURL URLByAppendingPathComponent:@"main-moved.m"];
89+
NSURL *moveLocation = [repository.workingDirectoryURL URLByAppendingPathComponent:@"main-moved.m"];
9090
expect(@([NSFileManager.defaultManager moveItemAtURL:targetFileURL toURL:moveLocation error:&err])).to(beTruthy());
9191
expect(err).to(beNil());
9292
expectSubpathToHaveWorkDirStatus(moveLocation.lastPathComponent, GTDeltaTypeRenamed);
@@ -108,7 +108,7 @@
108108

109109
it(@"should report file should be ignored", ^{
110110
__block NSError *err = nil;
111-
NSURL *fileURL = [repository.fileURL URLByAppendingPathComponent:@".DS_Store"];
111+
NSURL *fileURL = [repository.workingDirectoryURL URLByAppendingPathComponent:@".DS_Store"];
112112
BOOL success = NO;
113113
BOOL shouldIgnore = [repository shouldFileBeIgnored:fileURL success:&success error:&err];
114114
expect(@(success)).to(beTrue());
@@ -118,7 +118,7 @@
118118

119119
it(@"should report file should be ignored (convenience wrapper)", ^{
120120
__block NSError *err = nil;
121-
NSURL *fileURL = [repository.fileURL URLByAppendingPathComponent:@".DS_Store"];
121+
NSURL *fileURL = [repository.workingDirectoryURL URLByAppendingPathComponent:@".DS_Store"];
122122
GTFileIgnoreState ignore = [repository shouldIgnoreFileURL:fileURL error:&err];
123123
expect(@(ignore)).to(equal(@(GTFileIgnoreStateShouldIgnore)));
124124
expect(err).to(beNil());

ObjectiveGitTests/GTRepositoryAttributesSpec.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222

2323
it(@"should be able to look up attributes", ^{
2424
static NSString * const testAttributes = @"*.txt filter=reverse";
25-
NSURL *attributesURL = [repository.fileURL URLByAppendingPathComponent:@".gitattributes"];
25+
NSURL *attributesURL = [repository.workingDirectoryURL URLByAppendingPathComponent:@".gitattributes"];
2626
BOOL success = [testAttributes writeToURL:attributesURL atomically:YES encoding:NSUTF8StringEncoding error:NULL];
2727
expect(@(success)).to(beTruthy());
2828

0 commit comments

Comments
 (0)