shithub: riscv

Download patch

ref: 0d9119da0f6e85e4263fd790989b1851dd3d104d
parent: b237834cde5a02270539d8a3f81bd64bd5cb822c
author: Ori Bernstein <ori@eigenstate.org>
date: Sat Oct 28 14:10:34 EDT 2023

git/branch: prevent deleting current branch, skip dirty check for deleting branches

--- a/sys/src/cmd/git/branch
+++ b/sys/src/cmd/git/branch
@@ -48,8 +48,11 @@
 modified=`$nl{git/query -c HEAD $base | grep '^[^-]' | subst '^..'}
 deleted=`$nl{git/query -c HEAD $base | grep '^-' | subst '^..'}
 
+# if we delete the current branch without switching, bad things happen
+if(~ $delete 1 && ~ `{git/query HEAD} `{git/query $branch})
+	die 'cannot delete current branch'
 # if we're not merging, don't clobber existing changes.
-if(~ $#merge 0){
+if(~ $#merge 0 && ! $delete){
 	if(! ~ $#modified 0 || ! ~ $#deleted 0){
 		git/walk -fRMA $modified $deleted || 
 			die 'uncommitted changes would be clobbered'