Skip to content

Commit 631df10

Browse files
committed
Merge branch 'master' into pull
2 parents 6b4d2e0 + 39e3beb commit 631df10

File tree

7 files changed

+53
-19
lines changed

7 files changed

+53
-19
lines changed

External/libgit2

Submodule libgit2 updated 73 files

ObjectiveGit/GTSubmodule.h

+20-6
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,7 @@ NS_ASSUME_NONNULL_BEGIN
6060
@property (nonatomic, strong, readonly) GTRepository *parentRepository;
6161

6262
/// The current ignore rule for this submodule.
63-
///
64-
/// Setting this property will only update the rule in memory, not on disk.
65-
@property (nonatomic, assign) GTSubmoduleIgnoreRule ignoreRule;
63+
@property (nonatomic, readonly, assign) GTSubmoduleIgnoreRule ignoreRule;
6664

6765
/// The OID that the submodule is pinned to in the parent repository's index.
6866
///
@@ -113,6 +111,16 @@ NS_ASSUME_NONNULL_BEGIN
113111
/// Returns whether reloading succeeded.
114112
- (BOOL)reload:(NSError **)error;
115113

114+
/// Write a new ignore rule to disk and get the resulting submodule. The
115+
/// receiver will not have the new ignore rule. To update the receiver, call
116+
/// `-reload:`.
117+
///
118+
/// ignoreRule - The ignore rule.
119+
/// error - The error if one occurred.
120+
///
121+
/// Returns the updated submodule or nil if an error occurred.
122+
- (nullable GTSubmodule *)submoduleByUpdatingIgnoreRule:(GTSubmoduleIgnoreRule)ignoreRule error:(NSError **)error;
123+
116124
/// Synchronizes the submodule repository's configuration files with the settings
117125
/// from the parent repository.
118126
///
@@ -126,11 +134,17 @@ NS_ASSUME_NONNULL_BEGIN
126134
/// Returns the opened repository, or nil if an error occurs.
127135
- (nullable GTRepository *)submoduleRepository:(NSError **)error;
128136

129-
/// Determines the status for the submodule.
130-
///
131-
/// Returns the status, or `GTSubmoduleStatusUnknown` if an error occurs.
137+
/// Calls `-statusWithIgnoreRule:error:` with the submodule's ignore rule.
132138
- (GTSubmoduleStatus)status:(NSError **)error;
133139

140+
/// Determine the status for the submodule using the given ignore rule.
141+
///
142+
/// ignoreRule - The ignore rule to use in calculating status.
143+
/// error - The error if one occurred.
144+
///
145+
/// Returns the status or `GTSubmoduleStatusUnknown` if an error occurred.
146+
- (GTSubmoduleStatus)statusWithIgnoreRule:(GTSubmoduleIgnoreRule)ignoreRule error:(NSError **)error;
147+
134148
/// Initializes the submodule by copying its information into the parent
135149
/// repository's `.git/config` file. This is equivalent to `git submodule init`
136150
/// on the command line.

ObjectiveGit/GTSubmodule.m

+16-8
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,16 @@ - (GTSubmoduleIgnoreRule)ignoreRule {
2525
return (GTSubmoduleIgnoreRule)git_submodule_ignore(self.git_submodule);
2626
}
2727

28-
- (void)setIgnoreRule:(GTSubmoduleIgnoreRule)ignoreRule {
29-
git_submodule_set_ignore(self.parentRepository.git_repository, git_submodule_name(self.git_submodule), (git_submodule_ignore_t)ignoreRule);
28+
- (GTSubmodule *)submoduleByUpdatingIgnoreRule:(GTSubmoduleIgnoreRule)ignoreRule error:(NSError **)error {
29+
int result = git_submodule_set_ignore(self.parentRepository.git_repository, git_submodule_name(self.git_submodule), (git_submodule_ignore_t)ignoreRule);
30+
if (result != GIT_OK) {
31+
if (error != NULL) {
32+
*error = [NSError git_errorFor:result description:@"Couldn't set submodule ignore rule."];
33+
}
34+
return nil;
35+
}
3036

31-
// The docs for `git_submodule_set_ignore` note "This does not affect any
32-
// currently-loaded instances." So we need to reload.
33-
git_submodule_reload(self.git_submodule, 0);
37+
return [self.parentRepository submoduleWithName:self.name error:error];
3438
}
3539

3640
- (GTOID *)indexOID {
@@ -103,9 +107,9 @@ - (instancetype)initWithGitSubmodule:(git_submodule *)submodule parentRepository
103107

104108
#pragma mark Inspection
105109

106-
- (GTSubmoduleStatus)status:(NSError **)error {
110+
- (GTSubmoduleStatus)statusWithIgnoreRule:(GTSubmoduleIgnoreRule)ignoreRule error:(NSError **)error {
107111
unsigned status;
108-
int gitError = git_submodule_status(&status, self.parentRepository.git_repository, git_submodule_name(self.git_submodule), git_submodule_ignore(self.git_submodule));
112+
int gitError = git_submodule_status(&status, self.parentRepository.git_repository, git_submodule_name(self.git_submodule), (git_submodule_ignore_t)ignoreRule);
109113
if (gitError != GIT_OK) {
110114
if (error != NULL) *error = [NSError git_errorFor:gitError description:@"Failed to get submodule %@ status.", self.name];
111115
return GTSubmoduleStatusUnknown;
@@ -114,6 +118,10 @@ - (GTSubmoduleStatus)status:(NSError **)error {
114118
return status;
115119
}
116120

121+
- (GTSubmoduleStatus)status:(NSError **)error {
122+
return [self statusWithIgnoreRule:self.ignoreRule error:error];
123+
}
124+
117125
#pragma mark Manipulation
118126

119127
- (BOOL)reload:(NSError **)error {
@@ -136,7 +144,7 @@ - (BOOL)sync:(NSError **)error {
136144
return YES;
137145
}
138146

139-
- (GTRepository *)submoduleRepository:(NSError **)error {
147+
- (nullable GTRepository *)submoduleRepository:(NSError **)error {
140148
git_repository *repo;
141149
int gitError = git_submodule_open(&repo, self.git_submodule);
142150
if (gitError != GIT_OK) {

ObjectiveGitTests/GTSubmoduleSpec.m

+11-3
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,16 @@
9393
expect(@(success)).to(beTruthy());
9494
});
9595

96+
it(@"should update the ignore rule", ^{
97+
GTSubmodule *submodule = [repo submoduleWithName:@"Test_App" error:NULL];
98+
expect(submodule).notTo(beNil());
99+
expect(@(submodule.ignoreRule)).to(equal(@(GTSubmoduleIgnoreNone)));
100+
101+
GTSubmodule *updatedSubmodule = [submodule submoduleByUpdatingIgnoreRule:GTSubmoduleIgnoreAll error:NULL];
102+
expect(@(updatedSubmodule.ignoreRule)).to(equal(@(GTSubmoduleIgnoreAll)));
103+
expect(@(submodule.ignoreRule)).to(equal(@(GTSubmoduleIgnoreNone)));
104+
});
105+
96106
describe(@"clean, checked out submodule", ^{
97107
__block GTSubmodule *submodule;
98108

@@ -204,13 +214,11 @@
204214
});
205215

206216
it(@"should honor the ignore rule", ^{
207-
submodule.ignoreRule = GTSubmoduleIgnoreDirty;
208-
209217
GTSubmoduleStatus expectedStatus =
210218
GTSubmoduleStatusExistsInHEAD | GTSubmoduleStatusExistsInIndex | GTSubmoduleStatusExistsInConfig | GTSubmoduleStatusExistsInWorkingDirectory |
211219
GTSubmoduleStatusModifiedInIndex | GTSubmoduleStatusModifiedInWorkingDirectory;
212220

213-
expect(@([submodule status:NULL])).to(equal(@(expectedStatus)));
221+
expect(@([submodule statusWithIgnoreRule:GTSubmoduleIgnoreDirty error:NULL])).to(equal(@(expectedStatus)));
214222
});
215223

216224
it(@"should open a repository" ,^{

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# ObjectiveGit
22

33
[![Carthage compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat)](https://github.com/Carthage/Carthage)
4+
[![Build Status](https://travis-ci.org/libgit2/objective-git.svg?branch=master)](https://travis-ci.org/libgit2/objective-git)
45

56
ObjectiveGit provides Cocoa bindings to the
67
[libgit2](https://github.com/libgit2/libgit2) library.

script/cibuild

+3
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,9 @@ main ()
6262
"$BOOTSTRAP" || exit $?
6363
fi
6464

65+
echo "*** Prebuilding OpenSSL"
66+
$SCRIPT_DIR/update_libssl_ios
67+
6568
echo "*** The following schemes will be built:"
6669
echo "$SCHEMES" | xargs -n 1 echo " "
6770
echo

script/update_libgit2_ios

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ function build_libgit2 ()
4242
LOG="${INSTALL_PREFIX}/build-libgit2.log"
4343
echo "$LOG"
4444

45-
cmake -DCMAKE_C_COMPILER=clang \
45+
cmake \
4646
-DCMAKE_C_COMPILER_WORKS:BOOL=ON \
4747
-DBUILD_SHARED_LIBS:BOOL=OFF \
4848
-DCMAKE_LIBRARY_PATH:PATH=../../External/libssh2-ios/lib/ \

0 commit comments

Comments
 (0)