From 2c7c2fc99b1ae1675622c0a1f1172ff2f09407f2 Mon Sep 17 00:00:00 2001
From: Jani Nikula <jani.nikula@intel.com>
Date: Thu, 23 Mar 2017 11:28:28 +0200
Subject: [PATCH] dim: abstract and fix maintainer scope check for dinq

Separate maintainer scope check from checkpatch, and only do the check
on applying patches. Also, fix the failures on grep not matching.

Fixes: 56e53a49e28f ("dim: declare and assign separately")
Acked-by: Daniel Vetter <daniel@ffwll.ch>
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
---
 dim | 33 ++++++++++++++++++++-------------
 1 file changed, 20 insertions(+), 13 deletions(-)

diff --git a/dim b/dim
index ddcc18f..268bc6c 100755
--- a/dim
+++ b/dim
@@ -698,6 +698,7 @@ function dim_apply_branch
 	fi
 
 	checkpatch_commit HEAD
+	check_maintainer $branch HEAD
 
 	eval $DRY $DIM_POST_APPLY_ACTION
 }
@@ -1080,6 +1081,25 @@ function dim_conf
 	dim_checkout drm-intel-next-fixes "$@"
 }
 
+# $1 branch
+# $2 commit
+function check_maintainer
+{
+	local branch commit
+
+	branch=$1
+	commit=$2
+
+        if [ "$branch" = "drm-intel-next-queued" ]; then
+		if non_i915_files=$(git diff-tree --no-commit-id --name-only -r $commit | \
+			grep -v "^\(drivers/gpu/drm/i915/\|include/drm/i915\|include/uapi/drm/i915\)") && [[ -n "$non_i915_files" ]]; then
+			echo -e "The following files are outside of i915 maintenance scope:\n"
+			echo "$non_i915_files"
+			echo -e "\nConfirm you have appropriate Acked-by and Reviewed-by for above files."
+		fi
+	fi
+}
+
 # $1 is the git sha1 to check
 function checkpatch_commit
 {
@@ -1094,19 +1114,6 @@ function checkpatch_commit
 	if bug_lines=$($cmd | grep -m 1 -B 1 '^\+.*\WBUG' | grep -c '^[+-].*\WBUG') && [[ "$bug_lines" = "1" ]]; then
 		warn_or_fail "New BUG macro added"
 	fi
-
-        if [ "$branch" = "drm-intel-next-queued" ]; then
-		# FIXME: this relies on local assignment not failing on command
-		# substitution failures
-		non_i915_files=$(git diff-tree --no-commit-id --name-only -r $commit | \
-			grep -v "^\(drivers/gpu/drm/i915/\|include/drm/i915\|include/uapi/drm/i915\)")
-
-		if [ -n "$non_i915_files" ]; then
-			echo -e "The following files are outside of i915 maintenance scope:\n"
-			echo "$non_i915_files"
-			echo -e "\nConfirm you have appropriate Acked-by and Reviewed-by for above files."
-		fi
-	fi
 }
 
 # turn $1 in to a git commit range
-- 
GitLab