checkkconfigsymbols.py: find relevant commits

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>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
Valentin Rothberg 2015-06-01 16:00:19 +02:00 committed by Greg Kroah-Hartman
parent ccf97fe3dd
commit a42fa92ce7
1 changed files with 21 additions and 0 deletions

View File

@ -58,6 +58,11 @@ def parse_options():
"input format bases on Git log's " "input format bases on Git log's "
"\'commmit1..commit2\'.") "\'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', parser.add_option('-i', '--ignore', dest='ignore', action='store',
default="", default="",
help="Ignore files matching this pattern. Note that " help="Ignore files matching this pattern. Note that "
@ -86,6 +91,9 @@ def parse_options():
"'--force' if you\nwant to ignore this warning and " "'--force' if you\nwant to ignore this warning and "
"continue.") "continue.")
if opts.commit:
opts.find = False
if opts.ignore: if opts.ignore:
try: try:
re.match(opts.ignore, "this/is/just/a/test.c") re.match(opts.ignore, "this/is/just/a/test.c")
@ -129,12 +137,18 @@ def main():
if not feature in undefined_a: if not feature in undefined_a:
files = sorted(undefined_b.get(feature)) files = sorted(undefined_b.get(feature))
print "%s\t%s" % (feature, ", ".join(files)) 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 # check if there are new files that reference the undefined feature
else: else:
files = sorted(undefined_b.get(feature) - files = sorted(undefined_b.get(feature) -
undefined_a.get(feature)) undefined_a.get(feature))
if files: if files:
print "%s\t%s" % (feature, ", ".join(files)) print "%s\t%s" % (feature, ", ".join(files))
if opts.find:
commits = find_commits(feature, opts.diff)
print commits
# reset to head # reset to head
execute("git reset --hard %s" % head) execute("git reset --hard %s" % head)
@ -156,6 +170,13 @@ def execute(cmd):
return stdout 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(): def tree_is_dirty():
"""Return true if the current working tree is dirty (i.e., if any file has """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).""" been added, deleted, modified, renamed or copied but not committed)."""