[#7963] Add copy detection option for commit view
diff --git a/Allura/development.ini b/Allura/development.ini
index 934ea67..af7b5f6 100644
--- a/Allura/development.ini
+++ b/Allura/development.ini
@@ -313,6 +313,10 @@
; Set to 0 to cache all references. Remove entirely to cache nothing.
repo_refs_cache_threshold = .01
+; Enabling copy detection will display copies and renames in the commit views
+; at the expense of much longer response times.
+scm.commits.detect_copies = false
+
; One-click merge is enabled by default, but can be turned off on for each type of repo
scm.merge.git.disabled = false
scm.merge.hg.disabled = false
diff --git a/ForgeGit/forgegit/model/git_repo.py b/ForgeGit/forgegit/model/git_repo.py
index 8229b7e..14374a6 100644
--- a/ForgeGit/forgegit/model/git_repo.py
+++ b/ForgeGit/forgegit/model/git_repo.py
@@ -647,18 +647,18 @@ def get_changes(self, commit_id):
def paged_diffs(self, commit_id, start=0, end=None):
result = {'added': [], 'removed': [], 'changed': [], 'copied': [], 'renamed': []}
+ cmd_args = ['--no-commit-id',
+ '--name-status',
+ '--no-abbrev',
+ '--root',
+ # show tree entry itself as well as subtrees (Commit.added_paths relies on this)
+ '-t',
+ '-z' # don't escape filenames and use \x00 as fields delimiter
+ ]
+ if asbool(tg.config.get('scm.commits.detect_copies', False)):
+ cmd_args += ['-M', '-C']
- cmd_output = self._git.git.diff_tree(
- '--no-commit-id',
- '-M', # detect renames
- '-C', # detect copies
- '--name-status',
- '--no-abbrev',
- '--root',
- # show tree entry itself as well as subtrees (Commit.added_paths relies on this)
- '-t',
- '-z', # don't escape filenames and use \x00 as fields delimiter
- commit_id).split('\x00')[:-1]
+ cmd_output = self._git.git.diff_tree(commit_id, *cmd_args).split('\x00')[:-1] # don't escape filenames and use \x00 as fields delimiter
''' cmd_output will be like:
[
@@ -668,7 +668,7 @@ def paged_diffs(self, commit_id, start=0, end=None):
'another filename',
'M',
'po',
- 'R100',
+ 'R100', # <-- These next three lines would only show up with 'detect_copies' enabled
'po/sr.po',
'po/sr_Latn.po',
]