Skip to content

Can pr_*() functions be made to work better in the presence of git submodules? #2235

@jennybc

Description

@jennybc

usethis uses gert and gert uses libgit2 and libgit2 hasn't fully implemented submodule support, i.e.g libgit2 tends to silently skip the submodule work you expect and want when doing high-level tasks like fetch, branch checkout, or merge. This is despite the fact that I have submodule.recurse = true in my global git config. libgit2 just doesn't really honor that the way command line git does.

I think this is why the pr_*() functions sometimes leave me in an undesirable state when working in a repo that uses submodules, e.g. positron. For example, when a pr_*() function checks out a different branch, the submodule working tree gets left in whatever state it was in before. Then git sees the submodule HEAD as dirty/modified, which cascades into confusing status output that I have to manually resolve.

I think what we'd want is this command line equivalent:

git submodule update --init --recursive

gert does have some functionality around submodules: https://docs.ropensci.org/gert/reference/git_submodule.html. But I'm sure it's still fundamentally limited by what libgit2 supports (see r-lib/gert#165).

Is there anything to be done about this here? 🤔

Metadata

Metadata

Assignees

No one assigned

    Labels

    gitgit, GitHub, and CI in general

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions