我想知道如何使用 C-API 在 Git 中的两个标签之间找到所有提交?我知道这可以使用 CLI 工具轻松完成:
git log [第一次提交]..[第二次提交] --pretty=oneline
但是,我似乎无法弄清楚如何使用 C API 来做到这一点。我遇到的问题是图中最终出现了一个循环。
这是我在 Objective-Git 中使用的一些 Objective-C 代码,但是由于大多数人不了解 Objective-C,我很高兴在 C API 或其他一些 Git API 中得到答案。我想我必须保留以前遍历的提交或其他内容的字典?
- (void)traverseCommits: (GTCommit *)start withGoal: (GTCommit *)goal withHistory: (NSMutableDictionary *)history{
NSLog(@"%@", start.shortSHA);
if ([start.SHA isEqualToString:goal.SHA]) {
return;
}
for (GTCommit *c in start.parents) {
//[history setObject:c forKey:c.SHA];
if(![c.SHA isEqualToString:goal.SHA])
[self traverseCommits:c withGoal:goal withHistory:history];
}
}
Run Code Online (Sandbox Code Playgroud) 我正在使用Objective-Git.我无法使用以下方法:
- (GTIndex *)merge:(GTTree *)otherTree ancestor:(GTTree *)ancestorTree error:(NSError **)error
Run Code Online (Sandbox Code Playgroud)
没有返回错误,但返回的索引为空,当它存在时,所有属性都为零.合并操作不会发生,我无法写出树,因为我无法获得尝试合并产生的索引.
有没有人设法使用目标git成功执行合并 - 如何?救命!
GTBranch *branch1 = branches[0];
GTCommit *commit1 = [branch1 targetCommitAndReturnError:NULL];
GTOID *oid1 = commit1.OID;
GTTree *tree1 = commit1.tree;
GTBranch *branch2 = branches[1];
GTCommit *commit2 = [branch2 targetCommitAndReturnError:NULL];
GTTree *tree2 = commit2.tree;
GTOID *oid2 = commit2.OID;
GTRepository *repo = branch1.repository;
NSError *error;
GTCommit *ancestor = [repo mergeBaseBetweenFirstOID:oid1 secondOID:oid2 error:&error];
if (error){
NSLog(@"%@", error.description);
}
GTTree *ancTree = ancestor.tree;
NSError *someError;
NSLog(@"attempting merge into ""%@"" from ""%@"" with ancestor ""%@""", …Run Code Online (Sandbox Code Playgroud) 我正在尝试构建一个XCode项目,并在尝试构建时遇到以下错误:
...
Building for x86_64 i386 armv7 armv7s arm64
Building libssh2 for iphonesimulator7.1 x86_64
Please stand by...
/Users/jordanforeman/dev/ios/MyProject/objective-git/External/libssh2-ios/bin/iphonesimulator7.1-x86_64.sdk/build-libssh2.log
Command /bin/sh failed with exit code 1
** BUILD FAILED **
The following build commands failed:
PhaseScriptExecution Run\ Script /Users/jordanforeman/Library/Developer/Xcode/DerivedData/MyProject-azifgvrunekkgmagzghrrvpdathe/Build/Intermediates/ObjectiveGitFramework.build/Debug-iphoneos/libssh2-iOS.build/Script-6A3C609117D5963700382DFF.sh
(1 failure)
Run Code Online (Sandbox Code Playgroud)
看一看,build-libssh2.log我看到以下内容:
aclocal: error: aclocal: file '/usr/local/share/aclocal/pkg.m4' does not exist
autoheader: error: AC_CONFIG_HEADERS not found in configure.ac
cp: src/libssh2_config.h.in: No such file or directory
configure.ac:5: error: possibly undefined macro: AM_CONFIG_HEADER
If this token and others are legitimate, please use …Run Code Online (Sandbox Code Playgroud)