在 libgit2 中,如何解析短引用名称以获取完整的引用名称或哈希值?需要调用什么libgit2函数?
我正在编写一个用于保险丝(Linux)的git包装器,以访问git存储库,如普通文件和目录。
访问用于分支,标签和提交的文件夹和文件效果很好,但是提交文件时出现奇怪的行为。
我做以下样式:
之后,我更新了分支引用,我仅查看更新的文件,而没有其他任何信息!
这里有代码
String referenceName = null;
IEnumerable<Commit> parentCommit = null;
// Riposiziona il puntatore dello stream all'inizio
openedHandle.Stream.Seek(0, SeekOrigin.Begin);
// Crea il blob
Blob blob = this.repository.ObjectDatabase.CreateBlob(openedHandle.Stream);
// Acquisisce la path rimuovendo le prime due parti della path
List<string> pathParts = new List<string>(openedHandle.Path.Split('/'));
pathParts.RemoveRange(0, 3);
// Inserisce il blob in un tree
TreeDefinition treeDefinition = new TreeDefinition();
treeDefinition.Add(String.Join("/", pathParts), blob, Mode.NonExecutableFile);
Tree tree = this.repository.ObjectDatabase.CreateTree(treeDefinition);
// Inizializza l'autore ed il commiter
Signature …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用nodegit打开一个包含以下代码的git存储库:
var git = require('nodegit');
git.Repo(repoPath, function(error, repository) {
if (error) throw error;
}
Run Code Online (Sandbox Code Playgroud)
这给了我以下错误,无论我分配repoPath变量:
git.Repo(repoPath, function(error, repository) {
^
Error: git_repository is required.
Run Code Online (Sandbox Code Playgroud)
我试过路径到本地文件夹,我已经尝试过路径到本地文件夹,包括.git文件夹,我已经尝试过使用url的远程仓库.没什么.
任何人都可以帮忙吗?
我正在使用
节点v0.10.24
nodegit v0.1.4.
git 1.9.0.msysgit.0
win 8.1 pro 64bit
我正在寻找一种方法来捕获我的工作目录中每个文件中有多少行发生了变化 - 就像git diff --stat在 git 中一样 - 有没有办法用 LibGit2Sharp 做到这一点?
我知道我可以从补丁中获得总 LinesAdded/Deleted,但我想知道一个文件一个文件。
我可以编写一个Zsh具有某些git-command 功能子集的模块。动机是加速提示。我使用的示例提示是:
changed_files=()
git diff --quiet 2> /dev/null || changed_files=(${(f)"$( git diff --name-only 2>/dev/null )"})
Run Code Online (Sandbox Code Playgroud)
当进入例如 linux-kernel repo 时,这不是很快。我想知道 libgit2 是否可以对某些典型任务提供更多控制,并且以这种或其他方式更快。
我想可能性很小,因为Git存储库结构简单,所以git代码是它的一对一反映。但谁知道呢?任何独特的libgit2表现特征都符合我的兴趣。
任何人都可以告诉我如何克隆回购并推送或发布已提交的更改?
目前我能够修改克隆存储库并能够提交我的更改,但我不喜欢api来推动它.也最初克隆回购.
如果它不可用,使用c#的替代方法是什么?
-Jaffer
我把所有东西从include/git2带到/ usr/include,然后尝试编译以下程序:
#include <stdio.h>
#include <repository.h>
int main(void) {
puts("Hello, world!");
return 0;
}
Run Code Online (Sandbox Code Playgroud)
当我用GCC编译它时,我收到以下错误:
maxwell@UNIX-PC:~$ gcc ok.c
In file included from /usr/include/common.h:16:0,
from /usr/include/repository.h:10,
from ok.c:2:
/usr/include/inttypes.h:33:2: error: #error "Use this header only with Microsoft Visual C++ compilers!"
In file included from /usr/include/inttypes.h:46:0,
from /usr/include/common.h:16,
from /usr/include/repository.h:10,
from ok.c:2:
/usr/include/stdint.h:33:2: error: #error "Use this header only with Microsoft Visual C++ compilers!"
In file included from /usr/include/inttypes.h:46:0,
from /usr/include/common.h:16,
from /usr/include/repository.h:10,
from ok.c:2:
/usr/include/stdint.h:89:30: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ …Run Code Online (Sandbox Code Playgroud) 我正在尝试连接到一个回购:
using(var Git = new Repository(
Repository.Clone("https://github.com/wikimedia/mediawiki-core", "tmp")
)){
foreach(var Commit in Git.Commits)
{
MessageBox.Show(Commit.Author.Name);
}
}
Run Code Online (Sandbox Code Playgroud)
它连接正常(如果我更改了URL,我得到了预期的异常),但没有显示MessageBoxes - 为什么?这应该很简单.
我从这个站点下载了两个DLL(libgit2sharp.dll和git2.dll).
之后,我通过在.NET Windows应用程序中添加引用成功添加了Libgit2sharp.dll.现在,当我通过在.NET Windows应用程序中添加引用添加git2.dll时,它会出错:
a reference to 'C:\User\nitesh\git2.dll' could not be added please make sure that the file is accessible and that it is a valid assembly or COM component
Run Code Online (Sandbox Code Playgroud)
有人可以帮我理解这个问题吗?
我有两个约会 - 从和到.我必须在日期差异之间找到存储库中更改的文件并列出它.这是一个相关的问题,它可以得到树之间的差异.从LibGit2Sharp中的提交中获取已修改/添加/删除的文件.
libgit2 ×10
git ×7
libgit2sharp ×6
c# ×3
c ×2
github ×2
linux ×2
github-api ×1
mono ×1
node.js ×1
nodegit ×1
performance ×1