libgit2sharp icon indicating copy to clipboard operation
libgit2sharp copied to clipboard

Commands.Stage() fails with a submodule

Open jminer opened this issue 4 years ago • 0 comments

Reproduction steps

  1. Add a submodule to a Git repository like git submodule add ../test-module test-module
  2. Change the commit of the submodule like cd test-module; git checkout -b branch-name
  3. Try to stage the submodule using libgit2sharp with Commands.Stage("*") or with Commands.Stage("test-module")

Expected behavior

The submodule change should be staged.

Actual behavior

An exception is thrown because git_index_add_bypath() failed because the path is invalid: test-module/

Commands.Stage() adds a slash at the end of the submodule name it passes to git_index_add_bypath which causes it to fail. git_index_add_bypath works fine passing it test-module directly with repo.Index.Add("test-module") (which is a workaround I'll use for now).

Version of LibGit2Sharp (release number or SHA1)

LibGit2Sharp 0.26.2

Operating system(s) tested; .NET runtime tested

.NET Framework 4.7.2 on Windows 10

jminer avatar Apr 13 '21 16:04 jminer