libgit2 / libgit2sharp

Git + .NET = ❤
http://libgit2.github.com
MIT License
3.21k stars 889 forks source link

Add submodule changes to index #220

Closed haacked closed 11 years ago

haacked commented 12 years ago

Copied from my accidental submission to the libgit2 repo

I know that @arrbee added support for git_submodule_add_to_index to LibGit2. Ideally, this simply works as part of the existing Index.Stage command, if possible.

That way, something like this would Just Work™ for a repository that has a submodule in the root named MySubmodule:

using (var libGitRepo = new Repository("@c:\path-to-my-repo\.git")) {
    libGitRepo.Index.Stage(new [] 
        { "file1.txt", "MySubmodule", "AnotherFile.md" });
}
haacked commented 12 years ago

Just to provide more info, the way GHfW gets the list of files to stage today is we parse the output of:

git status --untracked-files=all --porcelain -z

Then we build an array and call libGitRepo.Index.Stage one each. Today, this fails when one of the changes reported by status is a submodule that's been updated.

Ideally, we wouldn't have to shell out at all to do this. :)

haacked commented 12 years ago

Any updates on this?

dahlbyk commented 12 years ago

I've started playing around with submodules a bit in the context of libgit2/libgit2#756... if nobody else is working on it, I can see about tackling this first.

Out of curiosity, what's missing from RepositoryStatus such that you need to shell out to git.git?

haacked commented 12 years ago

Apparently the thing that's missing is my knowledge that it's been implemented! ;)

The code to grab the status was written before I joined and we probably didn't think to upgrade it to use RepositoryStatus. Good to know it's there!

haacked commented 11 years ago

Any updates on this?

dahlbyk commented 11 years ago

I have some of the native submodule bindings done locally, but not much else.

dahlbyk commented 11 years ago

In the context of #274 it probably makes sense to wait for the updated Stage() implementation.