git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Catalin Marinas <catalin.marinas@gmail.com>
To: Alex Chiang <achiang@hp.com>
Cc: kha@treskal.com, git@vger.kernel.org
Subject: Re: [StGit PATCH] teach --summary to stg show
Date: Fri, 10 Jul 2009 11:11:05 +0100	[thread overview]
Message-ID: <b0943d9e0907100311n26af2e86j95cae2200298ff68@mail.gmail.com> (raw)
In-Reply-To: <20090619050653.GD21764@ldl.fc.hp.com>

Hi Alex,

Sorry for the loooong delay.

2009/6/19 Alex Chiang <achiang@hp.com>:
> Add -s/--summary option to stg show, which will generate a nice
> diffstat, similar to what you get in a cover mail if you specify
> %(diffstat)s.

I would use --stat for consistency with the diff command.

> +        commit_str = gitlib.diffstat(git.diff(
> +                                rev1 = git_id(crt_series, '%s^' % patches[0]),
> +                                rev2 = git_id(crt_series, '%s' % patches[-1])))

This works only of the shown patches are consecutive. If you specify
random patches, the diffstat isn't correct. I propose this form of the
patch:

diff --git a/stgit/commands/show.py b/stgit/commands/show.py
index b7a8aa9..45c3a56 100644
--- a/stgit/commands/show.py
+++ b/stgit/commands/show.py
@@ -20,6 +20,7 @@ from pydoc import pager
 from stgit.argparse import opt
 from stgit.commands.common import *
 from stgit import argparse, git
+from stgit.lib import git as gitlib

 help = 'Show the commit corresponding to a patch'
 kind = 'patch'
@@ -38,6 +39,8 @@ options = [
         short = 'Show the applied patches'),
     opt('-u', '--unapplied', action = 'store_true',
         short = 'Show the unapplied patches'),
+    opt('-s', '--stat', action = 'store_true',
+        short = 'Show a diffstat summary of the specified patches'),
     ] + argparse.diff_opts_option()

 directory = DirectoryHasRepository(log = False)
@@ -61,10 +64,13 @@ def func(parser, options, args):
         # individual patches or commit ids
         patches = args

-    options.diff_flags.extend(color_diff_flags())
+    if not options.stat:
+        options.diff_flags.extend(color_diff_flags())
     commit_ids = [git_id(crt_series, patch) for patch in patches]
     commit_str = '\n'.join([git.pretty_commit(commit_id,
                                               flags = options.diff_flags)
                             for commit_id in commit_ids])
+    if options.stat:
+        commit_str = gitlib.diffstat(commit_str)
     if commit_str:
         pager(commit_str)


-- 
Catalin

  reply	other threads:[~2009-07-10 10:11 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-06-19  5:06 [StGit PATCH] teach --summary to stg show Alex Chiang
2009-07-10 10:11 ` Catalin Marinas [this message]
2009-07-10 18:56   ` Alex Chiang
2009-07-10 22:14     ` Catalin Marinas

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=b0943d9e0907100311n26af2e86j95cae2200298ff68@mail.gmail.com \
    --to=catalin.marinas@gmail.com \
    --cc=achiang@hp.com \
    --cc=git@vger.kernel.org \
    --cc=kha@treskal.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).