From cfaf181bb83f2edc5e95019ef3c6b65a6ad977cf Mon Sep 17 00:00:00 2001 From: Sverre Rabbelier Date: Fri, 13 Jun 2008 13:43:04 +0200 Subject: [PATCH] gitstats: Improved the dispatching in index.py There is now a '-t/--touched' option that will show all commits that touch the same files as the staged changes. Also, the help message when no changes or no matching commits were found has been improved. --- src/git_stats/index.py | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/src/git_stats/index.py b/src/git_stats/index.py index 5ccd21f..4b404cf 100644 --- a/src/git_stats/index.py +++ b/src/git_stats/index.py @@ -73,12 +73,27 @@ def dispatch(*args): action="store_true", help="search even new files, which usually have no matching commits") - (options, args) = parser.parse_args(list(args)) + parser.add_option( + "-t", "--touched", + action="store_true", + help="shows all commits that touch the same paths as the staged changes") + + parser.set_default("touched", False) + parser.set_default("all", False) + + (options, args) = parser.parse_args(list(args)) - result = touched(options.all) + if options.touched: + result = touched(options.all) if not result: - print("No changes staged (or only new files added)") + msg = "No changes staged" + if options.all: + msg += " or no matching commits" + else: + msg += ", no matching commits, or only new files added" + + print(msg) return commit.prettyPrint(result) -- 2.11.4.GIT