diff options
author | Shawn O. Pearce <spearce@spearce.org> | 2007-07-22 04:49:06 -0400 |
---|---|---|
committer | Shawn O. Pearce <spearce@spearce.org> | 2007-07-23 01:28:35 -0400 |
commit | 7d5266a704ea55b11799bf0431d1648282f53d54 (patch) | |
tree | 0e7ce063c99e45d3b48fdf8bea261e25c0854939 | |
parent | a8139888f8d250c6d173ddbe892e98fc49763702 (diff) | |
download | git-7d5266a704ea55b11799bf0431d1648282f53d54.tar.gz git-7d5266a704ea55b11799bf0431d1648282f53d54.tar.xz |
git-gui: Avoid unnecessary symbolic-ref call during checkout
If we are checking out the branch we are already on then there is no
need to call symbolic-ref to update the HEAD pointer to the "new"
branch name, it is already correct.
Currently this situation does not happen very often, but it can be
seen in some workflows where the user always recreates their local
branch from a remote tracking branch and more-or-less ignores what
branch he/she is on right now. As they say, ignorance is bliss.
This case will however become a tad more common when we overload
checkout_op to actually also perform all of our merges. In that
case we will likely see that the branch we want to "checkout" is
the current branch, as we are actually just merging into it.
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
-rw-r--r-- | lib/checkout_op.tcl | 30 |
1 files changed, 16 insertions, 14 deletions
diff --git a/lib/checkout_op.tcl b/lib/checkout_op.tcl index 8c42ca800..40cc73a52 100644 --- a/lib/checkout_op.tcl +++ b/lib/checkout_op.tcl @@ -385,22 +385,24 @@ method _after_readtree {} { set rn [string length $rh] if {[string equal -length $rn $rh $new_ref]} { set new_branch [string range $new_ref $rn end] - append log " to $new_branch" - - if {[catch { - git symbolic-ref -m $log HEAD $new_ref - } err]} { - _fatal $this $err + if {$is_detached || $current_branch ne $new_branch} { + append log " to $new_branch" + if {[catch { + git symbolic-ref -m $log HEAD $new_ref + } err]} { + _fatal $this $err + } + set current_branch $new_branch + set is_detached 0 } - set current_branch $new_branch - set is_detached 0 } else { - append log " to $new_expr" - - if {[catch { - _detach_HEAD $log $new_hash - } err]} { - _fatal $this $err + if {$new_hash ne $HEAD} { + append log " to $new_expr" + if {[catch { + _detach_HEAD $log $new_hash + } err]} { + _fatal $this $err + } } set current_branch HEAD set is_detached 1 |