[PATCH 3/5] dim: sanity checks for merges

Daniel Vetter daniel.vetter at ffwll.ch
Wed May 23 07:27:02 UTC 2018


Just checks that merges aren't done without minimal thought.

Cc: Jani Nikula <jani.nikula at linux.intel.com>
Cc: Dave Airlie <airlied at gmail.com>
Signed-off-by: Daniel Vetter <daniel.vetter at intel.com>
---
 dim | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)

diff --git a/dim b/dim
index 2fa158231228..ff9e572726cb 100755
--- a/dim
+++ b/dim
@@ -785,6 +785,24 @@ function checkpatch_commit_push
 	return $rv
 }
 
+function checkmerge_commit_push
+{
+	local sha1 managed_branch rv body_text
+
+	sha1=$1
+	managed_branch=${2}
+	rv=0
+
+	body_text="$(git show $sha1 -s --format="format:%b" | grep -v "^$" | grep -v "^\S*:")"
+
+	if [[ -z "$body_text" ]] ; then
+		echoerr "$sha1 is lacking merge commit justification"
+		rv=1
+	fi
+
+	return $rv
+}
+
 function checkpatch_commit_push_range
 {
 	local rv managed_branch
@@ -797,6 +815,10 @@ function checkpatch_commit_push_range
 		checkpatch_commit_push $sha1 $managed_branch || rv=1
 	done
 
+	for sha1 in $(git rev-list "$@" --merges) ; do
+		checkmerge_commit_push $sha1 $managed_branch || rv=1
+	done
+
 	if [ $rv == "1" ] ; then
 		warn_or_fail "issues in commits detected"
 	fi
-- 
2.17.0



More information about the dim-tools mailing list