Re: [PATCH] dim: Don't run stuff that needs dim setup

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, 19 Oct 2015, Jani Nikula <jani.nikula@xxxxxxxxx> wrote:
> 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.

This should've had an explanation saying that I'd prefer this kind of
approach, to reduce the special casing all around.

Other than that, there was really nothing wrong with your patch either.

BR,
Jani.


>
> Reported-by: Tvrtko Ursulin <tvrtko.ursulin@xxxxxxxxxxxxxxx>
> Signed-off-by: Jani Nikula <jani.nikula@xxxxxxxxx>
>
> ---
>
> 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
>
> _______________________________________________
> Intel-gfx mailing list
> Intel-gfx@xxxxxxxxxxxxxxxxxxxxx
> http://lists.freedesktop.org/mailman/listinfo/intel-gfx

-- 
Jani Nikula, Intel Open Source Technology Center
_______________________________________________
Intel-gfx mailing list
Intel-gfx@xxxxxxxxxxxxxxxxxxxxx
http://lists.freedesktop.org/mailman/listinfo/intel-gfx




[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]
  Powered by Linux