From 50f763cfe38a1d69a3a04e41a36741545885f1d8 Mon Sep 17 00:00:00 2001 From: "James E. Blair" Date: Mon, 2 Mar 2015 09:25:27 -0800 Subject: Store path attribute on Diff object If a file in a commit contains no changes (for example, if only the file mode is changed) there will be no blob attached. This is usually where the filename is stored, so without it, the calling context can not tell what file was changed. Instead, always store a_path and b_path on the Diff object so that information is available. --- git/diff.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'git/diff.py') diff --git a/git/diff.py b/git/diff.py index 37882369..dc53f3f7 100644 --- a/git/diff.py +++ b/git/diff.py @@ -168,11 +168,13 @@ class Diff(object): a_mode is None a_blob is None + a_path is None ``Deleted File``:: b_mode is None b_blob is None + b_path is None ``Working Tree Blobs`` @@ -200,8 +202,8 @@ class Diff(object): NULL_HEX_SHA = "0" * 40 NULL_BIN_SHA = b"\0" * 20 - __slots__ = ("a_blob", "b_blob", "a_mode", "b_mode", "new_file", "deleted_file", - "rename_from", "rename_to", "diff") + __slots__ = ("a_blob", "b_blob", "a_mode", "b_mode", "a_path", "b_path", + "new_file", "deleted_file", "rename_from", "rename_to", "diff") def __init__(self, repo, a_path, b_path, a_blob_id, b_blob_id, a_mode, b_mode, new_file, deleted_file, rename_from, @@ -210,6 +212,9 @@ class Diff(object): self.a_mode = a_mode self.b_mode = b_mode + self.a_path = a_path + self.b_path = b_path + if self.a_mode: self.a_mode = mode_str_to_int(self.a_mode) if self.b_mode: -- cgit v1.2.1