[PATCH 2/2] git-gui: always default to the last merged branch in remote delete

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

 



This is useful if you are directly working together with other
developers pushing feature branches on a shared remote. You typically
push feature branches to the remote so others can review. Once they are
satisfied and the branch is merged into the main branch it needs to be
deleted on the server.

Since we did not yet have a preselected default branch in the remote
delete dialog lets use the last merged branch if it is found on the
server.

Signed-off-by: Heiko Voigt <hvoigt@xxxxxxxxxx>
---
 git-gui.sh                   |    4 ++++
 lib/merge.tcl                |    2 ++
 lib/remote_branch_delete.tcl |    9 ++++++++-
 3 files changed, 14 insertions(+), 1 deletions(-)

diff --git a/git-gui.sh b/git-gui.sh
index 886719a..d96df63 100755
--- a/git-gui.sh
+++ b/git-gui.sh
@@ -139,6 +139,10 @@ if {$_trace >= 0} {
 	set _trace 0
 }
 
+# variable for the last merged branch (useful for a default when deleting
+# branches).
+set _last_merged_branch {}
+
 proc shellpath {} {
 	global _shellpath env
 	if {[string match @@* $_shellpath]} {
diff --git a/lib/merge.tcl b/lib/merge.tcl
index 5cded23..460d32f 100644
--- a/lib/merge.tcl
+++ b/lib/merge.tcl
@@ -83,6 +83,7 @@ method _visualize {} {
 
 method _start {} {
 	global HEAD current_branch remote_url
+	global _last_merged_branch
 
 	set name [_rev $this]
 	if {$name eq {}} {
@@ -109,6 +110,7 @@ method _start {} {
 	regsub ^refs/heads/ $branch {} branch
 	puts $fh "$cmit\t\tbranch '$branch' of $remote"
 	close $fh
+	set _last_merged_branch $branch
 
 	set cmd [list git]
 	lappend cmd merge
diff --git a/lib/remote_branch_delete.tcl b/lib/remote_branch_delete.tcl
index f872a3d..fcc06d0 100644
--- a/lib/remote_branch_delete.tcl
+++ b/lib/remote_branch_delete.tcl
@@ -251,7 +251,7 @@ method _write_url        {args} { set urltype url    }
 method _write_check_head {args} { set checktype head }
 
 method _write_head_list {args} {
-	global current_branch
+	global current_branch _last_merged_branch
 
 	$head_m delete 0 end
 	foreach abr $head_list {
@@ -267,6 +267,13 @@ method _write_head_list {args} {
 			set check_head $current_branch
 		}
 	}
+	set lmb [lsearch -exact -sorted $head_list $_last_merged_branch]
+	if {$lmb >= 0} {
+		$w.heads.l conf -state normal
+		$w.heads.l select set $lmb
+		$w.heads.l yview $lmb
+		$w.heads.l conf -state disabled
+	}
 }
 
 method _write_urltype {args} {
-- 
1.7.4.34.gd2cb1

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]