Skip to content

Commit 59101bf

Browse files
committed
Merge pull request #351 from libgit2/add-reset
Added -resetPathspecs:...
2 parents 98367f8 + 8b1d9dc commit 59101bf

File tree

9 files changed

+194
-59
lines changed

9 files changed

+194
-59
lines changed

Classes/GTRepository+Reset.h

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
//
2+
// GTRepository+Reset.h
3+
// ObjectiveGitFramework
4+
//
5+
// Created by Josh Abernathy on 4/4/14.
6+
// Copyright (c) 2014 GitHub, Inc. All rights reserved.
7+
//
8+
9+
#import "GTRepository.h"
10+
11+
/// The reset types. See the libgit2 documentation for more info.
12+
typedef enum {
13+
GTRepositoryResetTypeSoft = GIT_RESET_SOFT,
14+
GTRepositoryResetTypeMixed = GIT_RESET_MIXED,
15+
GTRepositoryResetTypeHard = GIT_RESET_HARD,
16+
} GTRepositoryResetType;
17+
18+
@interface GTRepository (Reset)
19+
20+
/// Reset the repository's HEAD to the given commit.
21+
///
22+
/// commit - The commit the HEAD is to be reset to. Must not be nil.
23+
/// resetType - The type of reset to be used.
24+
/// error - The error if one occurred.
25+
///
26+
/// Returns whether the reset was succcessful.
27+
- (BOOL)resetToCommit:(GTCommit *)commit resetType:(GTRepositoryResetType)resetType error:(NSError **)error;
28+
29+
/// Resets the given pathspecs in the index to the tree entries from the commit.
30+
///
31+
/// pathspecs - The pathspecs to reset. Cannot be nil.
32+
/// commit - The commit whose tree should be used to reset. Cannot be nil.
33+
/// error - The error if one occurred.
34+
///
35+
/// Returns whether the reset was successful.
36+
- (BOOL)resetPathspecs:(NSArray *)pathspecs toCommit:(GTCommit *)commit error:(NSError **)error;
37+
38+
@end

Classes/GTRepository+Reset.m

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
//
2+
// GTRepository+Reset.m
3+
// ObjectiveGitFramework
4+
//
5+
// Created by Josh Abernathy on 4/4/14.
6+
// Copyright (c) 2014 GitHub, Inc. All rights reserved.
7+
//
8+
9+
#import "GTRepository+Reset.h"
10+
#import "GTCommit.h"
11+
#import "NSArray+StringArray.h"
12+
#import "NSError+Git.h"
13+
#import "GTSignature.h"
14+
15+
@implementation GTRepository (Reset)
16+
17+
- (BOOL)resetToCommit:(GTCommit *)commit resetType:(GTRepositoryResetType)resetType error:(NSError **)error {
18+
NSParameterAssert(commit != nil);
19+
20+
int gitError = git_reset(self.git_repository, commit.git_object, (git_reset_t)resetType, (git_signature *)[self userSignatureForNow].git_signature, NULL);
21+
if (gitError != GIT_OK) {
22+
if (error != NULL) {
23+
*error = [NSError git_errorFor:gitError description:@"Failed to reset repository to commit %@.", commit.SHA];
24+
}
25+
26+
return NO;
27+
}
28+
29+
return YES;
30+
}
31+
32+
- (BOOL)resetPathspecs:(NSArray *)paths toCommit:(GTCommit *)commit error:(NSError **)error {
33+
NSParameterAssert(paths != nil);
34+
NSParameterAssert(commit != nil);
35+
36+
git_strarray array = paths.git_strarray;
37+
int gitError = git_reset_default(self.git_repository, commit.git_object, &array);
38+
if (gitError != GIT_OK) {
39+
if (error != NULL) {
40+
*error = [NSError git_errorFor:gitError description:@"Failed resetting paths (%@) to %@", paths, commit];
41+
}
42+
43+
return NO;
44+
}
45+
46+
return YES;
47+
}
48+
49+
@end

Classes/GTRepository.h

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -47,12 +47,6 @@
4747
@class GTTag;
4848
@class GTTree;
4949

50-
typedef enum {
51-
GTRepositoryResetTypeSoft = GIT_RESET_SOFT,
52-
GTRepositoryResetTypeMixed = GIT_RESET_MIXED,
53-
GTRepositoryResetTypeHard = GIT_RESET_HARD
54-
} GTRepositoryResetType;
55-
5650
// Checkout strategies used by the various -checkout... methods
5751
// See git_checkout_strategy_t
5852
typedef enum {
@@ -277,15 +271,6 @@ extern NSString *const GTRepositoryCloneOptionsCredentialProvider;
277271
// returns the local commits, an empty array if there is no remote branch, or nil if an error occurred
278272
- (NSArray *)localCommitsRelativeToRemoteBranch:(GTBranch *)remoteBranch error:(NSError **)error;
279273

280-
// Reset the repository's HEAD to the given commit.
281-
//
282-
// commit - the commit the HEAD is to be reset to. Must not be nil.
283-
// resetType - The type of reset to be used.
284-
// error(out) - in the event of an error this may be set.
285-
//
286-
// Returns `YES` if successful, `NO` if not.
287-
- (BOOL)resetToCommit:(GTCommit *)commit withResetType:(GTRepositoryResetType)resetType error:(NSError **)error;
288-
289274
// Retrieves git's "prepared message" for the next commit, like the default
290275
// message pre-filled when committing after a conflicting merge.
291276
//

Classes/GTRepository.m

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -526,17 +526,6 @@ - (BOOL)isHEADUnborn {
526526
return (BOOL)git_repository_head_unborn(self.git_repository);
527527
}
528528

529-
- (BOOL)resetToCommit:(GTCommit *)commit withResetType:(GTRepositoryResetType)resetType error:(NSError **)error {
530-
NSParameterAssert(commit != nil);
531-
532-
int result = git_reset(self.git_repository, commit.git_object, (git_reset_t)resetType, (git_signature *)[self userSignatureForNow].git_signature, NULL);
533-
if (result == GIT_OK) return YES;
534-
535-
if (error != NULL) *error = [NSError git_errorFor:result description:@"Failed to reset repository to commit %@.", commit.SHA];
536-
537-
return NO;
538-
}
539-
540529
- (NSString *)preparedMessageWithError:(NSError **)error {
541530
void (^setErrorFromCode)(int) = ^(int errorCode) {
542531
if (errorCode == 0 || errorCode == GIT_ENOTFOUND) {

Classes/ObjectiveGit.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
#import <ObjectiveGit/GTRepository+Stashing.h>
3030
#import <ObjectiveGit/GTRepository+Committing.h>
3131
#import <ObjectiveGit/GTRepository+Status.h>
32+
#import <ObjectiveGit/GTRepository+Reset.h>
3233
#import <ObjectiveGit/GTEnumerator.h>
3334
#import <ObjectiveGit/GTCommit.h>
3435
#import <ObjectiveGit/GTCredential.h>

ObjectiveGitFramework.xcodeproj/project.pbxproj

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,7 @@
194194
8821547F17147B3600D76B76 /* GTOID.m in Sources */ = {isa = PBXBuildFile; fileRef = 8821547C17147B3600D76B76 /* GTOID.m */; };
195195
8821548017147B3600D76B76 /* GTOID.m in Sources */ = {isa = PBXBuildFile; fileRef = 8821547C17147B3600D76B76 /* GTOID.m */; };
196196
88215483171499BE00D76B76 /* GTReflogSpec.m in Sources */ = {isa = PBXBuildFile; fileRef = 88215482171499BE00D76B76 /* GTReflogSpec.m */; };
197+
88234B2618F2FE260039972E /* GTRepositoryResetSpec.m in Sources */ = {isa = PBXBuildFile; fileRef = 88234B2518F2FE260039972E /* GTRepositoryResetSpec.m */; };
197198
8832811F173D8816006D7DCF /* GTIndexSpec.m in Sources */ = {isa = PBXBuildFile; fileRef = 8832811E173D8816006D7DCF /* GTIndexSpec.m */; };
198199
88328128173D8A64006D7DCF /* GTTreeSpec.m in Sources */ = {isa = PBXBuildFile; fileRef = 88328127173D8A64006D7DCF /* GTTreeSpec.m */; };
199200
883CD6AB1600EBC600F57354 /* GTRemote.h in Headers */ = {isa = PBXBuildFile; fileRef = 883CD6A91600EBC600F57354 /* GTRemote.h */; settings = {ATTRIBUTES = (Public, ); }; };
@@ -212,6 +213,10 @@
212213
88948AC91779243600809CDA /* GTObjectDatabaseSpec.m in Sources */ = {isa = PBXBuildFile; fileRef = 88948AC81779243600809CDA /* GTObjectDatabaseSpec.m */; };
213214
88A994BA16FCE7D400402C7B /* GTBranchSpec.m in Sources */ = {isa = PBXBuildFile; fileRef = 88A994B916FCE7D400402C7B /* GTBranchSpec.m */; };
214215
88A994CB16FCED1D00402C7B /* GTTestCase.m in Sources */ = {isa = PBXBuildFile; fileRef = 88A994CA16FCED1D00402C7B /* GTTestCase.m */; };
216+
88BC0E5018EF4F3600C7D0E6 /* GTRepository+Reset.h in Headers */ = {isa = PBXBuildFile; fileRef = 88BC0E4E18EF4F3600C7D0E6 /* GTRepository+Reset.h */; settings = {ATTRIBUTES = (Public, ); }; };
217+
88BC0E5118EF4F3600C7D0E6 /* GTRepository+Reset.h in Headers */ = {isa = PBXBuildFile; fileRef = 88BC0E4E18EF4F3600C7D0E6 /* GTRepository+Reset.h */; settings = {ATTRIBUTES = (Public, ); }; };
218+
88BC0E5218EF4F3600C7D0E6 /* GTRepository+Reset.m in Sources */ = {isa = PBXBuildFile; fileRef = 88BC0E4F18EF4F3600C7D0E6 /* GTRepository+Reset.m */; };
219+
88BC0E5318EF4F3600C7D0E6 /* GTRepository+Reset.m in Sources */ = {isa = PBXBuildFile; fileRef = 88BC0E4F18EF4F3600C7D0E6 /* GTRepository+Reset.m */; };
215220
88C0BC5917038CF3009E99AA /* GTConfigurationSpec.m in Sources */ = {isa = PBXBuildFile; fileRef = 88C0BC5817038CF3009E99AA /* GTConfigurationSpec.m */; };
216221
88EB7E4D14AEBA600046FEA4 /* GTConfiguration.h in Headers */ = {isa = PBXBuildFile; fileRef = 88EB7E4B14AEBA600046FEA4 /* GTConfiguration.h */; settings = {ATTRIBUTES = (Public, ); }; };
217222
88EB7E4E14AEBA600046FEA4 /* GTConfiguration.m in Sources */ = {isa = PBXBuildFile; fileRef = 88EB7E4C14AEBA600046FEA4 /* GTConfiguration.m */; };
@@ -430,6 +435,7 @@
430435
8821547B17147B3600D76B76 /* GTOID.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GTOID.h; sourceTree = "<group>"; };
431436
8821547C17147B3600D76B76 /* GTOID.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GTOID.m; sourceTree = "<group>"; };
432437
88215482171499BE00D76B76 /* GTReflogSpec.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GTReflogSpec.m; sourceTree = "<group>"; };
438+
88234B2518F2FE260039972E /* GTRepositoryResetSpec.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GTRepositoryResetSpec.m; sourceTree = "<group>"; };
433439
8832811E173D8816006D7DCF /* GTIndexSpec.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GTIndexSpec.m; sourceTree = "<group>"; };
434440
88328127173D8A64006D7DCF /* GTTreeSpec.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GTTreeSpec.m; sourceTree = "<group>"; };
435441
883CD6A91600EBC600F57354 /* GTRemote.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GTRemote.h; sourceTree = "<group>"; };
@@ -447,6 +453,8 @@
447453
88A994B916FCE7D400402C7B /* GTBranchSpec.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GTBranchSpec.m; sourceTree = "<group>"; };
448454
88A994C916FCED1D00402C7B /* GTTestCase.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GTTestCase.h; sourceTree = "<group>"; };
449455
88A994CA16FCED1D00402C7B /* GTTestCase.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GTTestCase.m; sourceTree = "<group>"; };
456+
88BC0E4E18EF4F3600C7D0E6 /* GTRepository+Reset.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "GTRepository+Reset.h"; sourceTree = "<group>"; };
457+
88BC0E4F18EF4F3600C7D0E6 /* GTRepository+Reset.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "GTRepository+Reset.m"; sourceTree = "<group>"; };
450458
88C0BC5817038CF3009E99AA /* GTConfigurationSpec.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GTConfigurationSpec.m; sourceTree = "<group>"; };
451459
88EB7E4B14AEBA600046FEA4 /* GTConfiguration.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GTConfiguration.h; sourceTree = "<group>"; };
452460
88EB7E4C14AEBA600046FEA4 /* GTConfiguration.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GTConfiguration.m; sourceTree = "<group>"; };
@@ -733,6 +741,7 @@
733741
D015F7D417F6965400AD5E1F /* GTRepositoryStashingSpec.m */,
734742
886E623618AECD86000611A0 /* GTFilterSpec.m */,
735743
D0751CD818BE520400134314 /* GTFilterListSpec.m */,
744+
88234B2518F2FE260039972E /* GTRepositoryResetSpec.m */,
736745
);
737746
path = ObjectiveGitTests;
738747
sourceTree = "<group>";
@@ -763,6 +772,8 @@
763772
BDE4C063130EFE2C00851650 /* GTRepository.m */,
764773
30DCBA6117B45A78009B0EBD /* GTRepository+Status.h */,
765774
30DCBA6217B45A78009B0EBD /* GTRepository+Status.m */,
775+
88BC0E4E18EF4F3600C7D0E6 /* GTRepository+Reset.h */,
776+
88BC0E4F18EF4F3600C7D0E6 /* GTRepository+Reset.m */,
766777
30DCBA5A17B45213009B0EBD /* GTStatusDelta.h */,
767778
30DCBA5B17B45213009B0EBD /* GTStatusDelta.m */,
768779
D015F7C817F695E800AD5E1F /* GTRepository+Stashing.h */,
@@ -935,6 +946,7 @@
935946
886E622B18AEBF75000611A0 /* GTFilterSource.h in Headers */,
936947
306123B217EA5261006591D4 /* metamacros.h in Headers */,
937948
3E0A23E5159E0FDB00A6068F /* GTObjectDatabase.h in Headers */,
949+
88BC0E5118EF4F3600C7D0E6 /* GTRepository+Reset.h in Headers */,
938950
04DB464E133AB5E200D9C624 /* NSError+Git.h in Headers */,
939951
55C8057F13875C62004DCB0F /* NSData+Git.h in Headers */,
940952
55C8058013875C6E004DCB0F /* NSString+Git.h in Headers */,
@@ -998,6 +1010,7 @@
9981010
BDD627991318391200DE34D1 /* GTBlob.h in Headers */,
9991011
886E622A18AEBF75000611A0 /* GTFilterSource.h in Headers */,
10001012
BDD62924131C03D600DE34D1 /* GTTag.h in Headers */,
1013+
88BC0E5018EF4F3600C7D0E6 /* GTRepository+Reset.h in Headers */,
10011014
BDFAF9C3131C1845000508BC /* GTIndex.h in Headers */,
10021015
BDFAF9C9131C1868000508BC /* GTIndexEntry.h in Headers */,
10031016
BD441E08131ED0C300187010 /* GTReference.h in Headers */,
@@ -1253,6 +1266,7 @@
12531266
3011D87A1668F29600CE3409 /* GTDiffDelta.m in Sources */,
12541267
DD3D951E182AB3BD004AF532 /* GTBlame.m in Sources */,
12551268
880EE66418AE700500B82455 /* GTFilter.m in Sources */,
1269+
88BC0E5318EF4F3600C7D0E6 /* GTRepository+Reset.m in Sources */,
12561270
30FDC08216835A8100654BF0 /* GTDiffLine.m in Sources */,
12571271
30DCBA6017B45213009B0EBD /* GTStatusDelta.m in Sources */,
12581272
30B1E7F11703522100D0814D /* NSDate+GTTimeAdditions.m in Sources */,
@@ -1298,6 +1312,7 @@
12981312
8832811F173D8816006D7DCF /* GTIndexSpec.m in Sources */,
12991313
D0F4E28A17C7F24200BBDE30 /* NSErrorGitSpec.m in Sources */,
13001314
88328128173D8A64006D7DCF /* GTTreeSpec.m in Sources */,
1315+
88234B2618F2FE260039972E /* GTRepositoryResetSpec.m in Sources */,
13011316
5BE612931745EEBC00266D8C /* GTTreeBuilderSpec.m in Sources */,
13021317
D06D9E011755D10000558C17 /* GTEnumeratorSpec.m in Sources */,
13031318
D03B7C411756AB370034A610 /* GTSubmoduleSpec.m in Sources */,
@@ -1329,6 +1344,7 @@
13291344
BDD62925131C03D600DE34D1 /* GTTag.m in Sources */,
13301345
BDFAF9C4131C1845000508BC /* GTIndex.m in Sources */,
13311346
BDFAF9CA131C1868000508BC /* GTIndexEntry.m in Sources */,
1347+
88BC0E5218EF4F3600C7D0E6 /* GTRepository+Reset.m in Sources */,
13321348
BD441E09131ED0C300187010 /* GTReference.m in Sources */,
13331349
88F50F5A132054D800584FBE /* GTBranch.m in Sources */,
13341350
D0CE552318B6C58F008EB8E0 /* GTFilterList.m in Sources */,
Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
//
2+
// GTRepositoryResetSpec.m
3+
// ObjectiveGitFramework
4+
//
5+
// Created by Josh Abernathy on 4/7/14.
6+
// Copyright (c) 2014 GitHub, Inc. All rights reserved.
7+
//
8+
9+
#import "GTRepository+Reset.h"
10+
#import "GTRepository.h"
11+
#import "GTIndex.h"
12+
13+
SpecBegin(GTRepositoryReset)
14+
15+
__block GTRepository *repository;
16+
17+
describe(@"-resetPathspecs:toCommit:error:", ^{
18+
__block NSUInteger (^countStagedFiles)(void);
19+
20+
beforeEach(^{
21+
repository = [self testAppFixtureRepository];
22+
23+
countStagedFiles = ^{
24+
__block NSUInteger count = 0;
25+
[repository enumerateFileStatusWithOptions:nil error:NULL usingBlock:^(GTStatusDelta *headToIndex, GTStatusDelta *indexToWorkingDirectory, BOOL *stop) {
26+
if (headToIndex.status != GTStatusDeltaStatusUnmodified) count++;
27+
}];
28+
29+
return count;
30+
};
31+
});
32+
33+
it(@"should reset the path's index entry", ^{
34+
static NSString * const fileName = @"README.md";
35+
NSURL *fileURL = [repository.fileURL URLByAppendingPathComponent:fileName];
36+
BOOL success = [@"blahahaha" writeToURL:fileURL atomically:YES encoding:NSUTF8StringEncoding error:NULL];
37+
expect(success).to.beTruthy();
38+
39+
GTIndex *index = [repository indexWithError:NULL];
40+
expect(index).notTo.beNil();
41+
42+
success = [index addFile:fileName error:NULL];
43+
expect(success).to.beTruthy();
44+
45+
expect(countStagedFiles()).to.equal(1);
46+
47+
GTCommit *HEAD = [repository lookUpObjectByRevParse:@"HEAD" error:NULL];
48+
expect(HEAD).notTo.beNil();
49+
50+
success = [repository resetPathspecs:@[ fileName ] toCommit:HEAD error:NULL];
51+
expect(success).to.beTruthy();
52+
53+
expect(countStagedFiles()).to.equal(0);
54+
});
55+
});
56+
57+
describe(@"-resetToCommit:resetType:error:", ^{
58+
beforeEach(^{
59+
repository = [self bareFixtureRepository];
60+
});
61+
62+
it(@"should move HEAD when used", ^{
63+
NSError *error = nil;
64+
GTReference *originalHead = [repository headReferenceWithError:NULL];
65+
NSString *resetTargetSHA = @"8496071c1b46c854b31185ea97743be6a8774479";
66+
67+
GTCommit *commit = [repository lookUpObjectBySHA:resetTargetSHA error:NULL];
68+
expect(commit).notTo.beNil();
69+
GTCommit *originalHeadCommit = [repository lookUpObjectBySHA:originalHead.targetSHA error:NULL];
70+
expect(originalHeadCommit).notTo.beNil();
71+
72+
BOOL success = [repository resetToCommit:commit resetType:GTRepositoryResetTypeSoft error:&error];
73+
expect(success).to.beTruthy();
74+
expect(error).to.beNil();
75+
76+
GTReference *head = [repository headReferenceWithError:&error];
77+
expect(head).notTo.beNil();
78+
expect(head.targetSHA).to.equal(resetTargetSHA);
79+
80+
success = [repository resetToCommit:originalHeadCommit resetType:GTRepositoryResetTypeSoft error:&error];
81+
expect(success).to.beTruthy();
82+
expect(error).to.beNil();
83+
84+
head = [repository headReferenceWithError:&error];
85+
expect(head.targetSHA).to.equal(originalHead.targetSHA);
86+
});
87+
});
88+
89+
SpecEnd

ObjectiveGitTests/GTRepositorySpec.m

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -327,38 +327,6 @@
327327
});
328328
});
329329

330-
describe(@"-resetToCommit:withResetType:error:", ^{
331-
beforeEach(^{
332-
repository = self.bareFixtureRepository;
333-
});
334-
335-
it(@"should move HEAD when used", ^{
336-
NSError *error = nil;
337-
GTReference *originalHead = [repository headReferenceWithError:NULL];
338-
NSString *resetTargetSHA = @"8496071c1b46c854b31185ea97743be6a8774479";
339-
340-
GTCommit *commit = [repository lookUpObjectBySHA:resetTargetSHA error:NULL];
341-
expect(commit).notTo.beNil();
342-
GTCommit *originalHeadCommit = [repository lookUpObjectBySHA:originalHead.targetSHA error:NULL];
343-
expect(originalHeadCommit).notTo.beNil();
344-
345-
BOOL success = [repository resetToCommit:commit withResetType:GTRepositoryResetTypeSoft error:&error];
346-
expect(success).to.beTruthy();
347-
expect(error).to.beNil();
348-
349-
GTReference *head = [repository headReferenceWithError:&error];
350-
expect(head).notTo.beNil();
351-
expect(head.targetSHA).to.equal(resetTargetSHA);
352-
353-
success = [repository resetToCommit:originalHeadCommit withResetType:GTRepositoryResetTypeSoft error:&error];
354-
expect(success).to.beTruthy();
355-
expect(error).to.beNil();
356-
357-
head = [repository headReferenceWithError:&error];
358-
expect(head.targetSHA).to.equal(originalHead.targetSHA);
359-
});
360-
});
361-
362330
describe(@"-lookUpBranchWithName:type:error:", ^{
363331
it(@"should look up a local branch", ^{
364332
NSError *error = nil;

ObjectiveGitTests/GTSubmoduleSpec.m

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

172172
GTCommit *newHEAD = (id)[submoduleRepo lookUpObjectBySHA:@"82dc47f6ba3beecab33080a1136d8913098e1801" objectType:GTObjectTypeCommit error:NULL];
173173
expect(newHEAD).notTo.beNil();
174-
expect([submoduleRepo resetToCommit:newHEAD withResetType:GTRepositoryResetTypeHard error:NULL]).to.beTruthy();
174+
expect([submoduleRepo resetToCommit:newHEAD resetType:GTRepositoryResetTypeHard error:NULL]).to.beTruthy();
175175

176176
expect(submodule.workingDirectoryOID.SHA).notTo.equal(newHEAD.SHA);
177177

0 commit comments

Comments
 (0)