1
0
mirror of https://github.com/git/git.git synced 2024-09-29 17:51:22 +02:00
git/lib/branch.tcl
Shawn O. Pearce d41b43eb4c git-gui: Refactor branch switch to support detached head
This is a major rewrite of the way we perform switching between
branches and the subsequent update of the working directory.  Like
core Git we now use a single code path to perform all changes: our
new checkout_op class.  We also use it for branch creation/update
as it integrates the tracking branch fetch process along with a
very basic merge (fast-forward and reset only currently).

Because some users have literally hundreds of local branches we
use the standard revision picker (with its branch filtering tool)
to select the local branch, rather than keeping all of the local
branches in the Branch menu.  The branch menu listing out all of
the available branches is simply not sane for those types of huge
repositories.

Users can now checkout a detached head by ticking off the option
in the checkout dialog.  This option is off by default for the
obvious reason, but it can be easily enabled for any local branch
by simply checking it.  We also detach the head if any non local
branch was selected, or if a revision expression was entered.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2007-07-08 22:34:46 -04:00

36 lines
839 B
Tcl

# git-gui branch (create/delete) support
# Copyright (C) 2006, 2007 Shawn Pearce
proc load_all_heads {} {
global some_heads_tracking
set rh refs/heads
set rh_len [expr {[string length $rh] + 1}]
set all_heads [list]
set fd [open "| git for-each-ref --format=%(refname) $rh" r]
while {[gets $fd line] > 0} {
if {!$some_heads_tracking || ![is_tracking_branch $line]} {
lappend all_heads [string range $line $rh_len end]
}
}
close $fd
return [lsort $all_heads]
}
proc load_all_tags {} {
set all_tags [list]
set fd [open "| git for-each-ref --sort=-taggerdate --format=%(refname) refs/tags" r]
while {[gets $fd line] > 0} {
if {![regsub ^refs/tags/ $line {} name]} continue
lappend all_tags $name
}
close $fd
return $all_tags
}
proc radio_selector {varname value args} {
upvar #0 $varname var
set var $value
}