libgit2

Find out the branch a commit belongs to in LibGit2Sharp?

此生再无相见时 提交于 2020-01-13 12:25:22
问题 I am looping through commits in LibGit2Sharp : Repository repo = new Repository("Z:/www/gg"); foreach (LibGit2Sharp.Commit commit in repo.Commits) { ... } I can retrieve properties like Author and Message , but I do not see anything about what branch it belongs to? Ideally I would like to have a pointer to the branch object, but even a name would be fine in this scenario. This is what the debugger shows up: This is what I am looking for: TortoiseGit's behavior of showing the most relevant

how can i use rugged to create and commit a file like from the command line?

这一生的挚爱 提交于 2020-01-13 05:56:29
问题 i'm trying to use rugged to do something pretty simple: create and commit a file, leaving the repository in the same state as doing: git init echo "blah blah blah" > blah.txt git add blah.txt git commit -m "write blah.txt" which leaves git status printing On branch master nothing to commit, working directory clean i'm using code adapted from the rugged repo's readme, which boils down to: name = "blah.txt" repo = Rugged::Repository.init_at dir File.open File.join(dir, name), 'w' do |f| f.write

How to switch to specified version

有些话、适合烂在心里 提交于 2020-01-07 02:55:09
问题 I want to switch my cloned repository to some specified version. When I run this code, its not working as I want. It realizes how many commits am I behind or above master, but it doesn't really switch the project. For example, if I have version 1.0 with some txt document included, and version 1.1 without this txt document. Master is pointing to version 1.1 First I clone the whole repository, (destination folder doesn't contain txt document). Then I perform this code and I want the txt

Libgit2Sharp: get files in all commits between two tags

被刻印的时光 ゝ 提交于 2020-01-06 02:55:06
问题 I can do this in GitBash: $ git diff --name-only v01...HEAD -- *.sql which gives: Components/1/Database/Stored Procedures/spDC1.sql Components/1/Database/Stored Procedures/spDC2.sql I can't see how I would do this in LibGit2Sharp. Any ideas? Thanks 回答1: Here is an example from one of my projects that get a ICommitLog collection between two commits (current HEAD vs. the master branch): // git log HEAD..master --reverse public ICommitLog StalkerList { get { var filter = new CommitFilter {

libgit2 (fetch & merge & commit)

拈花ヽ惹草 提交于 2020-01-04 04:44:06
问题 I 'm trying to pull from a repo with libgit2. My steps are these: git_remote_connect - OK git_remote_download or should I use git_remote_fetch ? git_remote_ls to get the of the HEAD to pass to git_annotated_commit_from_fetchhead (is this coorect?). But there are more than 1 heads, do I pass the one with "HEAD" name? git_merge. This results in MERGE_HEAD in .git folder and then I am able to merge with an existing commit. The question is, is the above sequence correct? Why git creates FETCH

Implementing Pull with Pygit2

邮差的信 提交于 2020-01-04 04:08:05
问题 I am trying to implement some 'porcelain' commands using pygit2. It seems that I have run into a bit of road block while implementing pull. Specifically the easiest pull case, a fast forward. Setup: I have two git repos. One 'remote' and one 'local'. I make one commit on the remote repo and then create the local repo using pygit2's clone_repository() . I make a subsequent commit on the remote and then attempt to run the pull() function outlined below. My implementation: def pull(repo, remote

How do I build a version tree for a Git repository using LibGit2(Sharp)

江枫思渺然 提交于 2020-01-04 02:38:06
问题 Some background: I'm looking at the possibility of using Git as a data storage layer. Basically I need to keep all versions of some XML files which describe application state. The users needs a "Time Machine" to be able to revert to previous states, as well as branch off previous states etc. This will be hidden behind a service layer, but I am looking at using Git at the back end. I need to present the evolution of the application's state over time, so I want to build a network diagram

“git log -1 fullpath/myfile” with libgit2

橙三吉。 提交于 2020-01-02 23:44:12
问题 I want to implement git log -1 fullpath/myfile with libgit2. I am fairly new to libgit2. Am I on the right track? This is what I have so far: git_repository_head(&refToHead, repo); headOID = git_reference_oid(refToHead); git_commit_lookup(&headCommit, repo, headOID); headTreeOID = git_commit_tree_oid(headCommit); git_tree_lookup(&tree, repo, headTreeOID); git_tree_entry_byname(tree, "repopath/myfile"); Unfortunately git_tree_entry_byname seems not to work for files in subdirectories of the

How to clone/fetch a git repository with libgit2?

…衆ロ難τιáo~ 提交于 2020-01-02 07:14:10
问题 I need to initialize a git repository and fetch the latest version of a branch into it. In bash, the commands are: git init git remote add -t $BRANCH -f origin $REMOTE I'm trying to do the same programmatically with libgit2, but am having trouble finding the equivalent for the second line. The calls to create a remote are apparent, but I'm not seeing any to add it to a repository or handle the branch. Is it possible to do this with libgit2? If not, is there a library capable of doing this?

libgit2 returned: Refspec 'refs/heads/origin/HEAD' not found error in TortoiseGit

对着背影说爱祢 提交于 2020-01-01 07:59:47
问题 I got this error when starting up TortoiseGit: Could not get all refs. libgit2 returned: Refspec 'refs/heads/origin/HEAD' not found While annoying, it does not prevent me from using TortoiseGit. However, I'd like to make it go away, because it is, well, annoying . How do I fix this? 回答1: Updated Answer So it turns out that, for the purpose of updating a local repo's view of which branch <remote>/HEAD points to, you can have git automatically fetch that information from the remote and set it