[PATCH 15/18] dim: support multiple remotes for branches

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


Still left to do is fixing up create-branch and remove-branch.
Everything else should work here now.

Signed-off-by: Daniel Vetter <daniel.vetter at intel.com>
---
 dim | 36 ++++++++++++++++++++++++++----------
 1 file changed, 26 insertions(+), 10 deletions(-)

diff --git a/dim b/dim
index 4d5008ecce11..fc99108b6e55 100755
--- a/dim
+++ b/dim
@@ -163,7 +163,8 @@ if [ "$subcommand" != "setup" -a "$subcommand" != "help" -a "$subcommand" != "us
 	#
 
 	dim_branches=`(source $DIM_PREFIX/drm-rerere/nightly.conf ; echo $nightly_branches) | \
-		xargs -n 1 echo | grep '^origin' | sed -e 's/^origin\///'`
+		xargs -n 1 echo | grep '^\(drm-intel\|drm-misc\)' | \
+		sed -e 's/^\(drm-intel\|drm-misc\)\///'`
 fi
 
 function dim_uptodate
@@ -209,6 +210,14 @@ function get_remote_name
 	echo $remote
 }
 
+function get_remote_for_branch
+{
+	local remote=`git rev-parse --abbrev-ref --symbolic-full-name $1@{upstream}`
+	remote=${remote%%/*}
+
+	echo $remote
+}
+
 # get message id from file
 # $1 = file
 message_get_id ()
@@ -434,12 +443,14 @@ function dim_push_branch
 		exit 1
 	fi
 
-	branch=$1
+	local branch=$1
 	shift
 
 	assert_branch $branch
 
-	git push $DRY_RUN $DIM_DRM_INTEL_REMOTE $branch "$@"
+	local remote=`get_remote_for_branch $branch`
+
+	git push $DRY_RUN $remote $branch "$@"
 
 	dim_rebuild_nightly
 }
@@ -715,7 +726,11 @@ function dim_checkout
 
 	dim_cd $1
 	if [[ `git branch --list $1` ==  "" ]] ; then
-		git checkout -t $DIM_DRM_INTEL_REMOTE/$1
+		if [[ `git branch --list --remote $1` == "" ]] ; then
+			git checkout -t $DIM_DRM_INTEL_REMOTE/$1
+		else
+			git checkout -t $1
+		fi
 	else
 		git checkout $1
 	fi
@@ -999,8 +1014,9 @@ function dim_pull_request
 		exit 1
 	fi
 
-	branch=$1
-	upstream=$2
+	local branch=$1
+	local upstream=$2
+	local remote=`get_remote_for_branch $1`
 
 	if [ "$branch" != "drm-intel-next" ]; then
 		assert_branch $branch
@@ -1013,13 +1029,13 @@ function dim_pull_request
 
 	if [ "$branch" = "drm-intel-next" ]; then
 		# drm-intel-next pulls have been tagged using dim update-next
-		drm_intel_next_tags=`git log $DIM_DRM_INTEL_REMOTE/drm-intel-next ^$upstream --decorate | grep "(.*tag: drm-intel-next-" | sed -e "s/^.*(.*tag: \(drm-intel-next-[^ ,]*\).*)$/\1/"`
+		drm_intel_next_tags=`git log $branch@{upstream} ^$upstream --decorate | grep "(.*tag: drm-intel-next-" | sed -e "s/^.*(.*tag: \(drm-intel-next-[^ ,]*\).*)$/\1/"`
 		prep_pull_mail $drm_intel_next_tags
-		tag=`git describe --all --exact $DIM_DRM_INTEL_REMOTE/drm-intel-next`
+		tag=`git describe --all --exact $branch@{upstream}`
 	else
 		tag=$branch-$today
-		$DRY git tag -f $tag $DIM_DRM_INTEL_REMOTE/$branch
-		$DRY git push -f $DIM_DRM_INTEL_REMOTE $tag
+		$DRY git tag -f $tag $branch@{upstream}
+		$DRY git push -f $remote $tag
 		prep_pull_mail
 	fi
 
-- 
2.9.3



More information about the dri-devel mailing list