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

DRY delta types #581

Merged
merged 2 commits into from
Aug 4, 2016
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
2 changes: 1 addition & 1 deletion ObjectiveGit/GTDiff.h
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ typedef NS_OPTIONS(NSInteger, GTDiffFindOptionsFlags) {
- (git_diff *)git_diff __attribute__((objc_returns_inner_pointer));

/// The number of deltas of the given type that are contained in the diff.
- (NSUInteger)numberOfDeltasWithType:(GTDiffDeltaType)deltaType;
- (NSUInteger)numberOfDeltasWithType:(GTDeltaType)deltaType;

/// Enumerate the deltas in a diff.
///
Expand Down
2 changes: 1 addition & 1 deletion ObjectiveGit/GTDiff.m
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ - (NSUInteger)deltaCount {
return git_diff_num_deltas(self.git_diff);
}

- (NSUInteger)numberOfDeltasWithType:(GTDiffDeltaType)deltaType {
- (NSUInteger)numberOfDeltasWithType:(GTDeltaType)deltaType {
return git_diff_num_deltas_of_type(self.git_diff, (git_delta_t)deltaType);
}

Expand Down
47 changes: 26 additions & 21 deletions ObjectiveGit/GTDiffDelta.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,35 +17,38 @@

/// The type of change that this delta represents.
///
/// GTDiffFileDeltaUnmodified - No Change.
/// GTDiffFileDeltaAdded - The file was added to the index.
/// GTDiffFileDeltaDeleted - The file was removed from the working directory.
/// GTDiffFileDeltaModified - The file was modified.
/// GTDiffFileDeltaRenamed - The file has been renamed.
/// GTDiffFileDeltaCopied - The file was duplicated.
/// GTDiffFileDeltaIgnored - The file was ignored by git.
/// GTDiffFileDeltaUntracked - The file has been added to the working directory
/// GTDeltaTypeUnmodified - No Change.
/// GTDeltaTypeAdded - The file was added to the index.
/// GTDeltaTypeDeleted - The file was removed from the working directory.
/// GTDeltaTypeModified - The file was modified.
/// GTDeltaTypeRenamed - The file has been renamed.
/// GTDeltaTypeCopied - The file was duplicated.
/// GTDeltaTypeIgnored - The file was ignored by git.
/// GTDeltaTypeUntracked - The file has been added to the working directory
/// and is therefore currently untracked.
/// GTDiffFileDeltaTypeChange - The file has changed from a blob to either a
/// GTDeltaTypeTypeChange - The file has changed from a blob to either a
/// submodule, symlink or directory. Or vice versa.
typedef NS_ENUM(NSInteger, GTDiffDeltaType) {
GTDiffFileDeltaUnmodified = GIT_DELTA_UNMODIFIED,
GTDiffFileDeltaAdded = GIT_DELTA_ADDED,
GTDiffFileDeltaDeleted = GIT_DELTA_DELETED,
GTDiffFileDeltaModified = GIT_DELTA_MODIFIED,
GTDiffFileDeltaRenamed = GIT_DELTA_RENAMED,
GTDiffFileDeltaCopied = GIT_DELTA_COPIED,
GTDiffFileDeltaIgnored = GIT_DELTA_IGNORED,
GTDiffFileDeltaUntracked = GIT_DELTA_UNTRACKED,
GTDiffFileDeltaTypeChange = GIT_DELTA_TYPECHANGE,
/// GTDeltaTypeConflicted - The file is conflicted in the working directory.
typedef NS_ENUM(NSInteger, GTDeltaType) {
GTDeltaTypeUnmodified = GIT_DELTA_UNMODIFIED,
GTDeltaTypeAdded = GIT_DELTA_ADDED,
GTDeltaTypeDeleted = GIT_DELTA_DELETED,
GTDeltaTypeModified = GIT_DELTA_MODIFIED,
GTDeltaTypeRenamed = GIT_DELTA_RENAMED,
GTDeltaTypeCopied = GIT_DELTA_COPIED,
GTDeltaTypeIgnored = GIT_DELTA_IGNORED,
GTDeltaTypeUntracked = GIT_DELTA_UNTRACKED,
GTDeltaTypeTypeChange = GIT_DELTA_TYPECHANGE,
GTDeltaTypeUnreadable = GIT_DELTA_UNREADABLE,
GTDeltaTypeConflicted = GIT_DELTA_CONFLICTED,
};

NS_ASSUME_NONNULL_BEGIN

/// A class representing a single change within a diff.
///
/// The change may not be simply a change of text within a given file, it could
/// be that the file was renamed, or added to the index. See `GTDiffDeltaType`
/// be that the file was renamed, or added to the index. See `GTDeltaType`
/// for the types of change represented.
@interface GTDiffDelta : NSObject

Expand All @@ -68,7 +71,9 @@ NS_ASSUME_NONNULL_BEGIN
/// The type of change that this delta represents.
///
/// Think "status" as in `git status`.
@property (nonatomic, readonly) GTDiffDeltaType type;
@property (nonatomic, readonly) GTDeltaType type;

@property (nonatomic, readonly, assign) double similarity;

/// Diffs the given blob and data buffer.
///
Expand Down
8 changes: 6 additions & 2 deletions ObjectiveGit/GTDiffDelta.m
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,12 @@ - (GTDiffFile *)newFile {
return [[GTDiffFile alloc] initWithGitDiffFile:self.git_diff_delta.new_file];
}

- (GTDiffDeltaType)type {
return (GTDiffDeltaType)self.git_diff_delta.status;
- (GTDeltaType)type {
return (GTDeltaType)self.git_diff_delta.status;
}

- (double)similarity {
Copy link
Member

Choose a reason for hiding this comment

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

Did this just slip in?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That's 87c6b2a, so no, it's willingly present.

Copy link
Member

Choose a reason for hiding this comment

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

But it's private and unused?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I may or may not have forgotten adding the @property 😟 .

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Rebased with fixup, sorry about that.

return (double)(self.git_diff_delta.similarity / 100.0);
}

#pragma mark Lifecycle
Expand Down
10 changes: 5 additions & 5 deletions ObjectiveGit/GTRepository+Status.m
Original file line number Diff line number Diff line change
Expand Up @@ -68,23 +68,23 @@ - (BOOL)enumerateFileStatusWithOptions:(NSDictionary *)options error:(NSError **
- (BOOL)isWorkingDirectoryClean {
__block BOOL clean = YES;
[self enumerateFileStatusWithOptions:nil error:NULL usingBlock:^(GTStatusDelta *headToIndex, GTStatusDelta *indexToWorkingDirectory, BOOL *stop) {
GTStatusDeltaStatus headToIndexStatus = headToIndex.status;
GTStatusDeltaStatus indexToWorkDirStatus = indexToWorkingDirectory.status;
GTDeltaType headToIndexStatus = headToIndex.status;
GTDeltaType indexToWorkDirStatus = indexToWorkingDirectory.status;

// first, have items been deleted?
if (indexToWorkDirStatus == GTStatusDeltaStatusDeleted || headToIndexStatus == GTStatusDeltaStatusDeleted) {
if (indexToWorkDirStatus == GTDeltaTypeDeleted || headToIndexStatus == GTDeltaTypeDeleted) {
clean = NO;
*stop = YES;
}

// any untracked files?
if (indexToWorkDirStatus == GTStatusDeltaStatusUntracked) {
if (indexToWorkDirStatus == GTDeltaTypeUntracked) {
clean = NO;
*stop = YES;
}

// next, have items been modified?
if (indexToWorkDirStatus == GTStatusDeltaStatusModified || headToIndexStatus == GTStatusDeltaStatusModified) {
if (indexToWorkDirStatus == GTDeltaTypeModified || headToIndexStatus == GTDeltaTypeModified) {
clean = NO;
*stop = YES;
}
Expand Down
18 changes: 2 additions & 16 deletions ObjectiveGit/GTStatusDelta.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,24 +8,10 @@

#import <Foundation/Foundation.h>
#import "git2/diff.h"
#import <ObjectiveGit/GTDiffDelta.h>

@class GTDiffFile;

/// An enum representing the status of the file.
///
/// See diff.h for documentation of individual flags.
typedef NS_ENUM(NSInteger, GTStatusDeltaStatus) {
GTStatusDeltaStatusUnmodified = GIT_DELTA_UNMODIFIED,
GTStatusDeltaStatusAdded = GIT_DELTA_ADDED,
GTStatusDeltaStatusDeleted = GIT_DELTA_DELETED,
GTStatusDeltaStatusModified = GIT_DELTA_MODIFIED,
GTStatusDeltaStatusRenamed = GIT_DELTA_RENAMED,
GTStatusDeltaStatusCopied = GIT_DELTA_COPIED,
GTStatusDeltaStatusIgnored = GIT_DELTA_IGNORED,
GTStatusDeltaStatusUntracked = GIT_DELTA_UNTRACKED,
GTStatusDeltaStatusTypeChange = GIT_DELTA_TYPECHANGE,
};

NS_ASSUME_NONNULL_BEGIN

/// Represents the status of a file in a repository.
Expand All @@ -38,7 +24,7 @@ NS_ASSUME_NONNULL_BEGIN
@property (nonatomic, readonly, copy, nullable) GTDiffFile *newFile __attribute__((ns_returns_not_retained));

/// The status of the file.
@property (nonatomic, readonly) GTStatusDeltaStatus status;
@property (nonatomic, readonly) GTDeltaType status;

/// A float between 0 and 1 describing how similar the old and new
/// files are (where 0 is not at all and 1 is identical).
Expand Down
2 changes: 1 addition & 1 deletion ObjectiveGit/GTStatusDelta.m
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ - (instancetype)initWithGitDiffDelta:(const git_diff_delta *)delta {

_oldFile = [[GTDiffFile alloc] initWithGitDiffFile:delta->old_file];
_newFile = [[GTDiffFile alloc] initWithGitDiffFile:delta->new_file];
_status = (GTStatusDeltaStatus)delta->status;
_status = (GTDeltaType)delta->status;
_similarity = (double)(delta->similarity / 100.0);

return self;
Expand Down
10 changes: 5 additions & 5 deletions ObjectiveGitTests/GTDiffSpec.m
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@
setupDiffFromCommitSHAsAndOptions(@"be0f001ff517a00b5b8e3c29ee6561e70f994e17", @"fe89ea0a8e70961b8a6344d9660c326d3f2eb0fe", nil);

expect(@(diff.deltaCount)).to(equal(@1));
expect(@([diff numberOfDeltasWithType:GTDiffFileDeltaModified])).to(equal(@1));
expect(@([diff numberOfDeltasWithType:GTDeltaTypeModified])).to(equal(@1));

[diff enumerateDeltasUsingBlock:^(GTDiffDelta *delta, BOOL *stop) {
NSError *error = nil;
Expand All @@ -101,7 +101,7 @@
expect(delta.oldFile.path).to(equal(@"TestAppWindowController.h"));
expect(delta.oldFile.path).to(equal(delta.newFile.path));
expect(@(delta.flags & GTDiffFileFlagBinaryMask)).to(equal(@(GTDiffFileFlagNotBinary)));
expect(@(delta.type)).to(equal(@(GTDiffFileDeltaModified)));
expect(@(delta.type)).to(equal(@(GTDeltaTypeModified)));

expect(patch.delta).to(beIdenticalTo(delta));
expect(@(patch.hunkCount)).to(equal(@1));
Expand Down Expand Up @@ -155,7 +155,7 @@
expect(@(diff.deltaCount)).to(equal(@1));
[diff enumerateDeltasUsingBlock:^(GTDiffDelta *delta, BOOL *stop) {
expect(delta.newFile.path).to(equal(@"REAME")); //loltypo
expect(@(delta.type)).to(equal(@(GTDiffFileDeltaAdded)));
expect(@(delta.type)).to(equal(@(GTDeltaTypeAdded)));

*stop = YES;
}];
Expand All @@ -166,7 +166,7 @@

expect(@(diff.deltaCount)).to(equal(@1));
[diff enumerateDeltasUsingBlock:^(GTDiffDelta *delta, BOOL *stop) {
expect(@(delta.type)).to(equal(@(GTDiffFileDeltaDeleted)));
expect(@(delta.type)).to(equal(@(GTDeltaTypeDeleted)));

*stop = YES;
}];
Expand All @@ -193,7 +193,7 @@

expect(@(diff.deltaCount)).to(equal(@1));
[diff enumerateDeltasUsingBlock:^(GTDiffDelta *delta, BOOL *stop) {
expect(@(delta.type)).to(equal(@(GTDiffFileDeltaRenamed)));
expect(@(delta.type)).to(equal(@(GTDeltaTypeRenamed)));
expect(delta.oldFile.path).to(equal(@"README"));
expect(delta.newFile.path).to(equal(@"README_renamed"));

Expand Down
16 changes: 8 additions & 8 deletions ObjectiveGitTests/GTIndexSpec.m
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@

NSDictionary *renamedOptions = @{ GTRepositoryStatusOptionsFlagsKey: @(GTRepositoryStatusFlagsIncludeIgnored | GTRepositoryStatusFlagsIncludeUntracked | GTRepositoryStatusFlagsRecurseUntrackedDirectories | GTRepositoryStatusFlagsRenamesHeadToIndex | GTRepositoryStatusFlagsIncludeUnmodified) };

BOOL (^fileStatusEqualsExpected)(NSString *filename, GTStatusDeltaStatus headToIndexStatus, GTStatusDeltaStatus indexToWorkingDirectoryStatus) = ^(NSString *filename, GTStatusDeltaStatus headToIndexStatus, GTStatusDeltaStatus indexToWorkingDirectoryStatus) {
BOOL (^fileStatusEqualsExpected)(NSString *filename, GTDeltaType headToIndexStatus, GTDeltaType indexToWorkingDirectoryStatus) = ^(NSString *filename, GTDeltaType headToIndexStatus, GTDeltaType indexToWorkingDirectoryStatus) {
return [index.repository enumerateFileStatusWithOptions:renamedOptions error:NULL usingBlock:^(GTStatusDelta *headToIndex, GTStatusDelta *indexToWorkingDirectory, BOOL *stop) {
if (![headToIndex.newFile.path isEqualToString:filename]) return;
expect(@(headToIndex.status)).to(equal(@(headToIndexStatus)));
Expand Down Expand Up @@ -230,32 +230,32 @@
it(@"it preserves decomposed Unicode in index paths with precomposeunicode disabled", ^{
NSString *decomposedFilename = [filename decomposedStringWithCanonicalMapping];
GTIndexEntry *entry = [index entryWithPath:decomposedFilename error:NULL];
expect(@(fileStatusEqualsExpected(entry.path, GTStatusDeltaStatusUnmodified, GTStatusDeltaStatusUnmodified))).to(beTruthy());
expect(@(fileStatusEqualsExpected(entry.path, GTDeltaTypeUnmodified, GTDeltaTypeUnmodified))).to(beTruthy());

expect(@([[NSFileManager defaultManager] moveItemAtURL:fileURL toURL:renamedFileURL error:NULL])).to(beTruthy());

entry = [index entryWithPath:decomposedFilename error:NULL];
expect(@(fileStatusEqualsExpected(entry.path, GTStatusDeltaStatusUnmodified, GTStatusDeltaStatusDeleted))).to(beTruthy());
expect(@(fileStatusEqualsExpected(entry.path, GTDeltaTypeUnmodified, GTDeltaTypeDeleted))).to(beTruthy());

[index removeFile:filename error:NULL];
[index addFile:renamedFilename error:NULL];
[index write:NULL];

entry = [index entryWithPath:[renamedFilename decomposedStringWithCanonicalMapping] error:NULL];
expect(@(fileStatusEqualsExpected(entry.path, GTStatusDeltaStatusRenamed, GTStatusDeltaStatusUnmodified))).to(beTruthy());
expect(@(fileStatusEqualsExpected(entry.path, GTDeltaTypeRenamed, GTDeltaTypeUnmodified))).to(beTruthy());
});

it(@"it preserves precomposed Unicode in index paths with precomposeunicode enabled", ^{
GTIndexEntry *fileEntry = [index entryWithPath:[filename decomposedStringWithCanonicalMapping] error:NULL];
expect(fileEntry).notTo(beNil());
expect(@(fileStatusEqualsExpected(fileEntry.path, GTStatusDeltaStatusUnmodified, GTStatusDeltaStatusUnmodified))).to(beTruthy());
expect(@(fileStatusEqualsExpected(fileEntry.path, GTDeltaTypeUnmodified, GTDeltaTypeUnmodified))).to(beTruthy());

[configuration setBool:true forKey:@"core.precomposeunicode"];
expect(@([configuration boolForKey:@"core.precomposeunicode"])).to(beTruthy());

GTIndexEntry *decomposedFileEntry = [index entryWithPath:[filename decomposedStringWithCanonicalMapping] error:NULL];
expect(decomposedFileEntry).notTo(beNil());
expect(@(fileStatusEqualsExpected(decomposedFileEntry.path, GTStatusDeltaStatusUnmodified, GTStatusDeltaStatusDeleted))).to(beTruthy());
expect(@(fileStatusEqualsExpected(decomposedFileEntry.path, GTDeltaTypeUnmodified, GTDeltaTypeDeleted))).to(beTruthy());

expect(@([[NSFileManager defaultManager] moveItemAtURL:fileURL toURL:renamedFileURL error:NULL])).to(beTruthy());

Expand All @@ -264,15 +264,15 @@

decomposedFileEntry = [index entryWithPath:[filename decomposedStringWithCanonicalMapping] error:NULL];
expect(decomposedFileEntry).notTo(beNil());
expect(@(fileStatusEqualsExpected(decomposedFileEntry.path, GTStatusDeltaStatusUnmodified, GTStatusDeltaStatusDeleted))).to(beTruthy());
expect(@(fileStatusEqualsExpected(decomposedFileEntry.path, GTDeltaTypeUnmodified, GTDeltaTypeDeleted))).to(beTruthy());

[index removeFile:filename error:NULL];
[index addFile:renamedFilename error:NULL];
[index write:NULL];

GTIndexEntry *precomposedRenamedFileEntry = [index entryWithPath:renamedFilename error:NULL];
expect(precomposedRenamedFileEntry).notTo(beNil());
expect(@(fileStatusEqualsExpected(precomposedFileEntry.path, GTStatusDeltaStatusRenamed, GTStatusDeltaStatusUntracked))).to(beTruthy());
expect(@(fileStatusEqualsExpected(precomposedFileEntry.path, GTDeltaTypeRenamed, GTDeltaTypeUntracked))).to(beTruthy());
});
});

Expand Down
22 changes: 11 additions & 11 deletions ObjectiveGitTests/GTRepository+StatusSpec.m
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
expect(repository).notTo(beNil());
});

void (^updateIndexForSubpathAndExpectStatus)(NSString *, GTStatusDeltaStatus) = ^(NSString *subpath, GTStatusDeltaStatus expectedIndexStatus) {
void (^updateIndexForSubpathAndExpectStatus)(NSString *, GTDeltaType) = ^(NSString *subpath, GTDeltaType expectedIndexStatus) {
__block NSError *err = nil;
GTIndex *index = [repository indexWithError:&err];
expect(err).to(beNil());
Expand All @@ -42,7 +42,7 @@
expect(err).to(beNil());
};

void (^expectSubpathToHaveWorkDirStatus)(NSString *, GTStatusDeltaStatus) = ^(NSString *subpath, GTStatusDeltaStatus expectedWorkDirStatus) {
void (^expectSubpathToHaveWorkDirStatus)(NSString *, GTDeltaType) = ^(NSString *subpath, GTDeltaType expectedWorkDirStatus) {
__block NSError *err = nil;
NSDictionary *renamedOptions = @{ GTRepositoryStatusOptionsFlagsKey: @(GTRepositoryStatusFlagsIncludeIgnored | GTRepositoryStatusFlagsIncludeUntracked | GTRepositoryStatusFlagsRecurseUntrackedDirectories | GTRepositoryStatusFlagsRenamesIndexToWorkingDirectory) };
expect(@([repository enumerateFileStatusWithOptions:renamedOptions error:&err usingBlock:^(GTStatusDelta *headToIndex, GTStatusDelta *indexToWorkingDirectory, BOOL *stop) {
Expand All @@ -52,55 +52,55 @@
expect(err).to(beNil());
};

void (^expectSubpathToHaveMatchingStatus)(NSString *, GTStatusDeltaStatus) = ^(NSString *subpath, GTStatusDeltaStatus status) {
void (^expectSubpathToHaveMatchingStatus)(NSString *, GTDeltaType) = ^(NSString *subpath, GTDeltaType status) {
expectSubpathToHaveWorkDirStatus(subpath, status);
updateIndexForSubpathAndExpectStatus(subpath, status);
};

it(@"should recognize untracked files", ^{
expectSubpathToHaveWorkDirStatus(@"UntrackedImage.png", GTStatusDeltaStatusUntracked);
expectSubpathToHaveWorkDirStatus(@"UntrackedImage.png", GTDeltaTypeUntracked);
});

it(@"should recognize added files", ^{
updateIndexForSubpathAndExpectStatus(@"UntrackedImage.png", GTStatusDeltaStatusAdded);
updateIndexForSubpathAndExpectStatus(@"UntrackedImage.png", GTDeltaTypeAdded);
});

it(@"should recognize modified files", ^{
expect(@([NSFileManager.defaultManager removeItemAtURL:targetFileURL error:&err])).to(beTruthy());
expect(err).to(beNil());
expect(@([testData writeToURL:targetFileURL atomically:YES])).to(beTruthy());
expectSubpathToHaveMatchingStatus(targetFileURL.lastPathComponent, GTStatusDeltaStatusModified);
expectSubpathToHaveMatchingStatus(targetFileURL.lastPathComponent, GTDeltaTypeModified);
});

it(@"should recognize copied files", ^{
NSURL *copyLocation = [repository.fileURL URLByAppendingPathComponent:@"main2.m"];
expect(@([NSFileManager.defaultManager copyItemAtURL:targetFileURL toURL:copyLocation error:&err])).to(beTruthy());
expect(err).to(beNil());
updateIndexForSubpathAndExpectStatus(copyLocation.lastPathComponent, GTStatusDeltaStatusCopied);
updateIndexForSubpathAndExpectStatus(copyLocation.lastPathComponent, GTDeltaTypeCopied);
});

it(@"should recognize deleted files", ^{
expect(@([NSFileManager.defaultManager removeItemAtURL:targetFileURL error:&err])).to(beTruthy());
expect(err).to(beNil());
expectSubpathToHaveMatchingStatus(targetFileURL.lastPathComponent, GTStatusDeltaStatusDeleted);
expectSubpathToHaveMatchingStatus(targetFileURL.lastPathComponent, GTDeltaTypeDeleted);
});

it(@"should recognize renamed files", ^{
NSURL *moveLocation = [repository.fileURL URLByAppendingPathComponent:@"main-moved.m"];
expect(@([NSFileManager.defaultManager moveItemAtURL:targetFileURL toURL:moveLocation error:&err])).to(beTruthy());
expect(err).to(beNil());
expectSubpathToHaveWorkDirStatus(moveLocation.lastPathComponent, GTStatusDeltaStatusRenamed);
expectSubpathToHaveWorkDirStatus(moveLocation.lastPathComponent, GTDeltaTypeRenamed);
});

it(@"should recognise ignored files", ^{ //at least in the default options
expectSubpathToHaveWorkDirStatus(@".DS_Store", GTStatusDeltaStatusIgnored);
expectSubpathToHaveWorkDirStatus(@".DS_Store", GTDeltaTypeIgnored);
});

it(@"should skip ignored files if asked", ^{
__block NSError *err = nil;
NSDictionary *options = @{ GTRepositoryStatusOptionsFlagsKey: @(0) };
BOOL enumerationSuccessful = [repository enumerateFileStatusWithOptions:options error:&err usingBlock:^(GTStatusDelta *headToIndex, GTStatusDelta *indexToWorkingDirectory, BOOL *stop) {
expect(@(indexToWorkingDirectory.status)).notTo(equal(@(GTStatusDeltaStatusIgnored)));
expect(@(indexToWorkingDirectory.status)).notTo(equal(@(GTDeltaTypeIgnored)));
}];
expect(@(enumerationSuccessful)).to(beTruthy());
expect(err).to(beNil());
Expand Down
2 changes: 1 addition & 1 deletion ObjectiveGitTests/GTRepositoryResetSpec.m
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
countStagedFiles = ^{
__block NSUInteger count = 0;
[repository enumerateFileStatusWithOptions:nil error:NULL usingBlock:^(GTStatusDelta *headToIndex, GTStatusDelta *indexToWorkingDirectory, BOOL *stop) {
if (headToIndex.status != GTStatusDeltaStatusUnmodified) count++;
if (headToIndex.status != GTDeltaTypeUnmodified) count++;
}];

return count;
Expand Down