{"thread":{"id":"19860","subject":"[StGit PATCH] teach --summary to stg show","startedAt":"2009-06-19T05:06:53Z","lastAt":"2009-07-10T22:14:31Z","messageCount":4,"participants":["Alex Chiang","Catalin Marinas"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"116610","messageId":"20090619050653.GD21764@ldl.fc.hp.com","threadId":"19860","inReplyTo":null,"subject":"[StGit PATCH] teach --summary to stg show","fromName":"Alex Chiang","fromEmail":"achiang@hp.com","sentAt":"2009-06-19T05:06:53Z","receivedAt":"2009-06-19T05:06:53Z","isPatch":true,"sender":{"key":"achiang@hp.com","avatar":null},"body":"Add -s/--summary option to stg show, which will generate a nice\ndiffstat, similar to what you get in a cover mail if you specify\n%(diffstat)s.\n\nThis new option is handy for getting a sense of the scale of your\npatch-series-in-progress.\n\nYou'd think this option wouldn't be necessary, but simply piping\nthe output of stg show -a into diffstat (v1.45) doesn't do the\nRight Thing(tm):\n\nachiang@bob:linux-2.6$ stg series\n+ export-acpi-pci-root\n+ acpiphp-find-bridges-easy\n> acpi-pci-detect-ejectable-interface\n\nachiang@bob:linux-2.6$ stg show -a | diffstat\n b/drivers/acpi/pci_root.c            |   16 ------\n b/drivers/pci/hotplug/acpi_pcihp.c   |    7 --\n b/drivers/pci/hotplug/acpiphp_glue.c |   89 +++++++++++------------------------\n b/drivers/pci/hotplug/pciehp_acpi.c  |    5 +\n b/include/acpi/acpi_bus.h            |   14 +++++\n b/include/linux/pci_hotplug.h        |    2 \n drivers/pci/hotplug/acpiphp_glue.c   |   14 -----\n 7 files changed, 52 insertions(+), 95 deletions(-)\n\nHere is the correct diffstat using the new -s option.\n\nachiang@bob:linux-2.6$ stg show -a -s\n drivers/acpi/pci_root.c            |   16 +------\n drivers/pci/hotplug/acpi_pcihp.c   |    7 +--\n drivers/pci/hotplug/acpiphp_glue.c |   77 ++++++++----------------------------\n drivers/pci/hotplug/pciehp_acpi.c  |    5 +-\n include/acpi/acpi_bus.h            |   14 +++++++\n include/linux/pci_hotplug.h        |    2 -\n 6 files changed, 39 insertions(+), 82 deletions(-)\n\nSigned-off-by: Alex Chiang <achiang@hp.com>\n---\ndiff --git a/stgit/commands/show.py b/stgit/commands/show.py\nindex b7a8aa9..1f862f7 100644\n--- a/stgit/commands/show.py\n+++ b/stgit/commands/show.py\n@@ -20,6 +20,7 @@ from pydoc import pager\n from stgit.argparse import opt\n from stgit.commands.common import *\n from stgit import argparse, git\n+from stgit.lib import git as gitlib\n \n help = 'Show the commit corresponding to a patch'\n kind = 'patch'\n@@ -38,6 +39,8 @@ options = [\n         short = 'Show the applied patches'),\n     opt('-u', '--unapplied', action = 'store_true',\n         short = 'Show the unapplied patches'),\n+    opt('-s', '--summary', action = 'store_true',\n+        short = 'Show a diffstat summary of the specified patches'),\n     ] + argparse.diff_opts_option()\n \n directory = DirectoryHasRepository(log = False)\n@@ -62,9 +65,14 @@ def func(parser, options, args):\n         patches = args\n \n     options.diff_flags.extend(color_diff_flags())\n-    commit_ids = [git_id(crt_series, patch) for patch in patches]\n-    commit_str = '\\n'.join([git.pretty_commit(commit_id,\n-                                              flags = options.diff_flags)\n-                            for commit_id in commit_ids])\n+    if options.summary:\n+        commit_str = gitlib.diffstat(git.diff(\n+                                rev1 = git_id(crt_series, '%s^' % patches[0]),\n+                                rev2 = git_id(crt_series, '%s' % patches[-1])))\n+    else:\n+        commit_ids = [git_id(crt_series, patch) for patch in patches]\n+        commit_str = '\\n'.join([git.pretty_commit(commit_id,\n+                                                  flags = options.diff_flags)\n+                                for commit_id in commit_ids])\n     if commit_str:\n         pager(commit_str)\n"},{"id":"117761","messageId":"b0943d9e0907100311n26af2e86j95cae2200298ff68@mail.gmail.com","threadId":"19860","inReplyTo":"20090619050653.GD21764@ldl.fc.hp.com","subject":"Re: [StGit PATCH] teach --summary to stg show","fromName":"Catalin Marinas","fromEmail":"catalin.marinas@gmail.com","sentAt":"2009-07-10T10:11:05Z","receivedAt":"2009-07-10T10:11:05Z","isPatch":true,"sender":{"key":"catalin.marinas@gmail.com","avatar":null},"body":"Hi Alex,\n\nSorry for the loooong delay.\n\n2009/6/19 Alex Chiang <achiang@hp.com>:\n> Add -s/--summary option to stg show, which will generate a nice\n> diffstat, similar to what you get in a cover mail if you specify\n> %(diffstat)s.\n\nI would use --stat for consistency with the diff command.\n\n> +        commit_str = gitlib.diffstat(git.diff(\n> +                                rev1 = git_id(crt_series, '%s^' % patches[0]),\n> +                                rev2 = git_id(crt_series, '%s' % patches[-1])))\n\nThis works only of the shown patches are consecutive. If you specify\nrandom patches, the diffstat isn't correct. I propose this form of the\npatch:\n\ndiff --git a/stgit/commands/show.py b/stgit/commands/show.py\nindex b7a8aa9..45c3a56 100644\n--- a/stgit/commands/show.py\n+++ b/stgit/commands/show.py\n@@ -20,6 +20,7 @@ from pydoc import pager\n from stgit.argparse import opt\n from stgit.commands.common import *\n from stgit import argparse, git\n+from stgit.lib import git as gitlib\n\n help = 'Show the commit corresponding to a patch'\n kind = 'patch'\n@@ -38,6 +39,8 @@ options = [\n         short = 'Show the applied patches'),\n     opt('-u', '--unapplied', action = 'store_true',\n         short = 'Show the unapplied patches'),\n+    opt('-s', '--stat', action = 'store_true',\n+        short = 'Show a diffstat summary of the specified patches'),\n     ] + argparse.diff_opts_option()\n\n directory = DirectoryHasRepository(log = False)\n@@ -61,10 +64,13 @@ def func(parser, options, args):\n         # individual patches or commit ids\n         patches = args\n\n-    options.diff_flags.extend(color_diff_flags())\n+    if not options.stat:\n+        options.diff_flags.extend(color_diff_flags())\n     commit_ids = [git_id(crt_series, patch) for patch in patches]\n     commit_str = '\\n'.join([git.pretty_commit(commit_id,\n                                               flags = options.diff_flags)\n                             for commit_id in commit_ids])\n+    if options.stat:\n+        commit_str = gitlib.diffstat(commit_str)\n     if commit_str:\n         pager(commit_str)\n\n\n-- \nCatalin\n"},{"id":"117791","messageId":"20090710185629.GA19324@ldl.fc.hp.com","threadId":"19860","inReplyTo":"b0943d9e0907100311n26af2e86j95cae2200298ff68@mail.gmail.com","subject":"Re: [StGit PATCH] teach --summary to stg show","fromName":"Alex Chiang","fromEmail":"achiang@hp.com","sentAt":"2009-07-10T18:56:29Z","receivedAt":"2009-07-10T18:56:29Z","isPatch":true,"sender":{"key":"achiang@hp.com","avatar":null},"body":"* Catalin Marinas <catalin.marinas@gmail.com>:\n> Hi Alex,\n> \n> Sorry for the loooong delay.\n\nNo problem.\n\n> 2009/6/19 Alex Chiang <achiang@hp.com>:\n> > Add -s/--summary option to stg show, which will generate a nice\n> > diffstat, similar to what you get in a cover mail if you specify\n> > %(diffstat)s.\n> \n> I would use --stat for consistency with the diff command.\n> \n> > +        commit_str = gitlib.diffstat(git.diff(\n> > +                                rev1 = git_id(crt_series, '%s^' % patches[0]),\n> > +                                rev2 = git_id(crt_series, '%s' % patches[-1])))\n> \n> This works only of the shown patches are consecutive. If you specify\n> random patches, the diffstat isn't correct. I propose this form of the\n> patch:\n\nLooks much nicer than mine, thanks.\n\nTested-by: Alex Chiang <achiang@hp.com>\n\n[how about that other patch \"fix stg mail %(shortlog)s order\"? :) ]\n\n/ac\n\n> diff --git a/stgit/commands/show.py b/stgit/commands/show.py\n> index b7a8aa9..45c3a56 100644\n> --- a/stgit/commands/show.py\n> +++ b/stgit/commands/show.py\n> @@ -20,6 +20,7 @@ from pydoc import pager\n>  from stgit.argparse import opt\n>  from stgit.commands.common import *\n>  from stgit import argparse, git\n> +from stgit.lib import git as gitlib\n> \n>  help = 'Show the commit corresponding to a patch'\n>  kind = 'patch'\n> @@ -38,6 +39,8 @@ options = [\n>          short = 'Show the applied patches'),\n>      opt('-u', '--unapplied', action = 'store_true',\n>          short = 'Show the unapplied patches'),\n> +    opt('-s', '--stat', action = 'store_true',\n> +        short = 'Show a diffstat summary of the specified patches'),\n>      ] + argparse.diff_opts_option()\n> \n>  directory = DirectoryHasRepository(log = False)\n> @@ -61,10 +64,13 @@ def func(parser, options, args):\n>          # individual patches or commit ids\n>          patches = args\n> \n> -    options.diff_flags.extend(color_diff_flags())\n> +    if not options.stat:\n> +        options.diff_flags.extend(color_diff_flags())\n>      commit_ids = [git_id(crt_series, patch) for patch in patches]\n>      commit_str = '\\n'.join([git.pretty_commit(commit_id,\n>                                                flags = options.diff_flags)\n>                              for commit_id in commit_ids])\n> +    if options.stat:\n> +        commit_str = gitlib.diffstat(commit_str)\n>      if commit_str:\n>          pager(commit_str)\n> \n> \n> -- \n> Catalin\n> \n"},{"id":"117804","messageId":"b0943d9e0907101514u6140b577t2cd8e4e9f646817c@mail.gmail.com","threadId":"19860","inReplyTo":"20090710185629.GA19324@ldl.fc.hp.com","subject":"Re: [StGit PATCH] teach --summary to stg show","fromName":"Catalin Marinas","fromEmail":"catalin.marinas@gmail.com","sentAt":"2009-07-10T22:14:31Z","receivedAt":"2009-07-10T22:14:31Z","isPatch":true,"sender":{"key":"catalin.marinas@gmail.com","avatar":null},"body":"2009/7/10 Alex Chiang <achiang@hp.com>:\n> [how about that other patch \"fix stg mail %(shortlog)s order\"? :) ]\n\nI already merged it. Thanks.\n\n-- \nCatalin\n"}]}