[PATCH 2/2] dim: sanity-check config settings

Daniel Vetter daniel.vetter at ffwll.ch
Tue Aug 21 12:08:19 UTC 2018


Shashank wanted to reuse his drm-tip repo for DIM_REPO, which doesn't
work great. Catch this.

Also group the various check functions all together for a bit of OCD.

Cc: Shashank Sharma <shashank.sharma at intel.com>
Signed-off-by: Daniel Vetter <daniel.vetter at intel.com>
---
 dim | 43 ++++++++++++++++++++++++++-----------------
 1 file changed, 26 insertions(+), 17 deletions(-)

diff --git a/dim b/dim
index a1c194318b56..5040d6b046b2 100755
--- a/dim
+++ b/dim
@@ -316,20 +316,6 @@ function dim_uptodate
 	fi
 }
 
-function check_for_updates
-{
-	local stamp stampfile
-
-	stampfile=$HOME/.dim-update-check-timestamp
-
-	# daily check for updates based on file timestamp
-	stamp=$(stat --printf=%Y $stampfile 2>/dev/null || echo -n 0)
-	if [[ $((stamp + 24*60*60)) -lt $(date +%s) ]]; then
-		dim_uptodate || true
-		touch $stampfile
-	fi
-}
-
 function git_fetch_helper # remote
 {
 	local remote
@@ -373,7 +359,21 @@ function git_committer_email
 	echo $committer_email
 }
 
-function git_version_check
+function check_for_updates
+{
+	local stamp stampfile
+
+	stampfile=$HOME/.dim-update-check-timestamp
+
+	# daily check for updates based on file timestamp
+	stamp=$(stat --printf=%Y $stampfile 2>/dev/null || echo -n 0)
+	if [[ $((stamp + 24*60*60)) -lt $(date +%s) ]]; then
+		dim_uptodate || true
+		touch $stampfile
+	fi
+}
+
+function check_git_version
 {
 	local min_version="git version 2.8"
 
@@ -382,6 +382,14 @@ function git_version_check
 	fi
 }
 
+function check_dim_config
+{
+	if [[ "$DIM_REPO" == "drm-tip" || "$DIM_REPO" == "drm-rerere" || "$DIM_REPO" == "maintainer-tools" ]];  then
+		echoerr "WARNING: setting $DIM_REPO for DIM_REPO not allowed"
+		exit 1
+	fi
+}
+
 # get message id from file
 # $1 = file
 message_get_id ()
@@ -2389,6 +2397,8 @@ if [[ -n "${__dim_running:-}" ]]; then
 fi
 export __dim_running=1
 
+check_dim_config
+
 # Commands useful for developers don't need a full dim setup
 if list_developer_commands | grep -qx $subcmd; then
 	if [ -r $DIM_PREFIX/drm-rerere/$dim_integration_config ]; then
@@ -2404,9 +2414,8 @@ else
 
 	read_integration_config
 
-	# occasional check for dim updates
 	check_for_updates
-	git_version_check
+	check_git_version
 fi
 
 # throw away to not confuse list-aliases
-- 
2.18.0



More information about the dim-tools mailing list