[PATCH] dim: check pull request baselines

Daniel Vetter daniel.vetter at ffwll.ch
Tue Feb 19 15:20:44 UTC 2019

We want explicit backmerges when a pull request pulls in random other
stuff. Motivated by a few recent examples.

- Fix typo in warn_or_fail (Maxime)
- check baselines before checking commits, usually a wrong baseline
  will result in tons of complaints about unreviewed patches and other
  stuff dim likes to be obsessed about.

Cc: Maxime Ripard <maxime.ripard at bootlin.com>
Cc: Dave Airlie <airlied at linux.ie>
Acked-by: Maxime Ripard <maxime.ripard at bootlin.com>
Reviewed-by: Joonas Lahtinen <joonas.lahtinen at linux.intel.com>
Signed-off-by: Daniel Vetter <daniel.vetter at intel.com>
 dim | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

diff --git a/dim b/dim
index 06188fea94c6..004ec69080e2 100755
--- a/dim
+++ b/dim
@@ -1048,6 +1048,23 @@ function apply_patch #patch_file
 	return $rv
+function check_merge_baseline
+	local pull_sha1 baseline_sha1 upstream_sha1
+	pull_sha1=$1
+	baseline_sha1=$2
+	upstream_sha1=$3
+	# the merge base between the pull and upstream is supposed to be in our
+	# tree already
+	if ! git merge-base --is-ancestor $(git merge-base $pull_sha1 $upstream_sha1) $baseline_sha1 ; then
+		echoerr "Pull request contains commits from $upstream_sha1"
+		echoerr "Please backmerge first"
+		warn_or_fail "Issues in pull request detected"
+	fi
 # ensure we're on branch $1, and apply patches. the rest of the arguments are
 # passed to git am.
@@ -1112,6 +1129,9 @@ function dim_apply_pull
 		warn_or_fail "Nothing in the pull request"
+	check_merge_baseline FETCH_HEAD $branch $(branch_to_remote drm-fixes)/drm-fixes
+	check_merge_baseline FETCH_HEAD $branch origin/master
 	checkpatch_commit_push_range 0 "HEAD..FETCH_HEAD"
 	if ! $DRY git pull --no-ff $pull_branch ; then

More information about the dim-tools mailing list