]> asedeno.scripts.mit.edu Git - git.git/blobdiff - lib/checkout_op.tcl
git-gui: Allow git-merge to use branch names in conflict markers
[git.git] / lib / checkout_op.tcl
index 05711151287b4a4ae595b8e73fd99575c2972073..170f737f611b48fa901e1789ec6d4f4d64834537 100644 (file)
@@ -201,6 +201,7 @@ method _update_ref {} {
                                        # The current branch is actually newer.
                                        #
                                        set new $cur
+                                       set new_hash $cur
                                } else {
                                        _error $this "Branch '$newbranch' already exists.\n\nIt cannot fast-forward to $new_expr.\nA merge is required."
                                        return 0
@@ -247,7 +248,7 @@ method _checkout {} {
        if {[lock_index checkout_op]} {
                after idle [cb _start_checkout]
        } else {
-               _error $this "Index is already locked."
+               _error $this "Staging area (index) is already locked."
                delete_this
        }
 }
@@ -384,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