Print this page
9803 pbchk could use a -c option
9825 pbchk -b option should be -p

@@ -16,13 +16,13 @@
 
 #
 # Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
 # Copyright 2008, 2012 Richard Lowe
 # Copyright 2014 Garrett D'Amore <garrett@damore.org>
-# Copyright (c) 2014, Joyent, Inc.
 # Copyright (c) 2015, 2016 by Delphix. All rights reserved.
 # Copyright 2016 Nexenta Systems, Inc.
+# Copyright 2018 Joyent, Inc.
 #
 
 import getopt
 import os
 import re

@@ -369,34 +369,47 @@
     run_checks(root, parent, cmds)
 
 
 def main(cmd, args):
     parent_branch = None
+    checkname = None
 
     try:
-        opts, args = getopt.getopt(args, 'b:')
+        opts, args = getopt.getopt(args, 'c:p:')
     except getopt.GetoptError, e:
         sys.stderr.write(str(e) + '\n')
-        sys.stderr.write("Usage: %s [-b branch] [path...]\n" % cmd)
+        sys.stderr.write("Usage: %s [-c check] [-p branch] [path...]\n" % cmd)
         sys.exit(1)
 
     for opt, arg in opts:
+        # backwards compatibility
         if opt == '-b':
             parent_branch = arg
+        elif opt == '-c':
+            checkname = arg
+        elif opt == '-p':
+            parent_branch = arg
 
     if not parent_branch:
         parent_branch = git_parent_branch(git_branch())
 
-    func = nits
+    if checkname is None:
     if cmd == 'git-pbchk':
-        func = pbchk
+            checkname= 'pbchk'
+        else:
+            checkname = 'nits'
+
+    if checkname == 'pbchk':
         if args:
             sys.stderr.write("only complete workspaces may be pbchk'd\n");
             sys.exit(1)
+        pbchk(git_root(), parent_branch, None)
+    elif checkname == 'nits':
+        nits(git_root(), parent_branch, args)
+    else:
+        run_checks(git_root(), parent_branch, [eval(checkname)], args)
 
-    func(git_root(), parent_branch, args)
-
 if __name__ == '__main__':
     try:
         main(os.path.basename(sys.argv[0]), sys.argv[1:])
     except GitError, e:
         sys.stderr.write("failed to run git:\n %s\n" % str(e))