libgit2

how to print diff files in libgit2?

守給你的承諾、 提交于 2019-12-11 05:14:18
问题 I tried this string path = "path/to/my/repo"; git_libgit2_init(); const char * REPO_PATH = path.c_str(); git_repository * repo = nullptr; git_repository_open(&repo, REPO_PATH); git_diff_options diffopts = GIT_DIFF_OPTIONS_INIT; git_diff *diff; diffopts.flags = GIT_CHECKOUT_NOTIFY_CONFLICT; git_diff_index_to_workdir(&diff, repo, NULL, &diffopts); git_diff_format_t format = GIT_DIFF_FORMAT_NAME_ONLY; if (0!=git_diff_print(diff, format, NULL,NULL)) cerr << "git_diff_print() failed" << endl; git

How to connect to a GitHub repo using libgit2?

巧了我就是萌 提交于 2019-12-11 02:26:58
问题 I'm trying to connect to a repo: 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); } } It connects ok (as in, if I change the URL I get the expected exception), but no MessageBox es are shown - why? This should be simple. 回答1: Few things to consider regarding your question: One cannot "connect" to a remote repository and dynamically retrieve one file through the

LibGit2Sharp CheckoutPaths()

给你一囗甜甜゛ 提交于 2019-12-10 18:03:02
问题 I did a commit (49916.....) now i want to checkout one file of the commit into the working dir. The file is named NEW.txt. If i type Git checkout 49916 NEW.txt into Git Bash it creates the NEW.txt file with the content in my working dir. But my LibGit2Sharp command does not want to work. What am I doing wrong? var repo = new Repository(repopath); var checkoutPaths = new[] { "NEW.txt"}; repo.CheckoutPaths("49916", checkoutPaths); I read every article which i could find about the checkoutpaths

How can I create an empty commit using libgit2?

核能气质少年 提交于 2019-12-10 15:19:57
问题 I've been looking over the libgit2 C API reference, but I don't see how I could emulate the behaviour of git commit --allow-empty . Does libgit2 have a built-in way to create empty commits? If not, how does git create an empty commit under-the-hood, and how should I go about achieving the same behaviour using libgit2? 回答1: Call git_commit_create with the same tree as the parent commit. That is: // Get parent somehow. git_commit *parent = ...; // Use the same tree as the parent. git_tree *tree

libgit2 with libssh2 and libopenssl on windows

99封情书 提交于 2019-12-10 12:13:57
问题 I’ve tried before and had little success in the full build but even that fails now and I'm obviously missing something on windows (and yes its probably windows :P) can someone walk me through finding the correct OpenSSL to compile with libssh2 actually cmake/compiling libssh2 into libgit2 cause it keeps saying cannot find libssh2 and I'm struggling to build it again. I'm using CMake gui For windows, trying to build a VC2015 project The error I was getting when building libgit2 is checking for

基于 Git Namespace 的存储库快照方案

淺唱寂寞╮ 提交于 2019-12-09 20:43:47
前言 Git 是一种分布式的版本控制系统,分布式版本控制系统的一大特性就是远程存储库和本地存储库都包含存储库的完整数据。 而集中式的版本控制系统只有在中心服务器上才会包含存储库完整的数据,本地所谓的存储库只是远程服务器特定版本的 checkout 。当中心服务器故障后,如果没有备份服务器,那么集中式的版本控制系统存储库的数据绝大部分就会被丢失。这很容易得出分布式版本控制系统的代码要必集中式的版本控制系统更加安全。 但是,安全并不是绝对的,尤其当 Git 被越来越多的人使用后,用户也会需要 Git 吸收集中式版本控制系统的特性来改进用户体验,这种情形下,Git 分布式版本控制系统的安全性也就面临挑战。终端用户获取的不是完整的数据,为了保证存储库的安全仍然需要备份或者镜像远程服务器上的存储库。(用户可以使用浅表克隆,单分支克隆或者使用 git vfs(GVFS) 之类的技术加快 git 访问。) Git 给开发者非常大的自由,git 可以修改 commit 重新提交,也可以强制推送<sup>1</sup>引用到远程服务器,覆盖特定的引用,不合理的使用强制推送是非常危险的,这很容易造成代码丢失,对于企业存储库来说,合理的快照能够代码丢失后减小代码资产的损失。(但这并不是说绝对禁止强制推送<sup>2</sup>) 在 Gitee 提供了企业版后,我们也经常接收到用户对于代码资产安全的反馈

git2go with libssl and libssh2 in single binary

我怕爱的太早我们不能终老 提交于 2019-12-08 03:57:54
问题 Could anyone offer some suggestions (or resources) on how I could package a GO program that uses git2go, libssl and libssh2 such that it doesn't require the end user to install these libraries separately? I am only targeting Linux distros (if it matters) 回答1: One way would be to build those dependencies statically as well and use PKG_CONFIG_PATH point to your own copies so everything gets linked statically. That should make CMake choose the static versions. But if the goal is to avoid

Setting upstream on a repo

戏子无情 提交于 2019-12-08 03:56:38
问题 I am trying to pull the master branch from a remote using libgit2sharp . Sometimes I have to change the remote to a different url and pull from that remote . When I change the remote and try to pull I get this error: There is no tracking information for the current branch I know I have to do git branch --set-upstream-to=origin/master master to fix this issue using git, but I wonder how can I do the same with libgit2sharp ? 回答1: Given mybranch, a Branch instance, which is already configured to

comparing 2 commits in rugged

南楼画角 提交于 2019-12-07 14:14:59
问题 I didn't find any documentation on getting the difference between 2 files in rugged. I used the below code to commit a file using rugged @repo=Rugged::Repository.new($reponame) @sha=@repo.write('D:\Ruby\MyGitRepo\file1.txt','blob') puts @sha commit = @repo.lookup(@sha) how can see the difference between the 2 commits of the same object in rugged? 回答1: The way to compare two commits in git relies on a diffing process. brianmario recently wrapped the diffing iterator feature of libgit2 . Beware

How to get the diff of a single file with libgit2?

北战南征 提交于 2019-12-07 06:58:07
问题 Is there a function equivalent to git diff FILE in libgit2 ? In other words, how to efficiently retrieve the diff of a single file without having libgit2 to look at other files in the working directory? 回答1: git diff FILE will display the changes you've made relative to the index. This can be achieved through the use of the libgit2 git_diff_index_to_workdir() function. This function accepts a git_diff_options structure as a parameter into which you can provide a pathspec, or a list of