libgit2 / libgit2/libgit2sharp
Commands.Stage() fails with a submodule
Nobody has claimed this yet.
- Dominant language
- C#
- Stars
- 3.5k
- Forks
- 925
- PR merge metrics
- No merged PRs in 30d
Description
Reproduction steps
- Add a submodule to a Git repository like
git submodule add ../test-module test-module - Change the commit of the submodule like
cd test-module; git checkout -b branch-name - Try to stage the submodule using libgit2sharp with
Commands.Stage("*")or withCommands.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
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at the Commands.Stage entry point and reproduce the submodule case described with Commands.Stage("*") and Commands.Stage("test-module"). Compare its path handling with repo.Index.Add("test-module"), which is reported as a workaround. Done means staging the changed submodule without the trailing-slash path error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp, git
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 45/100