Allow 'stg diff ..<commit>'
[stgit] / stgit / commands / diff.py
index 38de3a1..631e42d 100644 (file)
@@ -23,6 +23,7 @@ from stgit.commands.common import *
 from stgit.utils import *
 from stgit.out import *
 from stgit import argparse, stack, git
+from stgit.lib import git as gitlib
 
 help = 'Show the tree diff'
 kind = 'wc'
@@ -31,14 +32,14 @@ description = """
 Show the diff (default) or diffstat between the current working copy
 or a tree-ish object and another tree-ish object (defaulting to HEAD).
 File names can also be given to restrict the diff output. The
-tree-ish object can be an StGIT patch, a standard git commit, tag or
-tree. In addition to these, the command also supports '{base}',
-representing the bottom of the current stack.
-
-rev = '[branch:](<patch>|{base}) | <tree-ish>'"""
+tree-ish object has the format accepted by the linkstg:id[] command."""
 
+args = [argparse.known_files, argparse.dirty_files]
 options = [
     opt('-r', '--range', metavar = 'rev1[..[rev2]]', dest = 'revs',
+        args = [argparse.patch_range(argparse.applied_patches,
+                                     argparse.unapplied_patches,
+                                     argparse.hidden_patches)],
         short = 'Show the diff between revisions'),
     opt('-s', '--stat', action = 'store_true',
         short = 'Show the stat instead of the diff'),
@@ -67,11 +68,13 @@ def func(parser, options, args):
         rev1 = 'HEAD'
         rev2 = None
 
-    diff_str = git.diff(args, git_id(crt_series, rev1),
+    if not options.stat:
+        options.diff_flags.extend(color_diff_flags())
+    diff_str = git.diff(args, rev1 and git_id(crt_series, rev1),
                         rev2 and git_id(crt_series, rev2),
                         diff_flags = options.diff_flags)
     if options.stat:
-        out.stdout_raw(git.diffstat(diff_str) + '\n')
+        out.stdout_raw(gitlib.diffstat(diff_str) + '\n')
     else:
         if diff_str:
             pager(diff_str)