From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <stable-bounces@dpdk.org>
Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124])
	by inbox.dpdk.org (Postfix) with ESMTP id 1134FA0A0F
	for <public@inbox.dpdk.org>; Wed, 30 Jun 2021 08:34:56 +0200 (CEST)
Received: from [217.70.189.124] (localhost [127.0.0.1])
	by mails.dpdk.org (Postfix) with ESMTP id 8308041236;
	Wed, 30 Jun 2021 08:34:55 +0200 (CEST)
Received: from NAM10-BN7-obe.outbound.protection.outlook.com
 (mail-bn7nam10on2086.outbound.protection.outlook.com [40.107.92.86])
 by mails.dpdk.org (Postfix) with ESMTP id 0AD954121D;
 Wed, 30 Jun 2021 08:34:50 +0200 (CEST)
ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none;
 b=hl5B76Jj2m42VKfNuE5muIWC0Xwqv2hIiQjvdjWPI+mlnxdqNEP6IqCKh7gDlpt6s7jydRFwPNI2e1aUwlEdems9PZYggzPReR8Nm5ctUhv60yO3nFrwpvhXsayImEp3JqTr+UBpwTNL3ef3JKXk3nDQ70BqolCdw+s3udSEwuoBy+ZG9eUqL7+oMDzbYhoZcwL5yYwbFb9o2aVVigL5kXltZLaIMO1tO1G1fewAKnuVyWQ4qVD68XpcfrCsBD6Wci/v85HWhubJFjtLlqYhGGdaM2CHmKNYV4n7kFsuk83v/PEeGUECKpA0W7OU+cdW0azXx53IqEf6+dXSN9vLgg==
ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; 
 s=arcselector9901;
 h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck;
 bh=QEgiaE5TWzIqEmGMw9U4uSxFVG7FkL3AsifbZzKiw10=;
 b=YxmZYS56H59CePBxneD0gi7jXIv/oixGFXVdG46U61HeCvp7gcHJ3gkY/69UDgX2katQ5QO1BCk41Dk5v1ozGsE43S4sa3XbszgJANkAJZaFy7t6RnOskszOlVverFAdjsFzKDxRScKt9+WNh/zjIFr6XmSEOkyC9fwLQvapY18ArSPjwkJrENR/MOfE3R7LKTX4iP9eqY7+XEA5qH0+Pl71BDhjzejIJEXMYYwUZn5KZVtyFWQ3vdYh8bSTkngWi73+cW+vwQ+VJpVdIGa/NBmeSyd4Dle6z022t7jl4rgiLeNAiRbToeZ9aP/j7ccblEQIXdZeRT6yomAUr0xbGg==
ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is
 216.228.112.34) smtp.rcpttodomain=canonical.com smtp.mailfrom=nvidia.com;
 dmarc=pass (p=none sp=none pct=100) action=none header.from=nvidia.com;
 dkim=none (message not signed); arc=none
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com;
 s=selector2;
 h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck;
 bh=QEgiaE5TWzIqEmGMw9U4uSxFVG7FkL3AsifbZzKiw10=;
 b=oCPcPp7HAnbqa+2BqwW4l4EB83dv1dAU35kq5KNv2y4YJSBHC2ChjSDx9yBZGOsZuwikd8uCijQpL7KEeOuNz6QztVXwBBANi2/6PJiIefezr8Dgf73BIdsHi6rLFg8gaR8QzQvnFnA3SwLIKn/PL5GQc1cU736vfJrFR4JDPHsLh7oqzP0RYlUSCa+gkVcZe32GippCbA4BOKfCKqAcKQgqNL5A/fji4SYxOV/6u8ZkNwt4ed0Z7wN6hlynYxgLvZmE7khjHwgStZ1evKfr4NfzEj6Pv3If6wTAev75/5EuqCE1p/fn+rLFKLqrFM00032ojtSyjeajxMvUDW4fHg==
Received: from MW4PR04CA0311.namprd04.prod.outlook.com (2603:10b6:303:82::16)
 by DM6PR12MB4153.namprd12.prod.outlook.com (2603:10b6:5:212::22) with
 Microsoft SMTP Server (version=TLS1_2,
 cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4264.18; Wed, 30 Jun
 2021 06:34:48 +0000
Received: from CO1NAM11FT064.eop-nam11.prod.protection.outlook.com
 (2603:10b6:303:82:cafe::9) by MW4PR04CA0311.outlook.office365.com
 (2603:10b6:303:82::16) with Microsoft SMTP Server (version=TLS1_2,
 cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4287.21 via Frontend
 Transport; Wed, 30 Jun 2021 06:34:48 +0000
X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.112.34)
 smtp.mailfrom=nvidia.com; canonical.com; dkim=none (message not signed)
 header.d=none;canonical.com; dmarc=pass action=none header.from=nvidia.com;
Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates
 216.228.112.34 as permitted sender) receiver=protection.outlook.com;
 client-ip=216.228.112.34; helo=mail.nvidia.com;
Received: from mail.nvidia.com (216.228.112.34) by
 CO1NAM11FT064.mail.protection.outlook.com (10.13.175.77) with Microsoft SMTP
 Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id
 15.20.4287.22 via Frontend Transport; Wed, 30 Jun 2021 06:34:48 +0000
Received: from nvidia.com (172.20.187.6) by HQMAIL107.nvidia.com
 (172.20.187.13) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Wed, 30 Jun
 2021 06:34:45 +0000
From: Xueming Li <xuemingl@nvidia.com>
To: <dev@dpdk.org>
CC: Thomas Monjalon <thomas@monjalon.net>, <stable@dpdk.org>, Christian
 Ehrhardt <christian.ehrhardt@canonical.com>, Yuanhan Liu
 <yuanhan.liu@linux.intel.com>
Date: Wed, 30 Jun 2021 14:34:15 +0800
Message-ID: <20210630063416.9550-2-xuemingl@nvidia.com>
X-Mailer: git-send-email 2.25.1
In-Reply-To: <20210630063416.9550-1-xuemingl@nvidia.com>
References: <20210616040324.311461-1-xuemingl@nvidia.com>
 <20210630063416.9550-1-xuemingl@nvidia.com>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Content-Type: text/plain
X-Originating-IP: [172.20.187.6]
X-ClientProxiedBy: HQMAIL111.nvidia.com (172.20.187.18) To
 HQMAIL107.nvidia.com (172.20.187.13)
X-EOPAttributedMessage: 0
X-MS-PublicTrafficType: Email
X-MS-Office365-Filtering-Correlation-Id: cc06b86e-b48d-486c-ecc9-08d93b912863
X-MS-TrafficTypeDiagnostic: DM6PR12MB4153:
X-LD-Processed: 43083d15-7273-40c1-b7db-39efd9ccc17a,ExtAddr
X-Microsoft-Antispam-PRVS: <DM6PR12MB41531D4B8300F86802BC2225A1019@DM6PR12MB4153.namprd12.prod.outlook.com>
X-MS-Oob-TLC-OOBClassifiers: OLM:363;
X-MS-Exchange-SenderADCheck: 1
X-Microsoft-Antispam: BCL:0;
X-Microsoft-Antispam-Message-Info: MnhobgQubRbnvDciljBu+fc1xCu568/RqhSV+xxg9HXHb+exmTHvNgP2SugiPGA22H+OqtAogV/lScQxqqj2waqJ1depgu7smlkKZzR/71fRjDDA9cK5JaoSXbL8OmzEYe7cDdRb2KWdw7IYHkCN7hMdQ5EqbUfNHAgl5mAxVa1/AqaV27f1cG9uiCjoLI3C3pmgXDVa1jsDGrOcoCS1jWTVqhLAo0j9xWCal0i9HFbrbqZHblY/nYUsC5w7s8j4rgcmrpsjPQwleWD3cBEeDouM3qHPVf8FQaRnZUvurtxljzmg5Dupo+8A6Sd4iZzWNDRd2/BjPuzMayW9dqVNWY3YErpzNjbFzSIPDRqECXYP6SOmNMS148+HnzkGENcnOPPgfa7Q8wntFNqjGkHGY4PFRJXRTLrWT5PZeCrjyV2+6M3hETpIb7PjtFsSUfIWGe4sgGnZn5SrjJfG/HV0ixJBD3dx9XauzjDCNg088h5E1NLC1LAxEVv8jBUXG33JZ15EatAPduUDzV+hVxnwWWNbFjY+7d/IUbmlkh56yTlZA2oby5FjGlfsw4gvPobcGRfuxeXpxSNJ+qk7x+35y/yrmKdX6IKio/wv8hs1p17IlO5o7CA5hnMYmLLZZQS3mmtz/NhYnY8Ekr0guQgX9Qnl3YDWhq6/wTKUtzdUgxHXWZ3/mCxvgB04N+DECtIu7lxS9u6S63mhSYLX4yzdBw==
X-Forefront-Antispam-Report: CIP:216.228.112.34; CTRY:US; LANG:en; SCL:1; SRV:;
 IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:schybrid03.nvidia.com; CAT:NONE;
 SFS:(4636009)(346002)(376002)(136003)(39860400002)(396003)(36840700001)(46966006)(336012)(54906003)(86362001)(47076005)(6286002)(426003)(316002)(36860700001)(2616005)(5660300002)(55016002)(4326008)(1076003)(70586007)(70206006)(478600001)(36756003)(82740400003)(2906002)(26005)(83380400001)(8676002)(8936002)(356005)(7636003)(6916009)(186003)(16526019)(6666004)(82310400003)(7696005);
 DIR:OUT; SFP:1101; 
X-OriginatorOrg: Nvidia.com
X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Jun 2021 06:34:48.2560 (UTC)
X-MS-Exchange-CrossTenant-Network-Message-Id: cc06b86e-b48d-486c-ecc9-08d93b912863
X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a
X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a; Ip=[216.228.112.34];
 Helo=[mail.nvidia.com]
X-MS-Exchange-CrossTenant-AuthSource: CO1NAM11FT064.eop-nam11.prod.protection.outlook.com
X-MS-Exchange-CrossTenant-AuthAs: Anonymous
X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem
X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR12MB4153
Subject: [dpdk-stable] [PATCH v2 2/2] devtools: fix patches missing if range
 newer than HEAD
X-BeenThere: stable@dpdk.org
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: patches for DPDK stable branches <stable.dpdk.org>
List-Unsubscribe: <https://mails.dpdk.org/options/stable>,
 <mailto:stable-request@dpdk.org?subject=unsubscribe>
List-Archive: <http://mails.dpdk.org/archives/stable/>
List-Post: <mailto:stable@dpdk.org>
List-Help: <mailto:stable-request@dpdk.org?subject=help>
List-Subscribe: <https://mails.dpdk.org/listinfo/stable>,
 <mailto:stable-request@dpdk.org?subject=subscribe>
Errors-To: stable-bounces@dpdk.org
Sender: "stable" <stable-bounces@dpdk.org>

Current fix scan scripts scanned specified range in HEAD branch.
When users ran it in an earlier branch, few patches were scanned
due to the fixes in the range are newer and not merged to HEAD
branch.

This patch introduces optional <branch> argument, default to HEAD
if not specified. Checks the <range> specified in parameter must
being merged in <branch>.

Fixes: 752d8e097ec1 ("scripts: show fixes with release version of bug")
Cc: Thomas Monjalon <thomas@monjalon.net>
Cc: stable@dpdk.org
Cc: Christian Ehrhardt <christian.ehrhardt@canonical.com>

Signed-off-by: Xueming Li <xuemingl@nvidia.com>
---
 devtools/git-log-fixes.sh | 23 +++++++++++++++++------
 1 file changed, 17 insertions(+), 6 deletions(-)

diff --git a/devtools/git-log-fixes.sh b/devtools/git-log-fixes.sh
index 153ba5b438..51d8b19942 100755
--- a/devtools/git-log-fixes.sh
+++ b/devtools/git-log-fixes.sh
@@ -4,7 +4,7 @@
 
 print_usage ()
 {
-	echo "usage: $(basename $0) [-h] <git_range>"
+	echo "usage: $(basename $0) [-h] <git_range> [<branch>]"
 }
 
 print_help ()
@@ -15,6 +15,7 @@ print_help ()
 	Find fixes to backport on previous versions.
 	It looks for the word "fix" in the headline or a tag "Fixes" or "Reverts".
 	The oldest bug origin is printed as well as partially fixed versions.
+	It looks into current branch or the branch specified.
 	END_OF_HELP
 }
 
@@ -33,14 +34,22 @@ while getopts h ARG ; do
 done
 shift $(($OPTIND - 1))
 [ $# -ge 1 ] || usage_error 'range argument required'
-range="$*"
+range="$1"
+branch="$2"
+
+[ -n "$branch" ] || branch="HEAD"
+refbranch=$(git rev-parse --abbrev-ref $branch)
+range_last=$(git log --oneline $range |head -n1|cut -d' ' -f1)
+if ! git branch -a --contains $range_last |grep -q -e " $refbranch$" -e " remotes/$refbranch$"; then
+	echo "range $range not included by branch $refbranch"
+	exit 1
+fi
 
 # get major release version of a commit
 commit_version () # <hash>
 {
 	local VER="v*.*"
 	# use current branch as history reference
-	local refbranch=$(git rev-parse --abbrev-ref HEAD)
 	local tag=$( (git tag -l "$VER" --contains $1 --sort=creatordate --merged $refbranch 2>&- ||
 		# tag --merged option has been introduced in git 2.7.0
 		# below is a fallback in case of old git version
@@ -49,9 +58,11 @@ commit_version () # <hash>
 			sed "s,.\+,$t,"
 		done) |
 		head -n1)
-	if [ -z "$tag" ] ; then
-		# before -rc1 tag of release in progress
-		cat VERSION | cut -d'.' -f-2
+	if [ -z "$tag" ]; then
+		if [ "$branch" = 'HEAD' ]; then
+			# before -rc1 tag of release in progress
+			cat VERSION | cut -d'.' -f-2
+		fi
 	else
 		echo $tag | sed 's,^v,,' | sed 's,-rc.*,,'
 	fi
-- 
2.25.1