From b303cb0c5995bf9c74db34a8082cdf5258c250fe Mon Sep 17 00:00:00 2001 From: JJ Graham Date: Sun, 20 Oct 2019 15:40:06 -0500 Subject: Initial stab at fixing diffs involving submodule changes --- git/diff.py | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'git/diff.py') diff --git a/git/diff.py b/git/diff.py index 0150d675..3dbe0866 100644 --- a/git/diff.py +++ b/git/diff.py @@ -278,6 +278,14 @@ class Diff(object): if self.b_mode: self.b_mode = mode_str_to_int(self.b_mode) + # Determine whether this diff references a submodule, if it does then + # we need to overwrite "repo" to the corresponding submodule's repo instead + if repo and a_rawpath: + for submodule in repo.submodules: + if submodule.path == a_rawpath.decode("utf-8"): + repo = submodule.module() + break + if a_blob_id is None or a_blob_id == self.NULL_HEX_SHA: self.a_blob = None else: -- cgit v1.2.1