[PATCH 1/2] dim: reduce indent in commit_rerere_cache

Daniel Vetter daniel at ffwll.ch
Wed Oct 11 15:48:05 UTC 2017


On Wed, Oct 11, 2017 at 06:31:27PM +0300, Jani Nikula wrote:
> Bail out early on errors to reduce indent. Add local decls while at it.
> ---
>  dim | 52 +++++++++++++++++++++++++++-------------------------
>  1 file changed, 27 insertions(+), 25 deletions(-)
> 
> diff --git a/dim b/dim
> index f83f91ffff3b..4b65eb26f1a1 100755
> --- a/dim
> +++ b/dim
> @@ -589,39 +589,41 @@ function update_rerere_cache
>  
>  function commit_rerere_cache
>  {
> +	local remote file
> +
>  	echo -n "Updating rerere cache... "
>  
>  	cd $DIM_PREFIX/drm-rerere/
> -	if git_is_current_branch rerere-cache ; then
> -		remote=$(branch_to_remote rerere-cache)
> +	if ! git_is_current_branch rerere-cache; then
> +		echo "Fail: Branch setup for the rerere-cache is borked."
> +		exit 1
> +	fi
>  
> -		if ! git pull -q ; then
> -			echoerr "Failed to update the rerere cache."
> -			echoerr "Please manually run"
> -			echoerr "	$ cd $DIM_PREFIX/drm-rerere ; git pull"
> -			echoerr "and fixup any issues."
> +	remote=$(branch_to_remote rerere-cache)
>  
> -			return 1
> -		fi
> -		git add ./*.patch >& /dev/null || true
> -		for file  in $(git ls-files -- rr-cache); do
> -			if ! git log --since="60 days ago" --name-only -- $file | grep $file &> /dev/null; then
> -				git rm $file &> /dev/null || true
> -			fi
> -		done
> -		find rr-cache/ -mtime -1 -type f -not -name "thisimage*" -print0 | xargs -0 git add > /dev/null || true
> -		git rm rr-cache/rr-cache &> /dev/null || true
> -		if git commit -m "$time: $integration_branch rerere cache update" >& /dev/null; then
> -			echo -n "New commit. "
> -		else
> -			echo -n "Nothing changed. "
> +	if ! git pull -q; then
> +		echoerr "Failed to update the rerere cache."
> +		echoerr "Please manually run"
> +		echoerr "	$ cd $DIM_PREFIX/drm-rerere; git pull"
> +		echoerr "and fixup any issues."
> +
> +		return 1
> +	fi
> +	git add ./*.patch >& /dev/null || true
> +	for file  in $(git ls-files -- rr-cache); do
> +		if ! git log --since="60 days ago" --name-only -- $file | grep $file &> /dev/null; then
> +			git rm $file &> /dev/null || true
>  		fi
> -		echo -n "Pushing rerere cache... "
> -		git push $DRY_RUN $remote HEAD >& /dev/null && echo "Done."
> +	done
> +	find rr-cache/ -mtime -1 -type f -not -name "thisimage*" -print0 | xargs -0 git add > /dev/null || true
> +	git rm rr-cache/rr-cache &> /dev/null || true
> +	if git commit -m "$time: $integration_branch rerere cache update" >& /dev/null; then

Just noticed that we pass around $time as a global created in
dim_rebuild_tip ... Anway with the sob added:

Reviewed-by: Daniel Vetter <daniel.vetter at ffwll.ch>

> +		echo -n "New commit. "
>  	else
> -		echo "Fail: Branch setup for the rerere-cache is borked."
> -		exit 1
> +		echo -n "Nothing changed. "
>  	fi
> +	echo -n "Pushing rerere cache... "
> +	git push $DRY_RUN $remote HEAD >& /dev/null && echo "Done."
>  }
>  
>  function dim_rebuild_tip
> -- 
> 2.11.0
> 
> _______________________________________________
> dim-tools mailing list
> dim-tools at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dim-tools

-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch


More information about the dim-tools mailing list