[Intel-gfx] [PATCH 11/18] dim: use git branch --list

Daniel Vetter daniel.vetter at ffwll.ch
Fri Oct 21 19:36:53 UTC 2016


... instead of git branch | grep. Handles submatches and branches
starting with - reliably. Motivated by a review from Jani.

Cc: Jani Nikula <jani.nikula at linux.intel.com>
Signed-off-by: Daniel Vetter <daniel.vetter at intel.com>
---
 dim | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/dim b/dim
index 5996306cddfb..d01407a7b10c 100755
--- a/dim
+++ b/dim
@@ -319,7 +319,7 @@ function dim_rebuild_nightly
 	source $rerere/nightly.conf
 
 	cd $DIM_PREFIX/$integration_branch
-	if ! git branch | grep $integration_branch | grep '\*' >& /dev/null ; then
+	if ! git branch --list $integration_branch | grep '\*' >& /dev/null ; then
 		echo "Branch setup for the integration repo is borked"
 		exit 1
 	fi
@@ -398,7 +398,7 @@ function dim_rebuild_nightly
 
 	echo -n "Updating rerere cache... "
 	cd $rerere
-	if git branch | grep rerere-cache | grep '\*' >& /dev/null ; then
+	if git branch --list rerere-cache | grep '\*' >& /dev/null ; then
 		git pull >& /dev/null
 		cp `rr_cache_dir`/* rr-cache -r
 		git add *.patch >& /dev/null || true
@@ -707,7 +707,7 @@ function dim_checkout
 	fi
 
 	dim_cd $1
-	if ! git branch | grep $1 > /dev/null ; then
+	if [[ `git branch --list $1` ==  "" ]] ; then
 		git checkout -t $DIM_DRM_INTEL_REMOTE/$1
 	else
 		git checkout $1
@@ -1095,7 +1095,7 @@ function setup_aux_checkout # name remote
 		if git help worktree &> /dev/null ; then
 			cd $DIM_PREFIX/$DIM_DRM_INTEL
 			remote=`get_remote_name $remote_url`
-			if ! git branch | grep $name > /dev/null ; then
+			if [[ `git branch --list $name` == "" ]] ; then
 				git branch --track $name $remote/$name
 			fi
 			git worktree add ../$dir $name
@@ -1111,7 +1111,7 @@ function setup_aux_checkout # name remote
 		cd $dir
 		remote=`get_remote_name $remote_url`
 	fi
-	if ! git branch | grep $name > /dev/null ; then
+	if [[ `git branch --list $name` == "" ]] ; then
 		git checkout -t $remote/$name
 	fi
 	cd ..
-- 
2.9.3



More information about the Intel-gfx mailing list