We were unable to load Disqus. If you are a moderator please see our troubleshooting guide.

Stefan Gumhold • 2 years ago

Hi Nathan, thanks a lot for providing the python script. I would love to use but get a python syntax error in line 85 on the ":=" syntax:

git-partial-submodule.py add https://github.com/nlohmann... 3rd
File "D:\develop\projects\git\testsparse\git-partial-submodule.py", line 85
if m := re.match(r'git version (\d+)\.(\d+)\.(\d+)', ReadGitOutput('--version')):
^
SyntaxError: invalid syntax

I use python 3.11.1.0 in a portable windows version and am not familiar with python.

Any help is highly appriciated.

Stefan

Nathan Reed • 2 years ago

Hi Stefan, sorry, no idea. The ":=" syntax was added in Python 3.8. It works for me under Python 3.11.2. I'd double check that the script has not gotten corrupted somehow when you downloaded it.

Stefan Gumhold • 2 years ago

Thanks for checking. Windows command prompt called some older version of python on my installation. Prefixing the call with python now works.
I had to figure out how to use the script as it was not clear that you first have to clone the project non-recursively first and then, from within the project, call git-sparse-submodule.py clone.
I first tried to clone the whole project with your script. I also misunderstood your statement "When cloning a repository with existing submodules, you use git-partial-submodule.py clone instead of recursively cloning or git submodule update --init." because I thought that "git submodule update --init" would also work. Maybe you change the "or" to "nor" to avoid confusion.
But now it works for my test project to have a sparse submodule just checking out "nlohmann/include" from nlohmann json.
It is a pity that the unsupported submodule updates do stall what might cause confusion if you have a larger user base.
Hope to see your script to be integrated into git soon.