Git Checkout and Pull through Lib2GitSharp

I am trying to build an application that periodically scans the commit history on various Git branches and reports on the authors and various details about the commit messages. I have started using LibGit2Sharp for this. It has been great for accessing the commits themselves, but I have run into a snag when trying to update the repository.

Every time my task runs, I need to get the most recent changes from the remote repository. My understanding is I need to checkout the local branch that tracks the remote branch in question, then perform a fetch or pull. I am attempting to do this in my app as follows:

  • AnkhSVN keeps marking .designer.cs files as newly added
  • How to use libgit2sharp to create a new branch from local to remote?
  • Finding past revisions of files in StarTeam w/ .NET SDK / C#
  • Error encountered while pushing to the remote Git repository
  • git and C++ workflow, how to handle object and archive files?
  • how to include git commit-number into a c++ executable?
  • // Get the branch
    var localBranch = repo.Branches[localbranchName];
    
    // Switch to this branch
    if (!localBranch.IsCurrentRepositoryHead)
    {
        repo.Checkout(localBranch);
    }
    
    // Do a pull to get latest
    var result = repo.Network.Pull(signature, new PullOptions());
    

    However, I always get the following exception when running repo.Checkout(localBranch);

    LibGit2Sharp.LibGit2SharpException: Failed to mmap. No data written: Not enough storage is available to process this command.
      at LibGit2Sharp.Core.Ensure.HandleError(Int32 result) in c:\Git\libgit2sharp\LibGit2Sharp\Core\Ensure.cs:line 160
      at LibGit2Sharp.Core.Ensure.ZeroResult(Int32 result) in c:\Git\libgit2sharp\LibGit2Sharp\Core\Ensure.cs:line 178
      at LibGit2Sharp.Core.Proxy.git_checkout_tree(RepositorySafeHandle repo, ObjectId treeId, GitCheckoutOpts& opts) in c:\Git\libgit2sharp\LibGit2Sharp\Core\Proxy.cs:line 295
      at LibGit2Sharp.Repository.CheckoutTree(Tree tree, IList`1 paths, IConvertableToGitCheckoutOpts opts)...
    

    When I manually checkout that branch in Git Bash and run my program (bypassing the need for the the checkout command) it then fails on the call to Pull with the same exception.

    There’s not a whole lot about this error out there but everything I’ve seen so far has resulted in answers to the extent of “Your repository is just too large for the library to handle.” The repository I am using is a fair-sized enterprise repository, but these commands execute in the console pretty quickly. I’m wondering now if I need to wrap my console in a handler and execute the checkout and pull directly through the CLI (yuck).

    Any thoughts?

  • In XCode 4 how do I add a remote GitHub repository to an existing local project?
  • Ignoring specific files, file types or folders in a pull request diff
  • git diff - show only what's new on the remote
  • Jenkins Git Branch Selection with Fallback
  • How does Git know that file was renamed?
  • Can you explain what “git reset” does in plain english?
  • One Solution collect form web for “Git Checkout and Pull through Lib2GitSharp”

    Apologies for this. There have been a handful of changes to libgit2 and LibGit2Sharp to deal with memory usage, and better handling of memory mapping, especially with large (or numerous) packfiles.

    You will see these improvements in the next release of LibGit2Sharp. Until then, installing a prerelease package from nuget.org should resolve this issue.

    Git Baby is a git and github fan, let's start git clone.