libgit2

How to apply diff rules of the languages in gitattributes

旧街凉风 提交于 2019-12-24 01:09:23
问题 For example, the .gitattributes file of lg2s has the line *.cs diff=csharp . the output of the codes using (var repo = new Repository(@"path\to\lg2s")) { var tree1 = repo.Lookup<Commit>("a845db9").Tree; var tree2 = repo.Lookup<Commit>("d677741").Tree; var patches = repo.Diff.Compare<Patch>(tree1, tree2); foreach (var patch in patches) { Console.WriteLine(patch.Patch); } } is (shortly) diff --git a/LibGit2Sharp/RepositoryStatus.cs b/LibGit2Sharp/RepositoryStatus.cs @@ -59,8 +59,8 @@ namespace

Does the libgit2 project or anyone else provide sample code to demonstrate the various libgit2 functions?

守給你的承諾、 提交于 2019-12-23 12:24:36
问题 I am using libgit2 via an FFI in another language but I am having difficulty figuring out what various functions actually do (and I'd prefer not to resort to reading the source code unless absolutely necessary). Does anyone know where I can find some working code samples for some of the functions in libgit2? 回答1: There are many ways to help you get a start with libgit2: A series of posts from Ben Straub, one of the core contributors Taking a peek at the libgit2 examples which are written in a

Is it possible to add parts of a file to Git index using libgit2?

落爺英雄遲暮 提交于 2019-12-23 01:45:19
问题 I am using libgit2, actually libgit2sharp, is there a way to add parts of a file similar to what add -p in CLI? I don't find anything from the documentation: http://libgit2.github.com/libgit2/#HEAD/group/index 回答1: This is neither implemented (yet) in libgit2 , nor in LibGit2Sharp . In order to make this happen sooner rather than later, I'd suggest you to open a feature request in the libgit2 tracker . 来源: https://stackoverflow.com/questions/9597663/is-it-possible-to-add-parts-of-a-file-to

Difference between “(no branch)” and “(detached at abc1234)”

ε祈祈猫儿з 提交于 2019-12-22 09:50:18
问题 Normally when you run something like this inside of a git repository: git checkout abc1234 You end up in a detached HEAD state. If you run git branch , the output will look something like this: * (detached from abc1234) master This is fine and expected behaviour. I've been playing around with pygit2 recently, and have come across something I haven't seen before. Let's say I do the following: repo = pygit2.discover_repository("/path/to/repo") repo.head = "abc1234" I would expect the repository

Git stash on windows extremly slow compared to Libgit2

对着背影说爱祢 提交于 2019-12-22 06:29:21
问题 Recently I've been using git stash many times and I've been thinking that it is really slow, even on a new repository with a single file. I've read this question about git stash slowness and this other one and tried every answer to these questions but nothing actually works. For example I've done the following steps to reproduce it: git init touch file.txt vim file.txt (edit the file adding 2 lines) git add . git commit -m "Initial commit" vim file.txt (edit it again adding 1 line) time git

Implementing 'git pull' with libgit2?

末鹿安然 提交于 2019-12-22 05:13:18
问题 I have a relatively short Gist which is supposed to use libgit2 to emulate the functionality of the git pull command. Unfortunately, it's not quite working. In summary, the snippet: calls git_repository_open() to open the repository on disk calls git_remote_load() to get a git_remote * to the remote named "origin" calls git_remote_connect() with the GIT_DIRECTION_FETCH flag calls git_remote_download() to fetch objects from the remote According to git_remote_stats(), objects are indeed being

How to commit to a git repository using libgit2?

一笑奈何 提交于 2019-12-21 23:02:57
问题 Since there is no copy-paste example for creating a commit without using files on disk with libgit2 as far as I can tell I thought I should add one. Don't forget that libgit2 is in full development at this time (March 2013) so have a look at official documentation and source code, as new features are added daily: libgit2 API headers are very well commented - here's an example extensive tests may be a source of inspiration there are some official examples, general.c is a good place to start

How to push git repository through ssh using libgit2

佐手、 提交于 2019-12-21 20:24:58
问题 Since, the ssh support is already implemented, could anybody show me how to write a push() function? I had some success pushing through the local file system but when I try the ssh I only get a segfault . int cred_acquire_cb(git_cred** cred,const char* url,unsigned int allowed_types, void* payload){ check_error(git_cred_ssh_keyfile_passphrase_new(cred,"./bitbucket.pub","./bitbucket",NULL),"keyfile passphrase"); } int main(int argc, const char *argv[]) { char* repo_path="./hello/.git"; char*

How to retrieve all object IDs?

心不动则不痛 提交于 2019-12-21 01:59:17
问题 I am trying to get a list of all object IDs in a git repository, using libgit2. I can't seem to find any method for this. Does libgit2 have a method to get all object IDs (or iterate through them), or do I need to read them manually? 回答1: What you may be looking for is the revision walking API. Description of the feature can be found here. A test demonstrating different walking strategies may also provide you with some help Edit: A thread in the libgit2 mailing list specifically deals with

How to retrieve all object IDs?

百般思念 提交于 2019-12-21 01:59:08
问题 I am trying to get a list of all object IDs in a git repository, using libgit2. I can't seem to find any method for this. Does libgit2 have a method to get all object IDs (or iterate through them), or do I need to read them manually? 回答1: What you may be looking for is the revision walking API. Description of the feature can be found here. A test demonstrating different walking strategies may also provide you with some help Edit: A thread in the libgit2 mailing list specifically deals with