Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Request support for the git_submodule_branch() API #1301

Open
ming4883 opened this issue Apr 13, 2016 · 4 comments
Open

Request support for the git_submodule_branch() API #1301

ming4883 opened this issue Apr 13, 2016 · 4 comments

Comments

@ming4883
Copy link

Please support the git_submodule_branch() API, so that the branch attributes inside ".gitmodules" can be retrieved.

Information about the API:
https://libgit2.github.com/libgit2/#HEAD/group/submodule/git_submodule_branch

Thanks

@metri
Copy link

metri commented Jul 26, 2016

Hi!
Is there any motion on this issue?

@ethomson
Copy link
Member

Not yet! We'd welcome a pull request if this is something that you're interested in! 😀

@rgl
Copy link

rgl commented Dec 22, 2016

is Repository.Submodules bound to a specific branch (e.g. to the current checked out branch)? if so, how can I get the submodules of other branches? do we need to have git_submodule_branch supported? how would that work?

currently, I'm traversing the tree looking for GitLink objects and resorting to manual parsing the .gitmodules files. I think this is something that should be provided out-of-the-box by libgit2sharp. if you point me to the right direction, I'm willing to contribute a PR.

@ming4883
Copy link
Author

Since .gitmodules is using the standard git config file format, I parse this file using the built-in Configuration.BuildFrom().

    // using GitLib = LibGit2Sharp;
    var _cfg = GitLib.Configuration.BuildFrom(_pathToGitModules);
    foreach (var _c in _cfg)
    {
        if (_c.Level != GitLib.ConfigurationLevel.Local) // ignore any global and system config
            continue;
        string[] _keys = _c.Key.Split(new char[] { '.' });
        if (string.Compare(_keys[0], "submodule") != 0 || _keys.Length < 3)
            continue;
        // where _keys[1] is the submodule name
        // _keys[2] is the key to the submodule value
        // _c.Value is the value
        Dictionary<string, string> _submod = GetSubModuleByName(_keys[1]);
        _submod[_keys[2]] = _c.Value;
    }

Hope this helps.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants