Skip to content

How to upgrade libgit2 binaries

Therzok edited this page Sep 20, 2014 · 3 revisions

The goal of this howto is to explain how to upgrade the libgit2 binaries used by LibGit2Sharp, and to make a pull request that will hopefully get merged.

Prerequisites:

  • Visual Studio 2010 SP1 or 2012, with VC++
  • CMake 2.8.11
  • git 1.8.1+
  • 64-Bit Visual C++ Toolset (also available as part of the Windows SDK)
  • Powershell
  • a clone/fork of LibGit2Sharp on your machine

Step 1: Create a new working branch

Can be done with GitExtensions

Create a new branch with upstream/vNext as a starting point. Give it a meaningful name (e.g.: topic/upgrade-binaries).

> git checkout --no-track -b topic/upgrade-binaries upstream/vNext

Step 2: Update libgit2 submodule

Can be done with GitExtensions

  • Open up Powershell, and cd to your libgit2sharp directory.
  • Go in the libgit2 submodule folder:
    > cd libgit2
  • Fetch last changes committed to libgit2:
    > git fetch
  • Checkout the revision you are interested in (usually the latest one):
    > git checkout 99a9c86
  • Go back to the main LibGit2Sharp folder:
    > cd ..

Step 3: Build libgit2

  • Open a PowerShell prompt.

    It has been reported that depending on your configuration, you may have to open it with the Run as administrator command so that the VC++ compiler is correctly recognized. This can usually be fixed by reinstalling the Windows SDK.

  • Navigate to the main LibGit2Sharp folder, and run the script:
    .\UpdateLibGit2ToSha.ps1 99a9c86 (or the sha you found above)

    By default, the script will try to build libgit2 using the Visual Studio 2010 VC++ compiler. If you only have the Visual Studio 2012 VC++ compiler available, use the following syntax:
    > .\UpdateLibGit2ToSha.ps1 -vs 11 99a9c86

Step 4: Fix the bindings

Open libgit2sharp.sln in Visual Studio, and make sure all the projects are building with no errors and that all tests are passing.

Fixes to apply usually include:

  • Updating the bindings (functions signatures modifications, enums new/modified values ...)
  • Fixing the LibGit2Sharp code to work with the new version of libgit2
  • Fixing the the actual unit tests if they were leveraging a libgit2 functionality in an unexpected way

Step 5: Commit time baby!

Can be done with GitExtensions

Commit all your changes with the following commit message:

Update libgit2 binaries to 99a9c86

https://github.com/libgit2/libgit2/compare/bd67979...99a9c86

Make sure to use the correct short shas. Please note that the first sha to use in the compare URL is the sha of the libgit2 revision which was used before your modification. You can get it by looking at the diff of the LibGit2Sharp/libgit2_hash.txt file which was modified in Step 3.

The list of files present in your commit should at least include:

  • Deleted: Lib/NativeBinaries/amd64/git2-bd67979.dll
  • Deleted: Lib/NativeBinaries/amd64/git2-bd67979.pdb
  • Deleted: Lib/NativeBinaries/x86/git2-bd67979.dll
  • Deleted: Lib/NativeBinaries/x86/git2-bd67979.pdb
  • Modified: nuget.package/build/LibGit2Sharp.props
  • Modified: LibGit2Sharp/Core/NativeDllName.cs
  • Modified: LibGit2Sharp/libgit2_hash.txt
  • Modified: libgit2
  • Added: Lib/NativeBinaries/amd64/git2-99a9c86.dll
  • Added: Lib/NativeBinaries/amd64/git2-99a9c86.pdb
  • Added: Lib/NativeBinaries/x86/git2-99a9c86.dll
  • Added: Lib/NativeBinaries/x86/git2-99a9c86.pdb

Step 6: Create the Pull Request

Can be done with GitExtensions

Push, and create the pull request!