mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH 0/2] checkkconfigsymbols.py: find relevant commits
@ 2015-06-01 14:00 Valentin Rothberg
  2015-06-01 14:00 ` [PATCH 1/2] " Valentin Rothberg
  2015-06-01 14:00 ` [PATCH 2/2] checkkconfigsymbols.py: colored output Valentin Rothberg
  0 siblings, 2 replies; 3+ messages in thread
From: Valentin Rothberg @ 2015-06-01 14:00 UTC (permalink / raw)
  To: gregkh, stefan.hengelein, andreas.ruprecht, pebolle
  Cc: linux-kernel, Valentin Rothberg

This patch series consists of two patches adding an option (--find) to
find and display git commits that may cause a Kconfig symbol to be
missing.  This option is helpful when diffing two states of the tree
(e.g. v4.0-v4.1-rc1) to get a set of relevant git commits without doing
that manually (i.e., git log -G SYMBOL v4.0..v4.1-rc1).  Note that this
option only works with --diff enabled.  Since --find prints additional
information, the output is colored such that missing symbols are printed
yellow, relevant commits red.

The new output looks as follows (entries are separated with blank
lines):

$ checkkconfigsymbols.py --diff v4.0..v4.1-rc1 --find
ARCH_EXYNOS5433 drivers/clk/samsung/Makefile
96bd6224f07b clk: samsung: exynos5433: Add clocks using common clock framework

ARCH_MB86S7X    drivers/clk/Makefile
1ccdd04f5365 clk: Add clock driver for mb86s7x

Valentin Rothberg (2):
  checkkconfigsymbols.py: find relevant commits
  checkkconfigsymbols.py: colored output

 scripts/checkkconfigsymbols.py | 43 ++++++++++++++++++++++++++++++++++++++----
 1 file changed, 39 insertions(+), 4 deletions(-)

--
2.1.4


^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH 1/2] checkkconfigsymbols.py: find relevant commits
  2015-06-01 14:00 [PATCH 0/2] checkkconfigsymbols.py: find relevant commits Valentin Rothberg
@ 2015-06-01 14:00 ` Valentin Rothberg
  2015-06-01 14:00 ` [PATCH 2/2] checkkconfigsymbols.py: colored output Valentin Rothberg
  1 sibling, 0 replies; 3+ messages in thread
From: Valentin Rothberg @ 2015-06-01 14:00 UTC (permalink / raw)
  To: gregkh, stefan.hengelein, andreas.ruprecht, pebolle
  Cc: linux-kernel, Valentin Rothberg

Add option -f/--find to find relevant commits when using the --diff
option.  --find is useful in case a user wants to check commits that
potentially cause a Kconfig symbol to be missing.  This is done via 'git
log -G $SYMBOL' (i.e., to get a list of commits that change $SYMBOL).
The relevant commits are printed below the "SYMBOL\tFILES" line,
followed by an empty line to increase readability.

Signed-off-by: Valentin Rothberg <valentinrothberg@gmail.com>
Acked-by: Stefan Hengelein <stefan.hengelein@fau.de>
Acked-by: Andreas Ruprecht <andreas.ruprecht@fau.de>
---
 scripts/checkkconfigsymbols.py | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)

diff --git a/scripts/checkkconfigsymbols.py b/scripts/checkkconfigsymbols.py
index c89fdcaf06e8..292848e32036 100755
--- a/scripts/checkkconfigsymbols.py
+++ b/scripts/checkkconfigsymbols.py
@@ -58,6 +58,11 @@ def parse_options():
                            "input format bases on Git log's "
                            "\'commmit1..commit2\'.")
 
+    parser.add_option('-f', '--find', dest='find', action='store_true',
+                      default=False,
+                      help="Find and show commits that may cause symbols to be "
+                           "missing.  Required to run with --diff.")
+
     parser.add_option('-i', '--ignore', dest='ignore', action='store',
                       default="",
                       help="Ignore files matching this pattern.  Note that "
@@ -86,6 +91,9 @@ def parse_options():
                      "'--force' if you\nwant to ignore this warning and "
                      "continue.")
 
+    if opts.commit:
+        opts.find = False
+
     if opts.ignore:
         try:
             re.match(opts.ignore, "this/is/just/a/test.c")
@@ -129,12 +137,18 @@ def main():
             if not feature in undefined_a:
                 files = sorted(undefined_b.get(feature))
                 print "%s\t%s" % (feature, ", ".join(files))
+                if opts.find:
+                    commits = find_commits(feature, opts.diff)
+                    print commits
             # check if there are new files that reference the undefined feature
             else:
                 files = sorted(undefined_b.get(feature) -
                                undefined_a.get(feature))
                 if files:
                     print "%s\t%s" % (feature, ", ".join(files))
+                    if opts.find:
+                        commits = find_commits(feature, opts.diff)
+                        print commits
 
         # reset to head
         execute("git reset --hard %s" % head)
@@ -156,6 +170,13 @@ def execute(cmd):
     return stdout
 
 
+def find_commits(symbol, diff):
+    """Find commits changing %symbol in the given range of %diff."""
+    commits = execute("git log --pretty=oneline --abbrev-commit -G %s %s"
+                      % (symbol, diff))
+    return commits
+
+
 def tree_is_dirty():
     """Return true if the current working tree is dirty (i.e., if any file has
     been added, deleted, modified, renamed or copied but not committed)."""
-- 
2.1.4


^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH 2/2] checkkconfigsymbols.py: colored output
  2015-06-01 14:00 [PATCH 0/2] checkkconfigsymbols.py: find relevant commits Valentin Rothberg
  2015-06-01 14:00 ` [PATCH 1/2] " Valentin Rothberg
@ 2015-06-01 14:00 ` Valentin Rothberg
  1 sibling, 0 replies; 3+ messages in thread
From: Valentin Rothberg @ 2015-06-01 14:00 UTC (permalink / raw)
  To: gregkh, stefan.hengelein, andreas.ruprecht, pebolle
  Cc: linux-kernel, Valentin Rothberg

Color output to make it more readable.  Symbols will be printed yellow,
relevant commits (see --find) red.

Signed-off-by: Valentin Rothberg <valentinrothberg@gmail.com>
Acked-by: Stefan Hengelein <stefan.hengelein@fau.de>
Acked-by: Andreas Ruprecht <andreas.ruprecht@fau.de>
---
 scripts/checkkconfigsymbols.py | 26 ++++++++++++++++++++------
 1 file changed, 20 insertions(+), 6 deletions(-)

diff --git a/scripts/checkkconfigsymbols.py b/scripts/checkkconfigsymbols.py
index 292848e32036..d89371cc9110 100755
--- a/scripts/checkkconfigsymbols.py
+++ b/scripts/checkkconfigsymbols.py
@@ -2,7 +2,7 @@
 
 """Find Kconfig symbols that are referenced but not defined."""
 
-# (c) 2014-2015 Valentin Rothberg <Valentin.Rothberg@lip6.fr>
+# (c) 2014-2015 Valentin Rothberg <valentinrothberg@gmail.com>
 # (c) 2014 Stefan Hengelein <stefan.hengelein@fau.de>
 #
 # Licensed under the terms of the GNU GPL License version 2
@@ -136,19 +136,19 @@ def main():
             # feature has not been undefined before
             if not feature in undefined_a:
                 files = sorted(undefined_b.get(feature))
-                print "%s\t%s" % (feature, ", ".join(files))
+                print "%s\t%s" % (yel(feature), ", ".join(files))
                 if opts.find:
                     commits = find_commits(feature, opts.diff)
-                    print commits
+                    print red(commits)
             # check if there are new files that reference the undefined feature
             else:
                 files = sorted(undefined_b.get(feature) -
                                undefined_a.get(feature))
                 if files:
-                    print "%s\t%s" % (feature, ", ".join(files))
+                    print "%s\t%s" % (yel(feature), ", ".join(files))
                     if opts.find:
                         commits = find_commits(feature, opts.diff)
-                        print commits
+                        print red(commits)
 
         # reset to head
         execute("git reset --hard %s" % head)
@@ -158,7 +158,21 @@ def main():
         undefined = check_symbols(opts.ignore)
         for feature in sorted(undefined):
             files = sorted(undefined.get(feature))
-            print "%s\t%s" % (feature, ", ".join(files))
+            print "%s\t%s" % (yel(feature), ", ".join(files))
+
+
+def yel(string):
+    """
+    Color %string yellow.
+    """
+    return "\033[33m%s\033[0m" % string
+
+
+def red(string):
+    """
+    Color %string red.
+    """
+    return "\033[31m%s\033[0m" % string
 
 
 def execute(cmd):
-- 
2.1.4


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2015-06-01 14:01 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-06-01 14:00 [PATCH 0/2] checkkconfigsymbols.py: find relevant commits Valentin Rothberg
2015-06-01 14:00 ` [PATCH 1/2] " Valentin Rothberg
2015-06-01 14:00 ` [PATCH 2/2] checkkconfigsymbols.py: colored output Valentin Rothberg

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®