GitPython icon indicating copy to clipboard operation
GitPython copied to clipboard

`repo.submodule('sort')` returns reference to IterableList.sort() method, not Submodule instance

Open ryan-williams opened this issue 5 years ago • 1 comments

Check out toy example repo w/ 2 submodules (named generate-random-ints and sort):

git clone --recurse-submodules https://gitlab.com/gsmo/examples/submodule-demo.git
cd submodule-demo
git checkout e6f6d8f
git submodule update
python

In Python REPL:

import git
repo = git.Repo()
repo.submodule('sort')
# <built-in method sort of IterableList object at 0x1058a7360>
repo.submodule('generate-random-ints')
# git.Submodule(name=generate-random-ints, path=generate-random-ints, url=https://gitlab.com/gsmo/examples/submodules/generate-random-ints.git, branch_path=refs/heads/master)

The submodule named sort can't be retrieved, as its name is shadowed by the IterableList.sort method.

ryan-williams avatar Nov 26 '20 15:11 ryan-williams

Thanks a lot for taking the time to illustrate the issue and for making it reproducible!

It looks like in order to fix this, one would have to fix the indexex access of IterableList to make this kind of code work across the board. As these are used in many places, similar issues would be present in other places, too. References come to mind.

Byron avatar Nov 27 '20 01:11 Byron