Description
On Windows, If you try to push a repository that contains a deep nesting of submodules you can get a "BadName: Ref 'HEAD' did not resolve to an object" when GitPython tries to assemble the path that contains the git dir for the submodule.
A concrete example is the submodule path
C:\git\vsm-utilities\vsm-helper\csdieinfo\host_py_rm_pdb_internal\host_py_rm_pdb_internal_efr32x21x000f1024xm32_secpu
that has a .git
file containing
gitdir: ../../../../.git/modules/vsm-helper/modules/csdieinfo/modules/host_py_rm_pdb_internal/modules/host_py_rm_pdb_internal_efr32x21x000f1024xm32_secpu
In find_submodule_git_dir() in fun.py, the path to the git dir is assembled by using os.path.join, which results in a very long path. In fact, os.path.isdir() returns False for this long path, even though the path length in absolute terms is under the size limit. But because the path contains relative designators, the path length is too long for os.path.isdir() to handle and thus it returns False.
I found that calling os.path.normpath() on the long path would normalize the path to return a path that os.path.isdir() recognizes as a real directory and would fix the problem.