summaryrefslogtreecommitdiff
path: root/git-gui.sh
diff options
context:
space:
mode:
authorLibravatar Shawn O. Pearce <spearce@spearce.org>2007-05-28 12:52:57 -0400
committerLibravatar Shawn O. Pearce <spearce@spearce.org>2007-05-28 17:50:42 -0400
commit61f82ce79abe965c466bb7d3d1d89ae631fbbd24 (patch)
treef8aee7d20c68b5df4464b6b1ae981b513ee55f64 /git-gui.sh
parentgit-gui: Disable tearoff menus on Windows, Mac OS X (diff)
downloadtgif-61f82ce79abe965c466bb7d3d1d89ae631fbbd24.tar.xz
git-gui: Allow users to rename branches through 'branch -m'
Git's native command line interface has had branch renaming support for quite a while, through the -m/-M options to the git-branch command line tool. This is an extremely useful feature as users may decide that the name of their current branch is not an adequate description, or was just entered incorrectly when it was created. Even though most people would consider git-branch to be a Porcelain tool I'm using it here in git-gui as it is the only code that implements the rather complex set of logic needed to successfully rename a branch in Git. Currently that is along the lines of: *) Backup the ref *) Backup the reflog *) Delete the old ref *) Create the new ref *) Move the backed up reflog to the new ref *) Record the rename event in the reflog *) If the current branch was renamed, update HEAD *) If HEAD changed, record the rename event in the HEAD reflog *) Rename the [branch "$name"] section in the config file Since that is some rather ugly set of functionality to implement and get right, and some of it isn't easily accessible through the raw plumbing layer I'm just cheating by relying on the Porcelain. Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Diffstat (limited to 'git-gui.sh')
-rwxr-xr-xgit-gui.sh14
1 files changed, 14 insertions, 0 deletions
diff --git a/git-gui.sh b/git-gui.sh
index d640b143f3..755f0643be 100755
--- a/git-gui.sh
+++ b/git-gui.sh
@@ -200,6 +200,15 @@ proc is_config_true {name} {
}
}
+proc get_config {name} {
+ global repo_config
+ if {[catch {set v $repo_config($name)}]} {
+ return {}
+ } else {
+ return $v
+ }
+}
+
proc load_config {include_global} {
global repo_config global_config default_config
@@ -1420,6 +1429,11 @@ if {[is_enabled branch]} {
lappend disable_on_lock [list .mbar.branch entryconf \
[.mbar.branch index last] -state]
+ .mbar.branch add command -label {Rename...} \
+ -command branch_rename::dialog
+ lappend disable_on_lock [list .mbar.branch entryconf \
+ [.mbar.branch index last] -state]
+
.mbar.branch add command -label {Delete...} \
-command do_delete_branch
lappend disable_on_lock [list .mbar.branch entryconf \