GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — submodule update doesn't work with relative submodule paths (in GitPython 2.1.14) · Issue #944 · gitpython-developers/GitPython

submodule update doesn't work with relative submodule paths (in GitPython 2.1.14) #944

New issue
Copy link
New issue
Copy link
Closed
#2062
Closed
submodule update doesn't work with relative submodule paths (in GitPython 2.1.14)#944
#2062
Copy link
Labels
acknowledgedhelp wanted

Description

@Genovese-martijn
Genovese-martijn
opened on Oct 18, 2019
Issue body actions

When using the git.objects.submodules.base.Submodule.update method (https://gitpython.readthedocs.io/en/stable/reference.html#git.objects.submodule.base.Submodule.update), the git python module seems to fake a git submodule call with git clone. It executes git clone -n --separate-git-dir=<workspace>/.git/modules/<submodule_path> -v <submodule_url> <workspace>/<submodule_path>. This command doesn't work when a submodule is specified as a relative path in the .gitmodules path. For example:

[submodule "main_project/submodule"]
  path = main_project/submodule
  url = ../../other_project/some_module.git

The git.objects.submodules.base.Submodule.update then fails with `repository '../../other_project/some_module.git' does not exist.

The regular git submodule command is able to resolve the paths.

Activity

  1. Byron
    added
    acknowledged
    waiting for feedback
    and removed
    acknowledged
    on Oct 19, 2019
  2. Byron commented on Oct 19, 2019

    @Byron
    Byron
    on Oct 19, 2019
    Member
    More actions

    Thanks for posting. Which version of GitPython are you using?

    Even though the submodule implementation may not be up to date with what git produces, I remember that some improvements were made in the past which might resolve this issue.

  3. Genovese-martijn commented on Oct 21, 2019

    @Genovese-martijn
    Genovese-martijn
    on Oct 21, 2019
    Author
    More actions

    Thanks for the feedback, I am using version 2.1.14 due to external python2 requirement. The issue is indeed resolved when using version 3.0.3.

    Reacted by Sebastian Thiel
  4. Byron
    changed the title [-]submodule update doesn't work with relative submodule paths[/-] [+]submodule update doesn't work with relative submodule paths (in GitPython 2.1.14)[/+] on Oct 21, 2019
  5. Byron
    added
    wont fix
    and removed
    waiting for feedback
    on Oct 21, 2019
  6. Byron commented on Oct 21, 2019

    @Byron
    Byron
    on Oct 21, 2019
    Member
    More actions

    Thanks for your reply! I am closing this issue as it is already resolved.

    Interestingly, in the last released version of GitPython with Python 2 compatibility, the submodule improvements should already be present. If you can spot the difference, I would be happy to receive a PR against 2.1.14 that fixes the issue there as well and release 2.1.15.

  7. Genovese-martijn commented on Oct 21, 2019

    @Genovese-martijn
    Genovese-martijn
    on Oct 21, 2019
    Author
    More actions

    Sorry, I made a mistake in my setup while I was testing it with python3 and git python version 3.0.3. On version 3.0.3 the relative submodule paths also does not work

    Reacted by Sebastian Thiel
  8. Byron
    added
    acknowledged
    help wanted
    and removed
    wont fix
    on Oct 21, 2019
  9. Ferenc- commented on Jan 16, 2020

    @Ferenc-
    Ferenc-
    on Jan 16, 2020
    More actions

    This bug is still present in 3.0.5 any chance to increase priority?

    Reacted by Nagy Vilmos
  10. Byron commented on Feb 8, 2020

    @Byron
    Byron
    on Feb 8, 2020
    Member
    More actions

    I am afraid there is no priority beyond what people decide to contribute. GitPython is in maintenance mode.

  11. Genovese-martijn commented on Feb 11, 2020

    @Genovese-martijn
    Genovese-martijn
    on Feb 11, 2020
    Author
    More actions

    When looking trough other issues, I think this issue is the same as issue 730. Is there any reason why gitpython doesn't use the "native" git submodule calls?

  12. Byron commented on Feb 12, 2020

    @Byron
    Byron
    on Feb 12, 2020
    Member
    More actions

    If memory serves, back in the days I wanted to have 'smart' submodules, that are easier to handle and to update. For that, a lot of additional logic was added to what constitutes a very own implementation, compatible to git-submodules. In retrospect that turned out to be coming with maintenance costs that are now unaffordable.

    Luckily, users can always workaround themselves by using repo.git.submodule(…), which may be enough for most usecases.

  13. BlackFIlms commented on Oct 14, 2021

    @BlackFIlms
    BlackFIlms
    on Oct 14, 2021
    More actions

    I have same trouble.
    I written the 'relatives' class, and this class can supply full URL, from origin + relative path to submodule.
    But how i can replace path to submodule in Repo object directly?

  14. Byron commented on Oct 14, 2021

    @Byron
    Byron
    on Oct 14, 2021
    Member
    More actions

    But how i can replace path to submodule in Repo object directly?

    Due to its nature, it is probably read-only. More details could be provided if there is more information on what's you are trying to do and how it's done.

  15. atomar94 commented on Feb 17, 2022

    @atomar94
    atomar94
    on Feb 17, 2022
    More actions

    My Workaround

    I was able to update my relative submodules with:

    repo.git.execute(command=['git', 'submodule', 'update', '--init', '--recursive'])

    Docs: https://gitpython.readthedocs.io/en/stable/reference.html#git.cmd.Git.execute

    GitPython 3.1.26, Python 3.8.10

    Reacted by Nagy Vilmos
  16. Byron commented on Feb 18, 2022

    @Byron
    Byron
    on Feb 18, 2022
    Member
    More actions

    Thanks for sharing. This can probably be rewritten to repo.git.submodule('update', init=True, recursive=True), giving it a bit of an edge over calling popen entirely by hand.

  17. yvatyan commented on Mar 14, 2022

    @yvatyan
    yvatyan
    on Mar 14, 2022
    More actions

    I wasn't able to make it work neither with
    repo.submodule_update(init=True, recursive=True)
    nor
    repo.git.submodule('update', init=True, recursive=True)
    The latter is due to derivation to wrong git command cmdline: git submodule --init --recursive update

    #944 (comment) solution worked for me.

    Git: 2.25.1
    GitPython: 3.1.27
    Python: 3.8.10

    Reacted by Sebastian Thiel and hudecekd
  18. Byron commented on Mar 15, 2022

    @Byron
    Byron
    on Mar 15, 2022
    Member
    More actions

    Thanks for letting us know.

    I think the takeaway here is that one should avoid GitPython submodules in favor of using reop.git.submodule(…), which uses the git program as one would on the command-line.

  19. Byron
    closed this as completedin #2062on Jul 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    acknowledgedhelp wanted

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402503 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.