diff options
author | Yobmod <yobmod@gmail.com> | 2021-07-06 15:09:36 +0100 |
---|---|---|
committer | Yobmod <yobmod@gmail.com> | 2021-07-06 15:09:36 +0100 |
commit | 278a3713a0a560cbc5b1515c86f8852cd3119e6b (patch) | |
tree | 9316d490ef57f3e10900c3230376f70c5f1c3afd /git/objects/submodule/base.py | |
parent | 1bcccd55e78d1412903c2af59ccc895cca85e153 (diff) | |
download | gitpython-278a3713a0a560cbc5b1515c86f8852cd3119e6b.tar.gz |
Fix for mrepo
Diffstat (limited to 'git/objects/submodule/base.py')
-rw-r--r-- | git/objects/submodule/base.py | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/git/objects/submodule/base.py b/git/objects/submodule/base.py index 2ace1f03..53e89dba 100644 --- a/git/objects/submodule/base.py +++ b/git/objects/submodule/base.py @@ -418,7 +418,7 @@ class Submodule(IndexObject, TraversableIterableObj): # END check url # END verify urls match - # mrepo: Union[Repo, None] = None + mrepo: Union[Repo, None] = None if url is None: if not has_module: @@ -474,7 +474,8 @@ class Submodule(IndexObject, TraversableIterableObj): sm._branch_path = br.path # we deliberately assume that our head matches our index ! - sm.binsha = mrepo.head.commit.binsha + if mrepo is not None: + sm.binsha = mrepo.head.commit.binsha index.add([sm], write=True) return sm @@ -589,8 +590,8 @@ class Submodule(IndexObject, TraversableIterableObj): if not dry_run: # see whether we have a valid branch to checkout try: - # assert isinstance(mrepo, Repo) # cant do this cos of circular import - mrepo = cast('Repo', mrepo) # Try TypeGuard wirh hasattr? + # assert isinstance(mrepo, Repo) # cant do this cos of circular import + mrepo = cast('Repo', mrepo) # Try TypeGuard wirh hasattr, or has_remotes&_head protocol? # find a remote which has our branch - we try to be flexible remote_branch = find_first_remote_branch(mrepo.remotes, self.branch_name) local_branch = mkhead(mrepo, self.branch_path) |