From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <dev-bounces@dpdk.org>
Received: from dpdk.org (dpdk.org [92.243.14.124])
	by inbox.dpdk.org (Postfix) with ESMTP id 9ACA7A034F;
	Wed,  6 May 2020 11:56:57 +0200 (CEST)
Received: from [92.243.14.124] (localhost [127.0.0.1])
	by dpdk.org (Postfix) with ESMTP id 23FA31D8E6;
	Wed,  6 May 2020 11:56:52 +0200 (CEST)
Received: from mga05.intel.com (mga05.intel.com [192.55.52.43])
 by dpdk.org (Postfix) with ESMTP id 347331D8CC
 for <dev@dpdk.org>; Wed,  6 May 2020 11:56:50 +0200 (CEST)
IronPort-SDR: aVlbepp10QPfjayu+v05Kk5/2BEAB3Cqj0B2aNcaDP/qP1F6FeXfpNJN4kexOjX6XST48Ax9Hc
 9uvPp0AK+5ew==
X-Amp-Result: SKIPPED(no attachment in message)
X-Amp-File-Uploaded: False
Received: from fmsmga006.fm.intel.com ([10.253.24.20])
 by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384;
 06 May 2020 02:56:49 -0700
IronPort-SDR: o7DzAejMpfgkUXV8I2dusT8wxe0ypIhjW3IZdgzOkCWOad0f0TPrHuACuOqRViCN52lpFzvdOC
 2qJqf9SDT6/g==
X-ExtLoop1: 1
X-IronPort-AV: E=Sophos;i="5.73,358,1583222400"; d="scan'208";a="461705911"
Received: from silpixa00399953.ir.intel.com (HELO
 silpixa00399953.ger.corp.intel.com) ([10.237.222.53])
 by fmsmga006.fm.intel.com with ESMTP; 06 May 2020 02:56:48 -0700
From: Ciara Power <ciara.power@intel.com>
To: thomas@monjalon.net
Cc: dev@dpdk.org,
	Ciara Power <ciara.power@intel.com>
Date: Wed,  6 May 2020 10:55:25 +0100
Message-Id: <20200506095526.27664-2-ciara.power@intel.com>
X-Mailer: git-send-email 2.17.1
In-Reply-To: <20200506095526.27664-1-ciara.power@intel.com>
References: <20200128150256.14339-1-ciara.power@intel.com>
 <20200506095526.27664-1-ciara.power@intel.com>
Subject: [dpdk-dev] [PATCH v2 1/2] devtools: standardize script arguments
X-BeenThere: dev@dpdk.org
X-Mailman-Version: 2.1.15
Precedence: list
List-Id: DPDK patches and discussions <dev.dpdk.org>
List-Unsubscribe: <https://mails.dpdk.org/options/dev>,
 <mailto:dev-request@dpdk.org?subject=unsubscribe>
List-Archive: <http://mails.dpdk.org/archives/dev/>
List-Post: <mailto:dev@dpdk.org>
List-Help: <mailto:dev-request@dpdk.org?subject=help>
List-Subscribe: <https://mails.dpdk.org/listinfo/dev>,
 <mailto:dev-request@dpdk.org?subject=subscribe>
Errors-To: dev-bounces@dpdk.org
Sender: "dev" <dev-bounces@dpdk.org>

This patch modifies the arguments expected by the check-git-log script,
to match the format of arguments for the checkpatches script. Both
scripts now take certain argument options in the same format, making
them easier to use.
e.g. Both now take a commit ID range by "-r <range>"

The checkpatches help print is also updated to include the "-h" option.

Signed-off-by: Ciara Power <ciara.power@intel.com>
Acked-by: Ferruh Yigit <ferruh.yigit@intel.com>

---
v2: Added exit 0 after print usage.
---
 devtools/check-git-log.sh | 33 ++++++++++++++++++++++++---------
 devtools/checkpatches.sh  |  2 +-
 2 files changed, 25 insertions(+), 10 deletions(-)

diff --git a/devtools/check-git-log.sh b/devtools/check-git-log.sh
index 4e65be0e4b..efdfca27cc 100755
--- a/devtools/check-git-log.sh
+++ b/devtools/check-git-log.sh
@@ -7,23 +7,38 @@
 # If any doubt about the formatting, please check in the most recent history:
 #	git log --format='%>|(15)%cr   %s' --reverse | grep -i <pattern>
 
-if [ "$1" = '-h' -o "$1" = '--help' ] ; then
+print_usage () {
 	cat <<- END_OF_HELP
-	usage: $(basename $0) [-h] [range]
+	usage: $(basename $0) [-h] [-nX|-r range]
 
 	Check commit log formatting.
-	The git range can be specified as a "git log" option,
-	e.g. -1 to check only the latest commit.
-	The default range starts from origin/master to HEAD.
+	The git commits to be checked can be specified as a "git log" option,
+	by latest git commits limited with -n option, or commits in the git
+	range specified with -r option.
+	e.g. -n1 to check only the latest commit.
+	The default starts from origin/master to HEAD.
 	END_OF_HELP
-	exit
-fi
+}
 
 selfdir=$(dirname $(readlink -f $0))
 range=${1:-origin/master..}
+
+if [ "$range" = '--help' ] ; then
+	print_usage
+	exit 0
 # convert -N to HEAD~N.. in order to comply with git-log-fixes.sh getopts
-if printf -- $range | grep -q '^-[0-9]\+' ; then
-	range="HEAD$(printf -- $range | sed 's,^-,~,').."
+elif printf -- "$range" | grep -q '^-[0-9]\+' ; then
+	range="HEAD$(printf -- "$range" | sed 's,^-,~,').."
+else
+	while getopts hr:n: ARG ; do
+		case $ARG in
+			n ) range="HEAD~$OPTARG.." ;;
+			r ) range=$OPTARG ;;
+			h ) print_usage ; exit 0 ;;
+			? ) print_usage ; exit 1 ;;
+		esac
+	done
+	shift $(($OPTIND - 1))
 fi
 
 commits=$(git log --format='%h' --reverse $range)
diff --git a/devtools/checkpatches.sh b/devtools/checkpatches.sh
index 42b833e0d7..e111c31d7d 100755
--- a/devtools/checkpatches.sh
+++ b/devtools/checkpatches.sh
@@ -38,7 +38,7 @@ options="$options $DPDK_CHECKPATCH_OPTIONS"
 
 print_usage () {
 	cat <<- END_OF_HELP
-	usage: $(basename $0) [-q] [-v] [-nX|-r range|patch1 [patch2] ...]]
+	usage: $(basename $0) [-h] [-q] [-v] [-nX|-r range|patch1 [patch2] ...]
 
 	Run Linux kernel checkpatch.pl with DPDK options.
 	The environment variable DPDK_CHECKPATCH_PATH must be set.
-- 
2.17.1