diff mbox

[1/5] dim: Fixup remove-branch for working-trees

Message ID 20161111143645.817-1-daniel.vetter@ffwll.ch (mailing list archive)
State New, archived
Headers show

Commit Message

Daniel Vetter Nov. 11, 2016, 2:36 p.m. UTC
When there's a working-tree checkout we need to remove that first,
before removing the branch. git complains otherwise. Not sure,
but this might be a recently added more strict test for the git
worktree support, at least I believe the "branch still checkout out
in $dir" warning is new-ish.

v2: Move to the front, also include the git worktree prune call to
clean up the potential mess.

Fixes: f507c9230d31 ("dim: abstract dim_{create,remove}_branch")
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
---
 dim | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)
diff mbox

Patch

diff --git a/dim b/dim
index 66ea0dd918b3..afa552a77cb1 100755
--- a/dim
+++ b/dim
@@ -673,12 +673,14 @@  function dim_remove_branch
 
 	cd $DIM_PREFIX/$DIM_DRM_INTEL
 
-	if ! $DRY git branch -d $branch ; then
-		warn_or_fail "Can't remove $branch in working repo"
-	fi
-
 	if [[ -d $DIM_PREFIX/$branch ]] ; then
 		rm -R $DIM_PREFIX/$branch
+		git worktree prune &> /dev/null || true
+	fi
+
+	if [[ `git branch --list $branch`  != "" ]] &&
+	   ! $DRY git branch -d $branch  ; then
+			warn_or_fail "Can't remove $branch in working repo"
 	fi
 
 	cd $DIM_PREFIX/drm-intel-nightly