git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[StGIT RFC PATCH] Activate rename detection by default.

From
Yann Dirson <ydirson@altern.org>
Date
May 4, 2007, 23:54 UTC
Message-ID
<20070504235413.29479.13640.stgit@gandelf.nowhere.earth>

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@altern.org>
---
 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):
Next: Catalin Marinas
Message 1 of 4 in “Activate rename detection by default.”
  1. Activate rename detection by default.Yann Dirson, May 4, 2007
  2. Catalin MarinasMay 15, 2007
  3. Karl HasselströmMay 15, 2007
  4. Yann DirsonMay 15, 2007

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.