summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJJ Graham <thetwoj@gmail.com>2019-10-20 15:40:06 -0500
committerSebastian Thiel <sebastian.thiel@icloud.com>2019-10-21 13:10:28 +0200
commitb303cb0c5995bf9c74db34a8082cdf5258c250fe (patch)
tree4c5c0a42b1f45e10dd2737eb787a30f417410dec
parent6fd090293792884f5a0d05f69109da1c970c3cab (diff)
downloadgitpython-b303cb0c5995bf9c74db34a8082cdf5258c250fe.tar.gz
Initial stab at fixing diffs involving submodule changes
-rw-r--r--git/cmd.py2
-rw-r--r--git/diff.py8
2 files changed, 9 insertions, 1 deletions
diff --git a/git/cmd.py b/git/cmd.py
index 78319c75..263c8ba7 100644
--- a/git/cmd.py
+++ b/git/cmd.py
@@ -67,7 +67,7 @@ __all__ = ('Git',)
def handle_process_output(process, stdout_handler, stderr_handler,
finalizer=None, decode_streams=True):
- """Registers for notifications to lean that process output is ready to read, and dispatches lines to
+ """Registers for notifications to learn that process output is ready to read, and dispatches lines to
the respective line handlers.
This function returns once the finalizer returns
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: