libgit2 / libgit2/pygit2

update_submodules duplicates

Open
#792 6 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
1.7k
Forks
408
Avg merge
2d 57m
Merged PRs (30d)
7

Description

I'm trying to replicate git clone --recursive in pygit2, and this is the function I've come up with.

def get_submodules(repo, creds):
    submodules = repo.listall_submodules()
    repo.init_submodules(submodules=submodules)
    repo.update_submodules(submodules=submodules, callbacks=creds)
    for submodule_path in submodules:
        submodule = repo.lookup_submodule(submodule_path)
        sub_repo = submodule.open()
        get_submodules(sub_repo, creds)

The problem I'm having is that in certain circumstances, this will cause crashes. Let me paint the picture.

Master Repo

  1. Submodule A
  2. Submodule B
    2.1 Submodule A
    2.2 Submodule D
  3. Submodule C

When update_submodules attempts to run on Submodule A the second time, it crashes. Not completely sure how to get around this. Some repos are in this format, but I haven't found a workaround. Any thoughts?

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 with the get_submodules example and the repo.update_submodules and repo.lookup_submodule calls. Reproduce the nested layout where Submodule A appears more than once, then inspect how repeated updates are handled. Done means the recursive operation no longer crashes for that layout, with the behavior verified against the reported scenario.

Written by the indexing model from the issue text.

Assessment

Tech stack
git, python
Domain
tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
32/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.