libgit2 / libgit2/libgit2sharp

Commands.Stage() fails with a submodule

Open
#1,877 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C#
Stars
3.5k
Forks
925
PR merge metrics
No merged PRs in 30d

Description

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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.