@matheusbsbs / matheus-bagliano / commits / 84e0bf1de4
Fork 0

git-gui: Started implementation of switch_branch.

This implementation of switch_branch is not yet finished, and thus it throws a "NOT FINISHED" error rather than completing the switch. But its a rough sketch of the procedure required. Signed-off-by: Shawn O. Pearce <spearce@spearce.org>

Shawn O. Pearce committed Nov 25, 2006 at 04:04 UTC 84e0bf1de4fcdada4698e2bd53bafaeaea6b5cbd
1 file changed +50 -1
git-gui
+50 -1
@@ -1643,10 +1643,59 @@ proc populate_branch_menu {m} {
1643 }
1644 }
1645
1646 -proc switch_branch {b} {
1646 +proc do_create_branch {} {
1647 error "NOT IMPLEMENTED"
1648 }
1649
1650 +proc do_delete_branch {} {
1651 + error "NOT IMPLEMENTED"
1652 +}
1653 +
1654 +proc switch_branch {b} {
1655 + global HEAD commit_type file_states current_branch
1656 + global selected_commit_type ui_comm
1657 +
1658 + if {![lock_index switch]} return
1659 +
1660 + # -- Backup the selected branch (repository_state resets it)
1661 + #
1662 + set new_branch $current_branch
1663 +
1664 + # -- Our in memory state should match the repository.
1665 + #
1666 + repository_state curType curHEAD curMERGE_HEAD
1667 + if {[string match amend* $commit_type]
1668 + && $curType eq {normal}
1669 + && $curHEAD eq $HEAD} {
1670 + } elseif {$commit_type ne $curType || $HEAD ne $curHEAD} {
1671 + info_popup {Last scanned state does not match repository state.
1672 +
1673 +Another Git program has modified this repository
1674 +since the last scan. A rescan must be performed
1675 +before the current branch can be changed.
1676 +
1677 +The rescan will be automatically started now.
1678 +}
1679 + unlock_index
1680 + rescan {set ui_status_value {Ready.}}
1681 + return
1682 + }
1683 +
1684 + # -- Toss the message buffer if we are in amend mode.
1685 + #
1686 + if {[string match amend* $curType]} {
1687 + $ui_comm delete 0.0 end
1688 + $ui_comm edit reset
1689 + $ui_comm edit modified false
1690 + }
1691 +
1692 + set selected_commit_type new
1693 + set current_branch $new_branch
1694 +
1695 + unlock_index
1696 + error "NOT FINISHED"
1697 +}
1698 +
1699 ######################################################################
1700 ##
1701 ## remote management