* [StGit PATCH] teach --summary to stg show
@ 2009-06-19 5:06 Alex Chiang
2009-07-10 10:11 ` Catalin Marinas
0 siblings, 1 reply; 4+ messages in thread
From: Alex Chiang @ 2009-06-19 5:06 UTC (permalink / raw)
To: catalin.marinas, kha; +Cc: git
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.
This new option is handy for getting a sense of the scale of your
patch-series-in-progress.
You'd think this option wouldn't be necessary, but simply piping
the output of stg show -a into diffstat (v1.45) doesn't do the
Right Thing(tm):
achiang@bob:linux-2.6$ stg series
+ export-acpi-pci-root
+ acpiphp-find-bridges-easy
> acpi-pci-detect-ejectable-interface
achiang@bob:linux-2.6$ stg show -a | diffstat
b/drivers/acpi/pci_root.c | 16 ------
b/drivers/pci/hotplug/acpi_pcihp.c | 7 --
b/drivers/pci/hotplug/acpiphp_glue.c | 89 +++++++++++------------------------
b/drivers/pci/hotplug/pciehp_acpi.c | 5 +
b/include/acpi/acpi_bus.h | 14 +++++
b/include/linux/pci_hotplug.h | 2
drivers/pci/hotplug/acpiphp_glue.c | 14 -----
7 files changed, 52 insertions(+), 95 deletions(-)
Here is the correct diffstat using the new -s option.
achiang@bob:linux-2.6$ stg show -a -s
drivers/acpi/pci_root.c | 16 +------
drivers/pci/hotplug/acpi_pcihp.c | 7 +--
drivers/pci/hotplug/acpiphp_glue.c | 77 ++++++++----------------------------
drivers/pci/hotplug/pciehp_acpi.c | 5 +-
include/acpi/acpi_bus.h | 14 +++++++
include/linux/pci_hotplug.h | 2 -
6 files changed, 39 insertions(+), 82 deletions(-)
Signed-off-by: Alex Chiang <achiang@hp.com>
---
diff --git a/stgit/commands/show.py b/stgit/commands/show.py
index b7a8aa9..1f862f7 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', '--summary', action = 'store_true',
+ short = 'Show a diffstat summary of the specified patches'),
] + argparse.diff_opts_option()
directory = DirectoryHasRepository(log = False)
@@ -62,9 +65,14 @@ def func(parser, options, args):
patches = args
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.summary:
+ commit_str = gitlib.diffstat(git.diff(
+ rev1 = git_id(crt_series, '%s^' % patches[0]),
+ rev2 = git_id(crt_series, '%s' % patches[-1])))
+ else:
+ 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 commit_str:
pager(commit_str)
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [StGit PATCH] teach --summary to stg show
2009-06-19 5:06 [StGit PATCH] teach --summary to stg show Alex Chiang
@ 2009-07-10 10:11 ` Catalin Marinas
2009-07-10 18:56 ` Alex Chiang
0 siblings, 1 reply; 4+ messages in thread
From: Catalin Marinas @ 2009-07-10 10:11 UTC (permalink / raw)
To: Alex Chiang; +Cc: kha, git
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
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [StGit PATCH] teach --summary to stg show
2009-07-10 10:11 ` Catalin Marinas
@ 2009-07-10 18:56 ` Alex Chiang
2009-07-10 22:14 ` Catalin Marinas
0 siblings, 1 reply; 4+ messages in thread
From: Alex Chiang @ 2009-07-10 18:56 UTC (permalink / raw)
To: Catalin Marinas; +Cc: kha, git
* Catalin Marinas <catalin.marinas@gmail.com>:
> Hi Alex,
>
> Sorry for the loooong delay.
No problem.
> 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:
Looks much nicer than mine, thanks.
Tested-by: Alex Chiang <achiang@hp.com>
[how about that other patch "fix stg mail %(shortlog)s order"? :) ]
/ac
> 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
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [StGit PATCH] teach --summary to stg show
2009-07-10 18:56 ` Alex Chiang
@ 2009-07-10 22:14 ` Catalin Marinas
0 siblings, 0 replies; 4+ messages in thread
From: Catalin Marinas @ 2009-07-10 22:14 UTC (permalink / raw)
To: Alex Chiang; +Cc: kha, git
2009/7/10 Alex Chiang <achiang@hp.com>:
> [how about that other patch "fix stg mail %(shortlog)s order"? :) ]
I already merged it. Thanks.
--
Catalin
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2009-07-10 22:14 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-06-19 5:06 [StGit PATCH] teach --summary to stg show Alex Chiang
2009-07-10 10:11 ` Catalin Marinas
2009-07-10 18:56 ` Alex Chiang
2009-07-10 22:14 ` Catalin Marinas
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).