summaryrefslogtreecommitdiff
path: root/lib/git
diff options
context:
space:
mode:
Diffstat (limited to 'lib/git')
-rw-r--r--lib/git/commit.py4
-rw-r--r--lib/git/diff.py11
2 files changed, 10 insertions, 5 deletions
diff --git a/lib/git/commit.py b/lib/git/commit.py
index 4aee1280..e35090a1 100644
--- a/lib/git/commit.py
+++ b/lib/git/commit.py
@@ -204,13 +204,13 @@ class Commit(LazyMixin):
if b:
paths.insert(0, b)
paths.insert(0, a)
- text = repo.git.diff(full_index=True, *paths)
+ text = repo.git.diff('-M', full_index=True, *paths)
return diff.Diff.list_from_string(repo, text)
@property
def diffs(self):
if not self.parents:
- d = self.repo.git.show(self.id, full_index=True, pretty='raw')
+ d = self.repo.git.show(self.id, '-M', full_index=True, pretty='raw')
if re.search(r'diff --git a', d):
if not re.search(r'^diff --git a', d):
p = re.compile(r'.+?(diff --git a)', re.MULTILINE | re.DOTALL)
diff --git a/lib/git/diff.py b/lib/git/diff.py
index 626c4df9..7a6770c4 100644
--- a/lib/git/diff.py
+++ b/lib/git/diff.py
@@ -12,7 +12,9 @@ class Diff(object):
A Diff contains diff information between two commits.
"""
- def __init__(self, repo, a_path, b_path, a_commit, b_commit, a_mode, b_mode, new_file, deleted_file, diff):
+ def __init__(self, repo, a_path, b_path, a_commit, b_commit, a_mode,
+ b_mode, new_file, deleted_file, rename_from,
+ rename_to, diff):
self.repo = repo
self.a_path = a_path
self.b_path = b_path
@@ -30,6 +32,9 @@ class Diff(object):
self.b_mode = b_mode
self.new_file = new_file
self.deleted_file = deleted_file
+ self.rename_from = rename_from
+ self.rename_to = rename_to
+ self.renamed = rename_from != rename_to
self.diff = diff
@classmethod
@@ -54,13 +59,13 @@ class Diff(object):
header = diff_header(diff)
a_path, b_path, similarity_index, rename_from, rename_to, \
- old_mode, new_mode, new_file_mode, deleted_file_mode, \
+ old_mode, new_mode, new_file_mode, deleted_file_mode, \
a_commit, b_commit, b_mode = header.groups()
new_file, deleted_file = bool(new_file_mode), bool(deleted_file_mode)
diffs.append(Diff(repo, a_path, b_path, a_commit, b_commit,
old_mode or deleted_file_mode, new_mode or new_file_mode or b_mode,
- new_file, deleted_file, diff[header.end():]))
+ new_file, deleted_file, rename_from, rename_to, diff[header.end():]))
return diffs