Code

git-gui: Fix detaching current branch during checkout
authorShawn O. Pearce <spearce@spearce.org>
Sun, 2 Sep 2007 19:30:26 +0000 (15:30 -0400)
committerShawn O. Pearce <spearce@spearce.org>
Tue, 4 Sep 2007 03:01:44 +0000 (23:01 -0400)
If the user tried to detach their HEAD while keeping the working
directory on the same commit we actually did not completely do
a detach operation internally.  The problem was caused by git-gui
not forcing the HEAD symbolic ref to be updated to a SHA-1 hash
when we were not switching revisions.  Now we update the HEAD ref
if we aren't currently detached or the hashes don't match.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
lib/checkout_op.tcl

index 170f737f611b48fa901e1789ec6d4f4d64834537..76f04f2854e85d51caface604d4fc10627f67620 100644 (file)
@@ -396,7 +396,7 @@ method _after_readtree {} {
                        set is_detached 0
                }
        } else {
-               if {$new_hash ne $HEAD} {
+               if {!$is_detached || $new_hash ne $HEAD} {
                        append log " to $new_expr"
                        if {[catch {
                                        _detach_HEAD $log $new_hash