Skip to content

Fix how Diff handles commits that contain submodule changes #947

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Oct 21, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Initial stab at fixing diffs involving submodule changes
  • Loading branch information
thetwoj committed Oct 20, 2019
commit 862cba85dd14ae3b9667c9418f8feebd6bdca939
2 changes: 1 addition & 1 deletion git/cmd.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@

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

Expand Down
8 changes: 8 additions & 0 deletions git/diff.py
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,14 @@ def __init__(self, repo, a_rawpath, b_rawpath, a_blob_id, b_blob_id, a_mode,
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:
Expand Down