[StGIT RFC PATCH] Activate rename detection by default.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This patch uses -M when generating diffs, which then looks fine, just
like any other git-generated diff.

While I was at it, I also added -M when calling "stg files" or "stg
status".  While we need that for completeness, we currently just
display the raw git-diff-tree output, and it may break some scripts.
We may also want to make it more human-readable (not sure how, esp. if
we want to remain machine-parsable).

It also raises the issue of whether to activate this by default or not
(mostly in status and files), and how to select this behaviour -
something which will possibly be needed to be decided before
introducing -C and --find-copies-harder, which would be useful as
well, the latter being definitely a candidate to be off by default.

That gives:

$ ./stg status
? contrib/stg-push-force
R100 README     README2
M stgit/git.py

$ ./stg files sink 
R056 Documentation/stg-bury.txt Documentation/stg-sink.txt
M Documentation/stg.txt
M contrib/stgit-completion.bash
R093 stgit/commands/bury.py     stgit/commands/sink.py
M stgit/main.py

Signed-off-by: Yann Dirson <ydirson@xxxxxxxxxx>
---

 README2      |    0 
 stgit/git.py |   12 ++++++------
 2 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/README b/README2
similarity index 100%
rename from README
rename to README2
diff --git a/stgit/git.py b/stgit/git.py
index d7eb48e..ed09eca 100644
--- a/stgit/git.py
+++ b/stgit/git.py
@@ -255,7 +255,7 @@ def __tree_status(files = None, tree_id = 'HEAD', unknown = False,
     cache_files += [('C', filename) for filename in conflicts]
 
     # the rest
-    for line in _output_lines(['git-diff-index', tree_id, '--'] + files):
+    for line in _output_lines(['git-diff-index', '-M', tree_id, '--'] + files):
         fs = tuple(line.rstrip().split(' ',4)[-1].split('\t',1))
         if fs[1] not in conflicts:
             cache_files.append(fs)
@@ -774,13 +774,13 @@ def diff(files = None, rev1 = 'HEAD', rev2 = None, out_fd = None):
         files = []
 
     if rev1 and rev2:
-        diff_str = _output(['git-diff-tree', '-p', rev1, rev2, '--'] + files)
+        diff_str = _output(['git-diff-tree', '-M', '-p', rev1, rev2, '--'] + files)
     elif rev1 or rev2:
         refresh_index()
         if rev2:
-            diff_str = _output(['git-diff-index', '-p', '-R', rev2, '--'] + files)
+            diff_str = _output(['git-diff-index', '-M', '-p', '-R', rev2, '--'] + files)
         else:
-            diff_str = _output(['git-diff-index', '-p', rev1, '--'] + files)
+            diff_str = _output(['git-diff-index', '-M', '-p', rev1, '--'] + files)
     else:
         diff_str = ''
 
@@ -808,7 +808,7 @@ def files(rev1, rev2):
     """
 
     result = ''
-    for line in _output_lines('git-diff-tree -r %s %s' % (rev1, rev2)):
+    for line in _output_lines('git-diff-tree -M -r %s %s' % (rev1, rev2)):
         result += '%s %s\n' % tuple(line.rstrip().split(' ',4)[-1].split('\t',1))
 
     return result.rstrip()
@@ -826,7 +826,7 @@ def barefiles(rev1, rev2):
 def pretty_commit(commit_id = 'HEAD'):
     """Return a given commit (log + diff)
     """
-    return _output(['git-diff-tree', '--cc', '--always', '--pretty', '-r',
+    return _output(['git-diff-tree', '-M', '--cc', '--always', '--pretty', '-r',
                     commit_id])
 
 def checkout(files = None, tree_id = None, force = False):

-
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]