[Intel-gfx] [PATCH] dim: Don't run stuff that needs dim setup

Jani Nikula jani.nikula at intel.com
Mon Oct 19 06:41:23 PDT 2015


Yet another case where something fell off - we can't compute
dim_branches before setup is done, so handle the commands that don't
need setup first.

Reported-by: Tvrtko Ursulin <tvrtko.ursulin at linux.intel.com>
Signed-off-by: Jani Nikula <jani.nikula at intel.com>

---

this is on top of the man page extraction patch
---
 dim | 84 +++++++++++++++++++++++++++++++++++++--------------------------------
 1 file changed, 45 insertions(+), 39 deletions(-)

diff --git a/dim b/dim
index 03e2709159d5..530219d73358 100755
--- a/dim
+++ b/dim
@@ -139,26 +139,6 @@ else
     shift
 fi
 
-#
-# Sanity checks.
-#
-
-if [ "$subcommand" != "setup" -a "$subcommand" != "help" ]; then
-	for d in $DIM_PREFIX $DIM_PREFIX/$DIM_DRM_INTEL $DIM_PREFIX/drm-intel-rerere $DIM_PREFIX/drm-intel-nightly; do
-		if [ ! -d $d ]; then
-			echo "$d is missing, please check your configuration and/or run dim setup"
-			exit 1
-		fi
-	done
-fi
-
-#
-# Internal configuration that depends on a sane setup.
-#
-
-dim_branches=`(source $DIM_PREFIX/drm-intel-rerere/nightly.conf ; echo $nightly_branches) | \
-	xargs -n 1 echo | grep '^origin' | sed -e 's/^origin\///'`
-
 # get message id from file
 # $1 = file
 message_get_id ()
@@ -684,10 +664,53 @@ function assert_branch
 	fi
 }
 
+#
+# Handle subcommands that must work without a sane setup.
+#
 case "$subcommand" in
 	setup)
 		setup_dim
 		;;
+	help)
+		manpage=$DIM_PREFIX/maintainer-tools/dim.rst
+		if [ ! -e "$manpage" ]; then
+			manpage=$(dirname $(readlink -f $0))/dim.rst
+			if [ ! -e "$manpage" ]; then
+				echo "Can't find the man page. See http://cgit.freedesktop.org/drm-intel/tree/dim.rst?h=maintainer-tools"
+				exit 1
+			fi
+		fi
+
+		if hash rst2man 2>/dev/null; then
+			renderer=rst2man
+			pager="man -l -"
+		else
+			renderer=cat
+			pager=${PAGER:-cat}
+		fi
+
+		$renderer < $manpage | $pager
+		;;
+esac
+
+#
+# Sanity checks.
+#
+for d in $DIM_PREFIX $DIM_PREFIX/$DIM_DRM_INTEL $DIM_PREFIX/drm-intel-rerere $DIM_PREFIX/drm-intel-nightly; do
+	if [ ! -d $d ]; then
+		echo "$d is missing, please check your configuration and/or run dim setup"
+		exit 1
+	fi
+done
+
+#
+# Internal configuration that depends on a sane setup.
+#
+dim_branches=`(source $DIM_PREFIX/drm-intel-rerere/nightly.conf ; echo $nightly_branches) | \
+	xargs -n 1 echo | grep '^origin' | sed -e 's/^origin\///'`
+
+
+case "$subcommand" in
 	nightly-forget)
 		cd $DIM_PREFIX/drm-intel-nightly
 		git fetch origin >& /dev/null
@@ -964,24 +987,7 @@ case "$subcommand" in
 		rm drivers/gpu/drm/i915/*.ko &> /dev/null || true
 		make C=1 drivers/gpu/drm/i915/i915.ko
 		;;
-	help|*)
-		manpage=$DIM_PREFIX/maintainer-tools/dim.rst
-		if [ ! -e "$manpage" ]; then
-			manpage=$(dirname $(readlink -f $0))/dim.rst
-			if [ ! -e "$manpage" ]; then
-				echo "Can't find the man page. See http://cgit.freedesktop.org/drm-intel/tree/dim.rst?h=maintainer-tools"
-				exit 1
-			fi
-		fi
-
-		if hash rst2man 2>/dev/null; then
-			renderer=rst2man
-			pager="man -l -"
-		else
-			renderer=cat
-			pager=${PAGER:-cat}
-		fi
-
-		$renderer < $manpage | $pager
+	*)
+		echo "Unknown command '$subcommand'. Try 'dim help'."
 		;;
 esac
-- 
2.1.4



More information about the Intel-gfx mailing list