[PATCH 3/5] dim: support git worktree for aux checkouts

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

 



If available by default. This saves quite a pile of disk-space that
imo making it the default is justified.

Note that this will break the rebuild-nightly script for now,
follow-up patches will fix that.

v2: Rebase to put the dim rework at the end of the series.

Signed-off-by: Daniel Vetter <daniel.vetter@xxxxxxxxx>
---
 dim | 36 +++++++++++++++++++++++++++---------
 1 file changed, 27 insertions(+), 9 deletions(-)

diff --git a/dim b/dim
index be3be7bc73d0..5d6cc37eb374 100755
--- a/dim
+++ b/dim
@@ -294,11 +294,20 @@ function check_conflicts
 	true
 }
 
+function rr_cache_dir
+{
+	if [ -d $DIM_PREFIX/drm-intel-nightly/.git/rr-cache/ ] ; then
+		echo $DIM_PREFIX/drm-intel-nightly/.git/rr-cache/
+	else
+		echo $DIM_PREFIX/$DIM_DRM_INTEL/.git/rr-cache/
+	fi
+}
+
 function update_rerere_cache
 {
 	cd $DIM_PREFIX/drm-intel-rerere/
 	git pull
-	cp rr-cache/* $DIM_PREFIX/drm-intel-nightly/.git/rr-cache/ -r
+	cp rr-cache/* `rr_cache_dir` -r
 	cd -
 }
 
@@ -306,7 +315,7 @@ function dim_revert_rerere
 {
 	cd $DIM_PREFIX/drm-intel-rerere/
 	git revert $1
-	rm $DIM_PREFIX/drm-intel-nightly/.git/rr-cache/ -Rf
+	rm `rr_cache_dir`/* -Rf
 }
 
 function dim_rebuild_nightly
@@ -403,7 +412,7 @@ function dim_rebuild_nightly
 	cd $rerere
 	if git branch --list rerere-cache | grep '\*' >& /dev/null ; then
 		git pull >& /dev/null
-		cp $DIM_PREFIX/$integration_branch/.git/rr-cache/* rr-cache -r
+		cp `rr_cache_dir`/* rr-cache -r
 		git add *.patch >& /dev/null || true
 		git add rr-cache/* > /dev/null
 		if git commit -m "$time: $integration_branch rerere cache update" >& /dev/null; then
@@ -1105,12 +1114,21 @@ function setup_aux_checkout # name remote
 	echo "Setting up $dir ..."
 
 	if [ ! -d $dir ]; then
-		git clone --reference=$DIM_PREFIX/$DIM_DRM_INTEL/.git $remote_url $dir
-		cd $dir
-		git config remote.origin.url $remote_url
-		echo "$DIM_PREFIX/$DIM_DRM_INTEL/.git/objects" > .git/objects/info/alternates
-		git repack -a -d -l
-		remote=origin
+		if git help worktree &> /dev/null ; then
+			cd $DIM_PREFIX/$DIM_DRM_INTEL
+			remote=`url_to_remote $remote_url`
+			if [[ `git branch --list $name` == "" ]] ; then
+				git branch --track $name $remote/$name
+			fi
+			git worktree add ../$dir $name
+		else
+			git clone --reference=$DIM_PREFIX/$DIM_DRM_INTEL/.git $remote_url $dir
+			cd $dir
+			git config remote.origin.url $remote_url
+			echo "$DIM_PREFIX/$DIM_DRM_INTEL/.git/objects" > .git/objects/info/alternates
+			git repack -a -d -l
+			remote=origin
+		fi
 	else
 		cd $dir
 		remote=`url_to_remote $remote_url`
-- 
2.10.2

_______________________________________________
Intel-gfx mailing list
Intel-gfx@xxxxxxxxxxxxxxxxxxxxx
https://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