From 2dfa54c6cb39c443652440f1ee6fdf5a6067364a Mon Sep 17 00:00:00 2001 From: "Shawn O. Pearce" Date: Mon, 16 Jul 2007 02:39:07 -0400 Subject: git-gui: Skip -dirty suffix on core git versions If the user is running a 'dirty' version of git (one compiled in a working directory with modified files) we want to just assume it was a committed version, as we really only look at the part that came from a real annotated tag anyway. Signed-off-by: Shawn O. Pearce diff --git a/git-gui.sh b/git-gui.sh index 2077261..bdb5571 100755 --- a/git-gui.sh +++ b/git-gui.sh @@ -544,6 +544,7 @@ if {![regsub {^git version } $_git_version {} _git_version]} { error_popup "Cannot parse Git version string:\n\n$_git_version" exit 1 } +regsub {-dirty$} $_git_version {} _git_version regsub {\.[0-9]+\.g[0-9a-f]+$} $_git_version {} _git_version regsub {\.rc[0-9]+$} $_git_version {} _git_version -- cgit v0.10.2-6-g49f6 From ec4fceece4a9f155afcadec254caff5cef781c67 Mon Sep 17 00:00:00 2001 From: "Shawn O. Pearce" Date: Mon, 16 Jul 2007 18:44:23 -0400 Subject: git-gui: Brown paper bag "dirty git version fix" My prior change to allow git-gui to run with a version of Git that was built from a working directory that had uncommitted changes didn't account for the pattern starting with -, and that confused Tcl. Signed-off-by: Shawn O. Pearce diff --git a/git-gui.sh b/git-gui.sh index bdb5571..3808451 100755 --- a/git-gui.sh +++ b/git-gui.sh @@ -544,7 +544,7 @@ if {![regsub {^git version } $_git_version {} _git_version]} { error_popup "Cannot parse Git version string:\n\n$_git_version" exit 1 } -regsub {-dirty$} $_git_version {} _git_version +regsub -- {-dirty$} $_git_version {} _git_version regsub {\.[0-9]+\.g[0-9a-f]+$} $_git_version {} _git_version regsub {\.rc[0-9]+$} $_git_version {} _git_version -- cgit v0.10.2-6-g49f6 From 6eb420ef61317b2efa2993868a6302afed6ae60a Mon Sep 17 00:00:00 2001 From: "Shawn O. Pearce" Date: Tue, 17 Jul 2007 01:50:10 -0400 Subject: git-gui: Always disable the Tcl EOF character when reading On Windows (which includes Cygwin) Tcl defaults to leaving the EOF character of input file streams set to the ASCII EOF character, but if that character were to appear in the data stream then Tcl will close the channel early. So we have to disable eofchar on Windows. Since the default is disabled on all platforms except Windows, we can just disable it everywhere to prevent any sort of read problem. Signed-off-by: Shawn O. Pearce diff --git a/git-gui.sh b/git-gui.sh index 3808451..d0b75c0 100755 --- a/git-gui.sh +++ b/git-gui.sh @@ -414,6 +414,7 @@ proc _open_stdout_stderr {cmd} { error $err } } + fconfigure $fd -eofchar {} return $fd } @@ -828,6 +829,7 @@ proc load_message {file} { if {[catch {set fd [open $f r]}]} { return 0 } + fconfigure $fd -eofchar {} set content [string trim [read $fd]] close $fd regsub -all -line {[ \r\t]+$} $content {} content diff --git a/lib/blame.tcl b/lib/blame.tcl index 4bdb9a2..1bcb4b4 100644 --- a/lib/blame.tcl +++ b/lib/blame.tcl @@ -370,6 +370,7 @@ method _load {jump} { $w_path conf -text [escape_path $path] if {$commit eq {}} { set fd [open $path r] + fconfigure $fd -eofchar {} } else { set fd [git_read cat-file blob "$commit:$path"] } diff --git a/lib/commit.tcl b/lib/commit.tcl index 46a78c1..0f3b16d 100644 --- a/lib/commit.tcl +++ b/lib/commit.tcl @@ -209,7 +209,7 @@ A good commit message has the following format: ui_status {Calling pre-commit hook...} set pch_error {} set fd_ph [open "| $pchook" r] - fconfigure $fd_ph -blocking 0 -translation binary + fconfigure $fd_ph -blocking 0 -translation binary -eofchar {} fileevent $fd_ph readable \ [list commit_prehook_wait $fd_ph $curHEAD $msg] } diff --git a/lib/diff.tcl b/lib/diff.tcl index 9cb9d06..e09e125 100644 --- a/lib/diff.tcl +++ b/lib/diff.tcl @@ -86,6 +86,7 @@ proc show_diff {path w {lno {}}} { set max_sz [expr {128 * 1024}] if {[catch { set fd [open $path r] + fconfigure $fd -eofchar {} set content [read $fd $max_sz] close $fd set sz [file size $path] -- cgit v0.10.2-6-g49f6 From 91464dfb102d6143182d8f312b68486e9dceb103 Mon Sep 17 00:00:00 2001 From: Julian Phillips Date: Tue, 17 Jul 2007 22:14:06 +0100 Subject: git-gui: Handle git versions of the form n.n.n.GIT The git-gui version check doesn't handle versions of the form n.n.n.GIT which you can get by installing from an tarball produced by git-archive. Without this change you get an error of the form: 'Error in startup script: expected version number but got "1.5.3.GIT"' Signed-off-by: Julian Phillips Signed-off-by: Shawn O. Pearce diff --git a/git-gui.sh b/git-gui.sh index d0b75c0..ebc2708 100755 --- a/git-gui.sh +++ b/git-gui.sh @@ -548,6 +548,7 @@ if {![regsub {^git version } $_git_version {} _git_version]} { regsub -- {-dirty$} $_git_version {} _git_version regsub {\.[0-9]+\.g[0-9a-f]+$} $_git_version {} _git_version regsub {\.rc[0-9]+$} $_git_version {} _git_version +regsub {\.GIT$} $_git_version {} _git_version proc git-version {args} { global _git_version -- cgit v0.10.2-6-g49f6 From 6f62b4f782c51bdf0dfdef3da5b5049c9006ff70 Mon Sep 17 00:00:00 2001 From: "Shawn O. Pearce" Date: Tue, 17 Jul 2007 22:31:16 -0400 Subject: git-gui: Delay searching for 'nice' until its really asked for Not every caller of 'git' or 'git_pipe' wants to use nice to lower the priority of the process its executing. In many cases we may never use the nice process to launch git. So we can avoid searching our $PATH to locate a suitable nice if we'll never actually use it. Signed-off-by: Shawn O. Pearce diff --git a/git-gui.sh b/git-gui.sh index ebc2708..5ca946a 100755 --- a/git-gui.sh +++ b/git-gui.sh @@ -367,16 +367,25 @@ proc _which {what} { return {} } +proc _lappend_nice {cmd_var} { + global _nice + upvar $cmd_var cmd + + if {![info exists _nice]} { + set _nice [_which nice] + } + if {$_nice ne {}} { + lappend cmd $_nice + } +} + proc git {args} { set opt [list exec] while {1} { switch -- [lindex $args 0] { --nice { - global _nice - if {$_nice ne {}} { - lappend opt $_nice - } + _lappend_nice opt } default { @@ -424,10 +433,7 @@ proc git_read {args} { while {1} { switch -- [lindex $args 0] { --nice { - global _nice - if {$_nice ne {}} { - lappend opt $_nice - } + _lappend_nice opt } --stderr { @@ -455,10 +461,7 @@ proc git_write {args} { while {1} { switch -- [lindex $args 0] { --nice { - global _nice - if {$_nice ne {}} { - lappend opt $_nice - } + _lappend_nice opt } default { @@ -525,7 +528,6 @@ if {$_git eq {}} { error_popup "Cannot find git in PATH." exit 1 } -set _nice [_which nice] ###################################################################### ## -- cgit v0.10.2-6-g49f6 From 2370164f3ceb833b9b4128d80bdfcc81e58682f9 Mon Sep 17 00:00:00 2001 From: "Shawn O. Pearce" Date: Tue, 17 Jul 2007 22:45:53 -0400 Subject: git-gui: Don't crash in ask_popup if we haven't mapped main window yet If we have more than our desired number of objects and we try to open the "Do you want to repack now?" dialog we cannot include a -parent . argument if the main window has not been mapped yet. On Mac OS X it appears this window isn't mapped right away, so we had better hang avoid including it. Signed-off-by: Shawn O. Pearce diff --git a/lib/error.tcl b/lib/error.tcl index d0253ae..16a2218 100644 --- a/lib/error.tcl +++ b/lib/error.tcl @@ -51,12 +51,15 @@ proc ask_popup {msg} { if {[reponame] ne {}} { append title " ([reponame])" } - return [tk_messageBox \ - -parent . \ + set cmd [list tk_messageBox \ -icon question \ -type yesno \ -title $title \ -message $msg] + if {[winfo ismapped .]} { + lappend cmd -parent . + } + eval $cmd } proc hook_failed_popup {hook msg} { -- cgit v0.10.2-6-g49f6 From d164b7548ab61e50d4404d1fbc0da3a8f6c0cc87 Mon Sep 17 00:00:00 2001 From: "Shawn O. Pearce" Date: Tue, 17 Jul 2007 22:49:44 -0400 Subject: git-gui: Change our initial GC hint to be an estimate Instead of running a full git-count-objects to count all of the loose objects we can get a reasonably close approximation by counting the number of files in the .git/objects/42 subdirectory. This works out reasonably well because the SHA-1 hash has a fairly even distribution, so every .git/objects/?? subdirectory should get a relatively equal number of files. If we have at least 8 files in .git/objects/42 than it is very likely there is about 8 files in every other directory, leaving us with around 2048 loose objects. This check is much faster, as we need to only perform a readdir of a single directory, and we can do it directly from Tcl and avoid the costly fork+exec. All of the credit on how clever this is goes to Linus Torvalds; he suggested using this trick in a post commit hook to repack every so often. Signed-off-by: Shawn O. Pearce diff --git a/git-gui.sh b/git-gui.sh index 5ca946a..cd2b093 100755 --- a/git-gui.sh +++ b/git-gui.sh @@ -2560,12 +2560,21 @@ if {[is_enabled transport]} { # -- Only suggest a gc run if we are going to stay running. # if {[is_enabled multicommit]} { - set object_limit 2000 - if {[is_Windows]} {set object_limit 200} - regexp {^([0-9]+) objects,} [git count-objects] _junk objects_current + set object_limit 8 + if {[is_Windows]} { + set object_limit 1 + } + set objects_current [llength [glob \ + -directory [gitdir objects 42] \ + -nocomplain \ + -tails \ + -- \ + *]] if {$objects_current >= $object_limit} { + set objects_current [expr {$objects_current * 256}] + set object_limit [expr {$object_limit * 256}] if {[ask_popup \ - "This repository currently has $objects_current loose objects. + "This repository currently has approximately $objects_current loose objects. To maintain optimal performance it is strongly recommended that you compress the database when more than $object_limit loose objects exist. @@ -2573,7 +2582,7 @@ Compress the database now?"] eq yes} { do_gc } } - unset object_limit _junk objects_current + unset object_limit objects_current } lock_index begin-read -- cgit v0.10.2-6-g49f6 From 301dfaa9daeb64c66d616efe50fac29d542c9414 Mon Sep 17 00:00:00 2001 From: "Shawn O. Pearce" Date: Tue, 17 Jul 2007 23:09:31 -0400 Subject: git-gui: Let the user continue even if we cannot understand git version Some users may do odd things, like tag their own private version of Git with an annotated tag such as 'testver', then compile that git and try to use it with git-gui. In such a case `git --version` will give us 'git version testver', which is not a numeric argument that we can pass off to our version comparsion routine. We now check that the cleaned up git version is a going to pass the version comparsion routine without failure. If it has a non-numeric component, or lacks at least a minor revision then we ask the user to confirm they really want to use this version of git within git-gui. If they do we shall assume it is git 1.5.0 and run with only the code that will support. Signed-off-by: Shawn O. Pearce diff --git a/git-gui.sh b/git-gui.sh index cd2b093..2127557 100755 --- a/git-gui.sh +++ b/git-gui.sh @@ -547,11 +547,35 @@ if {![regsub {^git version } $_git_version {} _git_version]} { error_popup "Cannot parse Git version string:\n\n$_git_version" exit 1 } + +set _real_git_version $_git_version regsub -- {-dirty$} $_git_version {} _git_version regsub {\.[0-9]+\.g[0-9a-f]+$} $_git_version {} _git_version regsub {\.rc[0-9]+$} $_git_version {} _git_version regsub {\.GIT$} $_git_version {} _git_version +if {![regexp {^[1-9]+(\.[0-9]+)+$} $_git_version]} { + catch {wm withdraw .} + if {[tk_messageBox \ + -icon warning \ + -type yesno \ + -default no \ + -title "[appname]: warning" \ + -message "Git version cannot be determined. + +$_git claims it is version '$_real_git_version'. + +[appname] requires at least Git 1.5.0 or later. + +Assume '$_real_git_version' is version 1.5.0? +"] eq {yes}} { + set _git_version 1.5.0 + } else { + exit 1 + } +} +unset _real_git_version + proc git-version {args} { global _git_version @@ -2586,4 +2610,7 @@ Compress the database now?"] eq yes} { } lock_index begin-read +if {![winfo ismapped .]} { + wm deiconify . +} after 1 do_rescan -- cgit v0.10.2-6-g49f6 From 3972b987d373759ae4868012fe8133ca1e26ea20 Mon Sep 17 00:00:00 2001 From: "Shawn O. Pearce" Date: Tue, 17 Jul 2007 23:20:56 -0400 Subject: git-gui: Delay the GC hint until after we are running I'm moving the code related to looking to see if we should GC now into a procedure closer to where it belongs, the database module. This reduces our script by a few lines for the single commit case (aka citool). But really it just is to help organize the code. We now perform the check after we have been running for at least 1 second. This way the main window has time to open up and our dialog (if we open it) will attach to the main window, instead of floating out in no-mans-land like it did before on Mac OS X. I had to use a wait of a full second here as a wait of 1 millisecond made our console install itself into the main window. Apparently we had a race condition with the console code where both the console and the main window thought they were the main window. Signed-off-by: Shawn O. Pearce diff --git a/git-gui.sh b/git-gui.sh index 2127557..0443129 100755 --- a/git-gui.sh +++ b/git-gui.sh @@ -2581,36 +2581,11 @@ if {[is_enabled transport]} { populate_push_menu } -# -- Only suggest a gc run if we are going to stay running. -# -if {[is_enabled multicommit]} { - set object_limit 8 - if {[is_Windows]} { - set object_limit 1 - } - set objects_current [llength [glob \ - -directory [gitdir objects 42] \ - -nocomplain \ - -tails \ - -- \ - *]] - if {$objects_current >= $object_limit} { - set objects_current [expr {$objects_current * 256}] - set object_limit [expr {$object_limit * 256}] - if {[ask_popup \ - "This repository currently has approximately $objects_current loose objects. - -To maintain optimal performance it is strongly recommended that you compress the database when more than $object_limit loose objects exist. - -Compress the database now?"] eq yes} { - do_gc - } - } - unset object_limit objects_current -} - lock_index begin-read if {![winfo ismapped .]} { wm deiconify . } after 1 do_rescan +if {[is_enabled multicommit]} { + after 1000 hint_gc +} diff --git a/lib/database.tcl b/lib/database.tcl index 87c815d..0657cc2 100644 --- a/lib/database.tcl +++ b/lib/database.tcl @@ -87,3 +87,30 @@ proc do_fsck_objects {} { lappend cmd --strict console::exec $w $cmd } + +proc hint_gc {} { + set object_limit 8 + if {[is_Windows]} { + set object_limit 1 + } + + set objects_current [llength [glob \ + -directory [gitdir objects 42] \ + -nocomplain \ + -tails \ + -- \ + *]] + + if {$objects_current >= $object_limit} { + set objects_current [expr {$objects_current * 256}] + set object_limit [expr {$object_limit * 256}] + if {[ask_popup \ + "This repository currently has approximately $objects_current loose objects. + +To maintain optimal performance it is strongly recommended that you compress the database when more than $object_limit loose objects exist. + +Compress the database now?"] eq yes} { + do_gc + } + } +} -- cgit v0.10.2-6-g49f6 From ba7cc6609e5726ddc59158b60ac01f5fc9717ab3 Mon Sep 17 00:00:00 2001 From: "Shawn O. Pearce" Date: Tue, 17 Jul 2007 23:23:56 -0400 Subject: git-gui: Move feature option selection before GIT_DIR init By moving our feature option determination up before we look for GIT_DIR we can make a decision about whether or not we need a working tree up front, before we look for GIT_DIR. A future change could then allow us to start in a bare Git repository if we only need access to the ODB. Signed-off-by: Shawn O. Pearce diff --git a/git-gui.sh b/git-gui.sh index 0443129..f13fa80 100755 --- a/git-gui.sh +++ b/git-gui.sh @@ -632,6 +632,43 @@ You are using [git-version]: ###################################################################### ## +## feature option selection + +if {[regexp {^git-(.+)$} [appname] _junk subcommand]} { + unset _junk +} else { + set subcommand gui +} +if {$subcommand eq {gui.sh}} { + set subcommand gui +} +if {$subcommand eq {gui} && [llength $argv] > 0} { + set subcommand [lindex $argv 0] + set argv [lrange $argv 1 end] +} + +enable_option multicommit +enable_option branch +enable_option transport + +switch -- $subcommand { +browser - +blame { + disable_option multicommit + disable_option branch + disable_option transport +} +citool { + enable_option singlecommit + + disable_option multicommit + disable_option branch + disable_option transport +} +} + +###################################################################### +## ## repository setup if {[catch { @@ -1598,43 +1635,6 @@ apply_config ###################################################################### ## -## feature option selection - -if {[regexp {^git-(.+)$} [appname] _junk subcommand]} { - unset _junk -} else { - set subcommand gui -} -if {$subcommand eq {gui.sh}} { - set subcommand gui -} -if {$subcommand eq {gui} && [llength $argv] > 0} { - set subcommand [lindex $argv 0] - set argv [lrange $argv 1 end] -} - -enable_option multicommit -enable_option branch -enable_option transport - -switch -- $subcommand { -browser - -blame { - disable_option multicommit - disable_option branch - disable_option transport -} -citool { - enable_option singlecommit - - disable_option multicommit - disable_option branch - disable_option transport -} -} - -###################################################################### -## ## ui construction set ui_comm {} -- cgit v0.10.2-6-g49f6 From c52c94524bdf9bbe515137b7f3f0240bc10a7f63 Mon Sep 17 00:00:00 2001 From: "Shawn O. Pearce" Date: Tue, 17 Jul 2007 23:58:56 -0400 Subject: git-gui: Allow blame/browser subcommands on bare repositories A long time ago Linus Torvalds tried to run git-gui on a bare repository to look at the blame viewer, but it failed to start because we required that the user run us only from within a working directory that had a normal git repository associated with it. This change relaxes that requirement so that you can start the tree browser or the blame viewer against a bare repository. In the latter case we do require that you provide a revision and a pathname if we cannot find the pathname in the current working directory. Signed-off-by: Shawn O. Pearce diff --git a/git-gui.sh b/git-gui.sh index f13fa80..9ddb61e 100755 --- a/git-gui.sh +++ b/git-gui.sh @@ -650,10 +650,13 @@ if {$subcommand eq {gui} && [llength $argv] > 0} { enable_option multicommit enable_option branch enable_option transport +disable_option bare switch -- $subcommand { browser - blame { + enable_option bare + disable_option multicommit disable_option branch disable_option transport @@ -691,19 +694,24 @@ if {![file isdirectory $_gitdir]} { error_popup "Git directory not found:\n\n$_gitdir" exit 1 } -if {[lindex [file split $_gitdir] end] ne {.git}} { - catch {wm withdraw .} - error_popup "Cannot use funny .git directory:\n\n$_gitdir" - exit 1 +if {![is_enabled bare]} { + if {[lindex [file split $_gitdir] end] ne {.git}} { + catch {wm withdraw .} + error_popup "Cannot use funny .git directory:\n\n$_gitdir" + exit 1 + } + if {[catch {cd [file dirname $_gitdir]} err]} { + catch {wm withdraw .} + error_popup "No working directory [file dirname $_gitdir]:\n\n$err" + exit 1 + } } -if {[catch {cd [file dirname $_gitdir]} err]} { - catch {wm withdraw .} - error_popup "No working directory [file dirname $_gitdir]:\n\n$err" - exit 1 +set _reponame [file split [file normalize $_gitdir]] +if {[lindex $_reponame end] eq {.git}} { + set _reponame [lindex $_reponame end-1] +} else { + set _reponame [lindex $_reponame end] } -set _reponame [lindex [file split \ - [file normalize [file dirname $_gitdir]]] \ - end] ###################################################################### ## @@ -1990,7 +1998,8 @@ browser { return } blame { - set subcommand_args {rev? path?} + set subcommand_args {rev? path} + if {$argv eq {}} usage set head {} set path {} set is_path 0 @@ -2009,12 +2018,18 @@ blame { } elseif {$head eq {}} { if {$head ne {}} usage set head $a + set is_path 1 } else { usage } } unset is_path + if {$head ne {} && $path eq {}} { + set path $_prefix$head + set head {} + } + if {$head eq {}} { load_current_branch } else { @@ -2029,7 +2044,11 @@ blame { set current_branch $head } - if {$path eq {}} usage + if {$head eq {} && ![file exists $path]} { + puts stderr "fatal: cannot stat path $path: No such file or directory" + exit 1 + } + blame::new $head $path return } -- cgit v0.10.2-6-g49f6 From 85d2d59760e5de7f288109cb278eb91da0d5f9bf Mon Sep 17 00:00:00 2001 From: "Shawn O. Pearce" Date: Wed, 18 Jul 2007 00:53:14 -0400 Subject: git-gui: Allow browser subcommand to start in subdirectory Like our blame subcommand the browser subcommand now accepts both a revision and a path, just a revision or just a path. This way the user can start the subcommand on any branch, or on any subtree. Signed-off-by: Shawn O. Pearce diff --git a/git-gui.sh b/git-gui.sh index 9ddb61e..267d606 100755 --- a/git-gui.sh +++ b/git-gui.sh @@ -1976,27 +1976,7 @@ proc usage {} { # -- Not a normal commit type invocation? Do that instead! # switch -- $subcommand { -browser { - set subcommand_args {rev?} - switch [llength $argv] { - 0 { load_current_branch } - 1 { - set current_branch [lindex $argv 0] - if {[regexp {^[0-9a-f]{1,39}$} $current_branch]} { - if {[catch { - set current_branch \ - [git rev-parse --verify $current_branch] - } err]} { - puts stderr $err - exit 1 - } - } - } - default usage - } - browser::new $current_branch - return -} +browser - blame { set subcommand_args {rev? path} if {$argv eq {}} usage @@ -2044,12 +2024,26 @@ blame { set current_branch $head } - if {$head eq {} && ![file exists $path]} { - puts stderr "fatal: cannot stat path $path: No such file or directory" - exit 1 + switch -- $subcommand { + browser { + if {$head eq {}} { + if {$path ne {} && [file isdirectory $path]} { + set head $current_branch + } else { + set head $path + set path {} + } + } + browser::new $head $path + } + blame { + if {$head eq {} && ![file exists $path]} { + puts stderr "fatal: cannot stat path $path: No such file or directory" + exit 1 + } + blame::new $head $path + } } - - blame::new $head $path return } citool - diff --git a/lib/browser.tcl b/lib/browser.tcl index 911e5af..e8802d0 100644 --- a/lib/browser.tcl +++ b/lib/browser.tcl @@ -13,13 +13,13 @@ field browser_busy 1 field ls_buf {}; # Buffered record output from ls-tree -constructor new {commit} { +constructor new {commit {path {}}} { global cursor_ptr M1B make_toplevel top w wm title $top "[appname] ([reponame]): File Browser" set browser_commit $commit - set browser_path $browser_commit: + set browser_path $browser_commit:$path label $w.path \ -textvariable @browser_path \ @@ -73,7 +73,11 @@ constructor new {commit} { bind $w_list [list focus $w_list] set w $w_list - _ls $this $browser_commit + if {$path ne {}} { + _ls $this $browser_commit:$path $path + } else { + _ls $this $browser_commit $path + } return $this } -- cgit v0.10.2-6-g49f6 From 8e891facbef4b0196e51fe2065602175f28508c3 Mon Sep 17 00:00:00 2001 From: "Shawn O. Pearce" Date: Wed, 18 Jul 2007 01:39:27 -0400 Subject: git-gui: Allow users to browse any branch, not just the current one We now allow users to pick which commit they want to browse through our revision picking mega-widget. This opens up in a dialog first, and then opens a tree browser for that selected commit. It is a very simple approach and requires minimal code changes. I also clarified the language a bit in the Repository menu, to show that these actions will access files. Just in case a user is not quite sure what specific action they are looking for, but they know they want some sort of file thing. Signed-off-by: Shawn O. Pearce diff --git a/git-gui.sh b/git-gui.sh index 267d606..ac04bc0 100755 --- a/git-gui.sh +++ b/git-gui.sh @@ -1670,9 +1670,12 @@ if {[is_enabled transport]} { menu .mbar.repository .mbar.repository add command \ - -label {Browse Current Branch} \ + -label {Browse Current Branch's Files} \ -command {browser::new $current_branch} -trace add variable current_branch write ".mbar.repository entryconf [.mbar.repository index last] -label \"Browse \$current_branch\" ;#" +trace add variable current_branch write ".mbar.repository entryconf [.mbar.repository index last] -label \"Browse \$current_branch's Files\" ;#" +.mbar.repository add command \ + -label {Browse Branch Files...} \ + -command browser_open::dialog .mbar.repository add separator .mbar.repository add command \ diff --git a/lib/browser.tcl b/lib/browser.tcl index e8802d0..b684c67 100644 --- a/lib/browser.tcl +++ b/lib/browser.tcl @@ -243,3 +243,56 @@ method _read {fd} { } } + +class browser_open { + +field w ; # widget path +field w_rev ; # mega-widget to pick the initial revision + +constructor dialog {} { + make_toplevel top w + wm title $top "[appname] ([reponame]): Browse Branch Files" + if {$top ne {.}} { + wm geometry $top "+[winfo rootx .]+[winfo rooty .]" + } + + label $w.header \ + -text {Browse Branch Files} \ + -font font_uibold + pack $w.header -side top -fill x + + frame $w.buttons + button $w.buttons.browse -text Browse \ + -default active \ + -command [cb _open] + pack $w.buttons.browse -side right + button $w.buttons.cancel -text {Cancel} \ + -command [list destroy $w] + pack $w.buttons.cancel -side right -padx 5 + pack $w.buttons -side bottom -fill x -pady 10 -padx 10 + + set w_rev [::choose_rev::new $w.rev {Revision}] + $w_rev bind_listbox [cb _open] + pack $w.rev -anchor nw -fill both -expand 1 -pady 5 -padx 5 + + bind $w [cb _visible] + bind $w [list destroy $w] + bind $w [cb _open]\;break + tkwait window $w +} + +method _open {} { + if {[catch {$w_rev commit_or_die} err]} { + return + } + set name [$w_rev get] + destroy $w + browser::new $name +} + +method _visible {} { + grab $w + $w_rev focus_filter +} + +} -- cgit v0.10.2-6-g49f6 From 4040971269e28676037448c4a6754d760eea1a64 Mon Sep 17 00:00:00 2001 From: "Shawn O. Pearce" Date: Wed, 18 Jul 2007 01:48:41 -0400 Subject: git-gui: Clarify the visualize history menu options Users who are new to Git may not realize that visualizing things in a repository involves looking at history. Adding in a small amount of text to the menu items really helps to understand what the action might do, before you invoke it. Signed-off-by: Shawn O. Pearce diff --git a/git-gui.sh b/git-gui.sh index ac04bc0..2473488 100755 --- a/git-gui.sh +++ b/git-gui.sh @@ -1679,11 +1679,11 @@ trace add variable current_branch write ".mbar.repository entryconf [.mbar.repos .mbar.repository add separator .mbar.repository add command \ - -label {Visualize Current Branch} \ + -label {Visualize Current Branch's History} \ -command {do_gitk $current_branch} -trace add variable current_branch write ".mbar.repository entryconf [.mbar.repository index last] -label \"Visualize \$current_branch\" ;#" +trace add variable current_branch write ".mbar.repository entryconf [.mbar.repository index last] -label \"Visualize \$current_branch's History\" ;#" .mbar.repository add command \ - -label {Visualize All Branches} \ + -label {Visualize All Branch History} \ -command {do_gitk --all} .mbar.repository add separator -- cgit v0.10.2-6-g49f6 From 46a2df3ac20c53eaec1d2081d5324f7c85b1adef Mon Sep 17 00:00:00 2001 From: "Shawn O. Pearce" Date: Wed, 18 Jul 2007 02:27:39 -0400 Subject: git-gui: Increase the default height of the revision picker Showing only five lines of heads/tags is not very useful to a user when they have about 10 branches that match the filter expression. The list is just too short to really be able to read easily, at least not without scrolling up and down. Expanding the list out to 10 really makes the revision picker easier to read and access, as you can read the matching branches much more quickly. Signed-off-by: Shawn O. Pearce diff --git a/lib/choose_rev.tcl b/lib/choose_rev.tcl index afd8170..6c4c318 100644 --- a/lib/choose_rev.tcl +++ b/lib/choose_rev.tcl @@ -86,7 +86,7 @@ constructor new {path {title {}}} { listbox $w_list \ -font font_diff \ -width 50 \ - -height 5 \ + -height 10 \ -selectmode browse \ -exportselection false \ -xscrollcommand [cb _sb_set $w.list.sbx h] \ -- cgit v0.10.2-6-g49f6 From ff749c114a9642e79a1e93250828034f0338f1be Mon Sep 17 00:00:00 2001 From: "Shawn O. Pearce" Date: Wed, 18 Jul 2007 02:56:44 -0400 Subject: git-gui: Convert merge dialog to use class system I've found that the class code makes it a whole lot easier to create more complex GUI code, especially the dialogs. So before I make any major improvements to the merge dialog's interface I'm going to first switch it to use the class system, so the code is slightly cleaner. Signed-off-by: Shawn O. Pearce diff --git a/lib/merge.tcl b/lib/merge.tcl index 288d7ac..6caf25f 100644 --- a/lib/merge.tcl +++ b/lib/merge.tcl @@ -1,9 +1,13 @@ # git-gui branch merge support # Copyright (C) 2006, 2007 Shawn Pearce -namespace eval merge { +class merge { + +field w ; # top level window +field w_list ; # widget of available branches +field list ; # list of available branches -proc _can_merge {} { +method _can_merge {} { global HEAD commit_type file_states if {[string match amend* $commit_type]} { @@ -63,26 +67,26 @@ You should complete the current commit before starting a merge. Doing so will h return 1 } -proc _refs {w list} { +method _refs {} { set r {} - foreach i [$w.source.l curselection] { + foreach i [$w_list curselection] { lappend r [lindex [lindex $list $i] 0] } return $r } -proc _visualize {w list} { - set revs [_refs $w $list] +method _visualize {} { + set revs [_refs $this] if {$revs eq {}} return lappend revs --not HEAD do_gitk $revs } -proc _start {w list} { +method _start {} { global HEAD current_branch set cmd [list git merge] - set names [_refs $w $list] + set names [_refs $this] set revcnt [llength $names] append cmd { } $names @@ -123,15 +127,14 @@ Please select fewer branches. To merge more than 15 branches, merge the branche set msg "Merging $current_branch, [join $names {, }]" ui_status "$msg..." set cons [console::new "Merge" $msg] - console::exec $cons $cmd \ - [namespace code [list _finish $revcnt $cons]] + console::exec $cons $cmd [cb _finish $revcnt $cons] wm protocol $w WM_DELETE_WINDOW {} destroy $w } -proc _finish {revcnt w ok} { - console::done $w $ok +method _finish {revcnt cons ok} { + console::done $cons $ok if {$ok} { set msg {Merge completed successfully.} } else { @@ -148,8 +151,7 @@ You can attempt this merge again by merging only one branch at a time." $w set fd [git_read read-tree --reset -u HEAD] fconfigure $fd -blocking 0 -translation binary - fileevent $fd readable \ - [namespace code [list _reset_wait $fd]] + fileevent $fd readable [cb _reset_wait $fd] ui_status {Aborting... please wait...} return } @@ -158,13 +160,17 @@ You can attempt this merge again by merging only one branch at a time." $w } unlock_index rescan [list ui_status $msg] + delete_this } -proc dialog {} { +constructor dialog {} { global current_branch global M1B - if {![_can_merge]} return + if {![_can_merge $this]} { + delete_this + return + } set fmt {list %(objectname) %(*objectname) %(refname) %(subject)} set fr_fd [git_read for-each-ref \ @@ -187,23 +193,25 @@ proc dialog {} { } close $fr_fd - set to_show {} + set list [list] set fr_fd [git_read rev-list --all --not HEAD] while {[gets $fr_fd line] > 0} { if {[catch {set ref $sha1($line)}]} continue foreach n $ref { - lappend to_show [list $n $line] + lappend list [list $n $line] } } close $fr_fd - set to_show [lsort -unique $to_show] + set list [lsort -unique $list] - set w .merge_setup - toplevel $w - wm geometry $w "+[winfo rootx .]+[winfo rooty .]" + make_toplevel top w + wm title $top "[appname] ([reponame]): Merge" + if {$top ne {.}} { + wm geometry $top "+[winfo rootx .]+[winfo rooty .]" + } - set _visualize [namespace code [list _visualize $w $to_show]] - set _start [namespace code [list _start $w $to_show]] + set _visualize [cb _visualize] + set _start [cb _start] label $w.header \ -text "Merge Into $current_branch" \ @@ -217,49 +225,65 @@ proc dialog {} { pack $w.buttons.create -side right button $w.buttons.cancel \ -text {Cancel} \ - -command "unlock_index;destroy $w" + -command [cb _cancel] pack $w.buttons.cancel -side right -padx 5 pack $w.buttons -side bottom -fill x -pady 10 -padx 10 labelframe $w.source -text {Source Branches} - listbox $w.source.l \ + set w_list $w.source.l + listbox $w_list \ -height 10 \ -width 70 \ -font font_diff \ -selectmode extended \ -yscrollcommand [list $w.source.sby set] - scrollbar $w.source.sby -command [list $w.source.l yview] + scrollbar $w.source.sby -command [list $w_list yview] pack $w.source.sby -side right -fill y - pack $w.source.l -side left -fill both -expand 1 + pack $w_list -side left -fill both -expand 1 pack $w.source -fill both -expand 1 -pady 5 -padx 5 - foreach ref $to_show { + foreach ref $list { set n [lindex $ref 0] if {[string length $n] > 20} { set n "[string range $n 0 16]..." } - $w.source.l insert end [format {%s %-20s %s} \ + $w_list insert end [format {%s %-20s %s} \ [string range [lindex $ref 1] 0 5] \ $n \ $subj([lindex $ref 0])] } - bind $w.source.l [list event generate %W ] - bind $w.source.l [list event generate %W ] - bind $w.source.l [list event generate %W ] - bind $w.source.l [list event generate %W ] - bind $w.source.l [list event generate %W ] - bind $w.source.l [list event generate %W ] - bind $w.source.l $_visualize + bind $w_list [list event generate %W ] + bind $w_list [list event generate %W ] + bind $w_list [list event generate %W ] + bind $w_list [list event generate %W ] + bind $w_list [list event generate %W ] + bind $w_list [list event generate %W ] + bind $w_list $_visualize bind $w <$M1B-Key-Return> $_start - bind $w "grab $w; focus $w.source.l" - bind $w "unlock_index;destroy $w" - wm protocol $w WM_DELETE_WINDOW "unlock_index;destroy $w" - wm title $w "[appname] ([reponame]): Merge" + bind $w [cb _visible] + bind $w [cb _cancel] + wm protocol $w WM_DELETE_WINDOW [cb _cancel] tkwait window $w } +method _visible {} { + grab $w + focus $w_list +} + +method _cancel {} { + wm protocol $w WM_DELETE_WINDOW {} + unlock_index + destroy $w + delete_this +} + +} + +namespace eval merge { + proc reset_hard {} { global HEAD commit_type file_states -- cgit v0.10.2-6-g49f6 From dc5ccdc6cab41e8a4b2ace991b1564fe9bdd172d Mon Sep 17 00:00:00 2001 From: "Shawn O. Pearce" Date: Wed, 18 Jul 2007 09:37:27 -0400 Subject: Don't offer my special Tools/Migrate hack unless in multicommit Users shouldn't see this menu option if they startup a browser or blame from the command line, especially if they are doing so on a bare repository. Signed-off-by: Shawn O. Pearce diff --git a/git-gui.sh b/git-gui.sh index 2473488..7b6a96e 100755 --- a/git-gui.sh +++ b/git-gui.sh @@ -1888,7 +1888,9 @@ if {[is_MacOSX]} { # -- Tools Menu # - if {[is_Cygwin] && [file exists /usr/local/miga/lib/gui-miga]} { + if {[is_Cygwin] + && [is_enabled multicommit] + && [file exists /usr/local/miga/lib/gui-miga]} { proc do_miga {} { if {![lock_index update]} return set cmd [list sh --login -c "/usr/local/miga/lib/gui-miga \"[pwd]\""] -- cgit v0.10.2-6-g49f6 From a870ddc0997881d5e73c0ec4562f3521274c5960 Mon Sep 17 00:00:00 2001 From: "Shawn O. Pearce" Date: Thu, 19 Jul 2007 00:39:23 -0400 Subject: git-gui: Bind Ctrl/Cmd-M to merge action Users who merge often may want to access the merge action quickly, so we now bind M to the merge action. Signed-off-by: Shawn O. Pearce diff --git a/git-gui.sh b/git-gui.sh index 7b6a96e..0aabfba 100755 --- a/git-gui.sh +++ b/git-gui.sh @@ -1846,14 +1846,14 @@ if {[is_enabled multicommit] || [is_enabled singlecommit]} { if {[is_enabled branch]} { menu .mbar.merge .mbar.merge add command -label {Local Merge...} \ - -command merge::dialog + -command merge::dialog \ + -accelerator $M1T-M lappend disable_on_lock \ [list .mbar.merge entryconf [.mbar.merge index last] -state] .mbar.merge add command -label {Abort Merge...} \ -command merge::reset_hard lappend disable_on_lock \ [list .mbar.merge entryconf [.mbar.merge index last] -state] - } # -- Transport Menu @@ -2508,6 +2508,8 @@ if {[is_enabled branch]} { bind . <$M1B-Key-N> branch_create::dialog bind . <$M1B-Key-o> branch_checkout::dialog bind . <$M1B-Key-O> branch_checkout::dialog + bind . <$M1B-Key-m> merge::dialog + bind . <$M1B-Key-M> merge::dialog } if {[is_enabled transport]} { bind . <$M1B-Key-p> do_push_anywhere -- cgit v0.10.2-6-g49f6 From d36cd968378cd3e509434b1b9f43f1417fdba57e Mon Sep 17 00:00:00 2001 From: "Shawn O. Pearce" Date: Thu, 19 Jul 2007 00:43:16 -0400 Subject: git-gui: Avoid unnecessary global statements when possible Running global takes slightly longer than just accessing the variable via its package name, especially if the variable is just only once in the procedure, or isn't even used at all in the procedure. So this is a minor cleanup for some of our commonly invoked procedures. Signed-off-by: Shawn O. Pearce diff --git a/git-gui.sh b/git-gui.sh index 0aabfba..c5ff7c8 100755 --- a/git-gui.sh +++ b/git-gui.sh @@ -154,12 +154,10 @@ proc gitexec {args} { } proc reponame {} { - global _reponame - return $_reponame + return $::_reponame } proc is_MacOSX {} { - global tcl_platform tk_library if {[tk windowingsystem] eq {aqua}} { return 1 } @@ -167,17 +165,16 @@ proc is_MacOSX {} { } proc is_Windows {} { - global tcl_platform - if {$tcl_platform(platform) eq {windows}} { + if {$::tcl_platform(platform) eq {windows}} { return 1 } return 0 } proc is_Cygwin {} { - global tcl_platform _iscygwin + global _iscygwin if {$_iscygwin eq {}} { - if {$tcl_platform(platform) eq {windows}} { + if {$::tcl_platform(platform) eq {windows}} { if {[catch {set p [exec cygpath --windir]} err]} { set _iscygwin 0 } else { -- cgit v0.10.2-6-g49f6 From c4638f662c9ba5f4150ab97dbbf0e540392aad55 Mon Sep 17 00:00:00 2001 From: "Shawn O. Pearce" Date: Thu, 19 Jul 2007 01:13:29 -0400 Subject: git-gui: Translate standard encoding names to Tcl ones This is a essentially a copy of Paul Mackerras encoding support from gitk. I stole the code from gitk commit fd8ccbec4f0161, as Paul has already done all of the hard work setting up this translation table. Signed-off-by: Shawn O. Pearce diff --git a/lib/blame.tcl b/lib/blame.tcl index 1bcb4b4..4da60ac 100644 --- a/lib/blame.tcl +++ b/lib/blame.tcl @@ -771,15 +771,20 @@ method _showcommit {cur_w lno} { set enc [string tolower [string range $line 9 end]] } } - set msg [encoding convertfrom $enc [read $fd]] - set msg [string trim $msg] + set msg [read $fd] close $fd - set author_name [encoding convertfrom $enc $author_name] - set committer_name [encoding convertfrom $enc $committer_name] - - set header($cmit,author) $author_name - set header($cmit,committer) $committer_name + set enc [tcl_encoding $enc] + if {$enc ne {}} { + set msg [encoding convertfrom $enc $msg] + set author_name [encoding convertfrom $enc $author_name] + set committer_name [encoding convertfrom $enc $committer_name] + set header($cmit,author) $author_name + set header($cmit,committer) $committer_name + set header($cmit,summary) \ + [encoding convertfrom $enc $header($cmit,summary)] + } + set msg [string trim $msg] } set header($cmit,message) $msg } diff --git a/lib/commit.tcl b/lib/commit.tcl index 0f3b16d..75b13a0 100644 --- a/lib/commit.tcl +++ b/lib/commit.tcl @@ -37,9 +37,14 @@ You are currently in the middle of a merge that has not been fully completed. Y set enc [string tolower [string range $line 9 end]] } } - set msg [encoding convertfrom $enc [read $fd]] - set msg [string trim $msg] + set msg [read $fd] close $fd + + set enc [tcl_encoding $enc] + if {$enc ne {}} { + set msg [encoding convertfrom $enc $msg] + } + set msg [string trim $msg] } err]} { error_popup "Error loading commit data for amend:\n\n$err" return @@ -287,11 +292,18 @@ A rescan will be automatically started now. # set msg_p [gitdir COMMIT_EDITMSG] set msg_wt [open $msg_p w] + fconfigure $msg_wt -translation lf if {[catch {set enc $repo_config(i18n.commitencoding)}]} { set enc utf-8 } - fconfigure $msg_wt -encoding binary -translation binary - puts -nonewline $msg_wt [encoding convertto $enc $msg] + set use_enc [tcl_encoding $enc] + if {$use_enc ne {}} { + fconfigure $msg_wt -encoding $use_enc + } else { + puts stderr "warning: Tcl does not support encoding '$enc'." + fconfigure $msg_wt -encoding utf-8 + } + puts -nonewline $msg_wt $msg close $msg_wt # -- Create the commit. diff --git a/lib/encoding.tcl b/lib/encoding.tcl new file mode 100644 index 0000000..7f06b0d --- /dev/null +++ b/lib/encoding.tcl @@ -0,0 +1,276 @@ +# git-gui encoding support +# Copyright (C) 2005 Paul Mackerras +# (Copied from gitk, commit fd8ccbec4f0161) + +# This list of encoding names and aliases is distilled from +# http://www.iana.org/assignments/character-sets. +# Not all of them are supported by Tcl. +set encoding_aliases { + { ANSI_X3.4-1968 iso-ir-6 ANSI_X3.4-1986 ISO_646.irv:1991 ASCII + ISO646-US US-ASCII us IBM367 cp367 csASCII } + { ISO-10646-UTF-1 csISO10646UTF1 } + { ISO_646.basic:1983 ref csISO646basic1983 } + { INVARIANT csINVARIANT } + { ISO_646.irv:1983 iso-ir-2 irv csISO2IntlRefVersion } + { BS_4730 iso-ir-4 ISO646-GB gb uk csISO4UnitedKingdom } + { NATS-SEFI iso-ir-8-1 csNATSSEFI } + { NATS-SEFI-ADD iso-ir-8-2 csNATSSEFIADD } + { NATS-DANO iso-ir-9-1 csNATSDANO } + { NATS-DANO-ADD iso-ir-9-2 csNATSDANOADD } + { SEN_850200_B iso-ir-10 FI ISO646-FI ISO646-SE se csISO10Swedish } + { SEN_850200_C iso-ir-11 ISO646-SE2 se2 csISO11SwedishForNames } + { KS_C_5601-1987 iso-ir-149 KS_C_5601-1989 KSC_5601 korean csKSC56011987 } + { ISO-2022-KR csISO2022KR } + { EUC-KR csEUCKR } + { ISO-2022-JP csISO2022JP } + { ISO-2022-JP-2 csISO2022JP2 } + { JIS_C6220-1969-jp JIS_C6220-1969 iso-ir-13 katakana x0201-7 + csISO13JISC6220jp } + { JIS_C6220-1969-ro iso-ir-14 jp ISO646-JP csISO14JISC6220ro } + { IT iso-ir-15 ISO646-IT csISO15Italian } + { PT iso-ir-16 ISO646-PT csISO16Portuguese } + { ES iso-ir-17 ISO646-ES csISO17Spanish } + { greek7-old iso-ir-18 csISO18Greek7Old } + { latin-greek iso-ir-19 csISO19LatinGreek } + { DIN_66003 iso-ir-21 de ISO646-DE csISO21German } + { NF_Z_62-010_(1973) iso-ir-25 ISO646-FR1 csISO25French } + { Latin-greek-1 iso-ir-27 csISO27LatinGreek1 } + { ISO_5427 iso-ir-37 csISO5427Cyrillic } + { JIS_C6226-1978 iso-ir-42 csISO42JISC62261978 } + { BS_viewdata iso-ir-47 csISO47BSViewdata } + { INIS iso-ir-49 csISO49INIS } + { INIS-8 iso-ir-50 csISO50INIS8 } + { INIS-cyrillic iso-ir-51 csISO51INISCyrillic } + { ISO_5427:1981 iso-ir-54 ISO5427Cyrillic1981 } + { ISO_5428:1980 iso-ir-55 csISO5428Greek } + { GB_1988-80 iso-ir-57 cn ISO646-CN csISO57GB1988 } + { GB_2312-80 iso-ir-58 chinese csISO58GB231280 } + { NS_4551-1 iso-ir-60 ISO646-NO no csISO60DanishNorwegian + csISO60Norwegian1 } + { NS_4551-2 ISO646-NO2 iso-ir-61 no2 csISO61Norwegian2 } + { NF_Z_62-010 iso-ir-69 ISO646-FR fr csISO69French } + { videotex-suppl iso-ir-70 csISO70VideotexSupp1 } + { PT2 iso-ir-84 ISO646-PT2 csISO84Portuguese2 } + { ES2 iso-ir-85 ISO646-ES2 csISO85Spanish2 } + { MSZ_7795.3 iso-ir-86 ISO646-HU hu csISO86Hungarian } + { JIS_C6226-1983 iso-ir-87 x0208 JIS_X0208-1983 csISO87JISX0208 } + { greek7 iso-ir-88 csISO88Greek7 } + { ASMO_449 ISO_9036 arabic7 iso-ir-89 csISO89ASMO449 } + { iso-ir-90 csISO90 } + { JIS_C6229-1984-a iso-ir-91 jp-ocr-a csISO91JISC62291984a } + { JIS_C6229-1984-b iso-ir-92 ISO646-JP-OCR-B jp-ocr-b + csISO92JISC62991984b } + { JIS_C6229-1984-b-add iso-ir-93 jp-ocr-b-add csISO93JIS62291984badd } + { JIS_C6229-1984-hand iso-ir-94 jp-ocr-hand csISO94JIS62291984hand } + { JIS_C6229-1984-hand-add iso-ir-95 jp-ocr-hand-add + csISO95JIS62291984handadd } + { JIS_C6229-1984-kana iso-ir-96 csISO96JISC62291984kana } + { ISO_2033-1983 iso-ir-98 e13b csISO2033 } + { ANSI_X3.110-1983 iso-ir-99 CSA_T500-1983 NAPLPS csISO99NAPLPS } + { ISO_8859-1:1987 iso-ir-100 ISO_8859-1 ISO-8859-1 latin1 l1 IBM819 + CP819 csISOLatin1 } + { ISO_8859-2:1987 iso-ir-101 ISO_8859-2 ISO-8859-2 latin2 l2 csISOLatin2 } + { T.61-7bit iso-ir-102 csISO102T617bit } + { T.61-8bit T.61 iso-ir-103 csISO103T618bit } + { ISO_8859-3:1988 iso-ir-109 ISO_8859-3 ISO-8859-3 latin3 l3 csISOLatin3 } + { ISO_8859-4:1988 iso-ir-110 ISO_8859-4 ISO-8859-4 latin4 l4 csISOLatin4 } + { ECMA-cyrillic iso-ir-111 KOI8-E csISO111ECMACyrillic } + { CSA_Z243.4-1985-1 iso-ir-121 ISO646-CA csa7-1 ca csISO121Canadian1 } + { CSA_Z243.4-1985-2 iso-ir-122 ISO646-CA2 csa7-2 csISO122Canadian2 } + { CSA_Z243.4-1985-gr iso-ir-123 csISO123CSAZ24341985gr } + { ISO_8859-6:1987 iso-ir-127 ISO_8859-6 ISO-8859-6 ECMA-114 ASMO-708 + arabic csISOLatinArabic } + { ISO_8859-6-E csISO88596E ISO-8859-6-E } + { ISO_8859-6-I csISO88596I ISO-8859-6-I } + { ISO_8859-7:1987 iso-ir-126 ISO_8859-7 ISO-8859-7 ELOT_928 ECMA-118 + greek greek8 csISOLatinGreek } + { T.101-G2 iso-ir-128 csISO128T101G2 } + { ISO_8859-8:1988 iso-ir-138 ISO_8859-8 ISO-8859-8 hebrew + csISOLatinHebrew } + { ISO_8859-8-E csISO88598E ISO-8859-8-E } + { ISO_8859-8-I csISO88598I ISO-8859-8-I } + { CSN_369103 iso-ir-139 csISO139CSN369103 } + { JUS_I.B1.002 iso-ir-141 ISO646-YU js yu csISO141JUSIB1002 } + { ISO_6937-2-add iso-ir-142 csISOTextComm } + { IEC_P27-1 iso-ir-143 csISO143IECP271 } + { ISO_8859-5:1988 iso-ir-144 ISO_8859-5 ISO-8859-5 cyrillic + csISOLatinCyrillic } + { JUS_I.B1.003-serb iso-ir-146 serbian csISO146Serbian } + { JUS_I.B1.003-mac macedonian iso-ir-147 csISO147Macedonian } + { ISO_8859-9:1989 iso-ir-148 ISO_8859-9 ISO-8859-9 latin5 l5 csISOLatin5 } + { greek-ccitt iso-ir-150 csISO150 csISO150GreekCCITT } + { NC_NC00-10:81 cuba iso-ir-151 ISO646-CU csISO151Cuba } + { ISO_6937-2-25 iso-ir-152 csISO6937Add } + { GOST_19768-74 ST_SEV_358-88 iso-ir-153 csISO153GOST1976874 } + { ISO_8859-supp iso-ir-154 latin1-2-5 csISO8859Supp } + { ISO_10367-box iso-ir-155 csISO10367Box } + { ISO-8859-10 iso-ir-157 l6 ISO_8859-10:1992 csISOLatin6 latin6 } + { latin-lap lap iso-ir-158 csISO158Lap } + { JIS_X0212-1990 x0212 iso-ir-159 csISO159JISX02121990 } + { DS_2089 DS2089 ISO646-DK dk csISO646Danish } + { us-dk csUSDK } + { dk-us csDKUS } + { JIS_X0201 X0201 csHalfWidthKatakana } + { KSC5636 ISO646-KR csKSC5636 } + { ISO-10646-UCS-2 csUnicode } + { ISO-10646-UCS-4 csUCS4 } + { DEC-MCS dec csDECMCS } + { hp-roman8 roman8 r8 csHPRoman8 } + { macintosh mac csMacintosh } + { IBM037 cp037 ebcdic-cp-us ebcdic-cp-ca ebcdic-cp-wt ebcdic-cp-nl + csIBM037 } + { IBM038 EBCDIC-INT cp038 csIBM038 } + { IBM273 CP273 csIBM273 } + { IBM274 EBCDIC-BE CP274 csIBM274 } + { IBM275 EBCDIC-BR cp275 csIBM275 } + { IBM277 EBCDIC-CP-DK EBCDIC-CP-NO csIBM277 } + { IBM278 CP278 ebcdic-cp-fi ebcdic-cp-se csIBM278 } + { IBM280 CP280 ebcdic-cp-it csIBM280 } + { IBM281 EBCDIC-JP-E cp281 csIBM281 } + { IBM284 CP284 ebcdic-cp-es csIBM284 } + { IBM285 CP285 ebcdic-cp-gb csIBM285 } + { IBM290 cp290 EBCDIC-JP-kana csIBM290 } + { IBM297 cp297 ebcdic-cp-fr csIBM297 } + { IBM420 cp420 ebcdic-cp-ar1 csIBM420 } + { IBM423 cp423 ebcdic-cp-gr csIBM423 } + { IBM424 cp424 ebcdic-cp-he csIBM424 } + { IBM437 cp437 437 csPC8CodePage437 } + { IBM500 CP500 ebcdic-cp-be ebcdic-cp-ch csIBM500 } + { IBM775 cp775 csPC775Baltic } + { IBM850 cp850 850 csPC850Multilingual } + { IBM851 cp851 851 csIBM851 } + { IBM852 cp852 852 csPCp852 } + { IBM855 cp855 855 csIBM855 } + { IBM857 cp857 857 csIBM857 } + { IBM860 cp860 860 csIBM860 } + { IBM861 cp861 861 cp-is csIBM861 } + { IBM862 cp862 862 csPC862LatinHebrew } + { IBM863 cp863 863 csIBM863 } + { IBM864 cp864 csIBM864 } + { IBM865 cp865 865 csIBM865 } + { IBM866 cp866 866 csIBM866 } + { IBM868 CP868 cp-ar csIBM868 } + { IBM869 cp869 869 cp-gr csIBM869 } + { IBM870 CP870 ebcdic-cp-roece ebcdic-cp-yu csIBM870 } + { IBM871 CP871 ebcdic-cp-is csIBM871 } + { IBM880 cp880 EBCDIC-Cyrillic csIBM880 } + { IBM891 cp891 csIBM891 } + { IBM903 cp903 csIBM903 } + { IBM904 cp904 904 csIBBM904 } + { IBM905 CP905 ebcdic-cp-tr csIBM905 } + { IBM918 CP918 ebcdic-cp-ar2 csIBM918 } + { IBM1026 CP1026 csIBM1026 } + { EBCDIC-AT-DE csIBMEBCDICATDE } + { EBCDIC-AT-DE-A csEBCDICATDEA } + { EBCDIC-CA-FR csEBCDICCAFR } + { EBCDIC-DK-NO csEBCDICDKNO } + { EBCDIC-DK-NO-A csEBCDICDKNOA } + { EBCDIC-FI-SE csEBCDICFISE } + { EBCDIC-FI-SE-A csEBCDICFISEA } + { EBCDIC-FR csEBCDICFR } + { EBCDIC-IT csEBCDICIT } + { EBCDIC-PT csEBCDICPT } + { EBCDIC-ES csEBCDICES } + { EBCDIC-ES-A csEBCDICESA } + { EBCDIC-ES-S csEBCDICESS } + { EBCDIC-UK csEBCDICUK } + { EBCDIC-US csEBCDICUS } + { UNKNOWN-8BIT csUnknown8BiT } + { MNEMONIC csMnemonic } + { MNEM csMnem } + { VISCII csVISCII } + { VIQR csVIQR } + { KOI8-R csKOI8R } + { IBM00858 CCSID00858 CP00858 PC-Multilingual-850+euro } + { IBM00924 CCSID00924 CP00924 ebcdic-Latin9--euro } + { IBM01140 CCSID01140 CP01140 ebcdic-us-37+euro } + { IBM01141 CCSID01141 CP01141 ebcdic-de-273+euro } + { IBM01142 CCSID01142 CP01142 ebcdic-dk-277+euro ebcdic-no-277+euro } + { IBM01143 CCSID01143 CP01143 ebcdic-fi-278+euro ebcdic-se-278+euro } + { IBM01144 CCSID01144 CP01144 ebcdic-it-280+euro } + { IBM01145 CCSID01145 CP01145 ebcdic-es-284+euro } + { IBM01146 CCSID01146 CP01146 ebcdic-gb-285+euro } + { IBM01147 CCSID01147 CP01147 ebcdic-fr-297+euro } + { IBM01148 CCSID01148 CP01148 ebcdic-international-500+euro } + { IBM01149 CCSID01149 CP01149 ebcdic-is-871+euro } + { IBM1047 IBM-1047 } + { PTCP154 csPTCP154 PT154 CP154 Cyrillic-Asian } + { Amiga-1251 Ami1251 Amiga1251 Ami-1251 } + { UNICODE-1-1 csUnicode11 } + { CESU-8 csCESU-8 } + { BOCU-1 csBOCU-1 } + { UNICODE-1-1-UTF-7 csUnicode11UTF7 } + { ISO-8859-14 iso-ir-199 ISO_8859-14:1998 ISO_8859-14 latin8 iso-celtic + l8 } + { ISO-8859-15 ISO_8859-15 Latin-9 } + { ISO-8859-16 iso-ir-226 ISO_8859-16:2001 ISO_8859-16 latin10 l10 } + { GBK CP936 MS936 windows-936 } + { JIS_Encoding csJISEncoding } + { Shift_JIS MS_Kanji csShiftJIS } + { Extended_UNIX_Code_Packed_Format_for_Japanese csEUCPkdFmtJapanese + EUC-JP } + { Extended_UNIX_Code_Fixed_Width_for_Japanese csEUCFixWidJapanese } + { ISO-10646-UCS-Basic csUnicodeASCII } + { ISO-10646-Unicode-Latin1 csUnicodeLatin1 ISO-10646 } + { ISO-Unicode-IBM-1261 csUnicodeIBM1261 } + { ISO-Unicode-IBM-1268 csUnicodeIBM1268 } + { ISO-Unicode-IBM-1276 csUnicodeIBM1276 } + { ISO-Unicode-IBM-1264 csUnicodeIBM1264 } + { ISO-Unicode-IBM-1265 csUnicodeIBM1265 } + { ISO-8859-1-Windows-3.0-Latin-1 csWindows30Latin1 } + { ISO-8859-1-Windows-3.1-Latin-1 csWindows31Latin1 } + { ISO-8859-2-Windows-Latin-2 csWindows31Latin2 } + { ISO-8859-9-Windows-Latin-5 csWindows31Latin5 } + { Adobe-Standard-Encoding csAdobeStandardEncoding } + { Ventura-US csVenturaUS } + { Ventura-International csVenturaInternational } + { PC8-Danish-Norwegian csPC8DanishNorwegian } + { PC8-Turkish csPC8Turkish } + { IBM-Symbols csIBMSymbols } + { IBM-Thai csIBMThai } + { HP-Legal csHPLegal } + { HP-Pi-font csHPPiFont } + { HP-Math8 csHPMath8 } + { Adobe-Symbol-Encoding csHPPSMath } + { HP-DeskTop csHPDesktop } + { Ventura-Math csVenturaMath } + { Microsoft-Publishing csMicrosoftPublishing } + { Windows-31J csWindows31J } + { GB2312 csGB2312 } + { Big5 csBig5 } +} + +proc tcl_encoding {enc} { + global encoding_aliases + set names [encoding names] + set lcnames [string tolower $names] + set enc [string tolower $enc] + set i [lsearch -exact $lcnames $enc] + if {$i < 0} { + # look for "isonnn" instead of "iso-nnn" or "iso_nnn" + if {[regsub {^iso[-_]} $enc iso encx]} { + set i [lsearch -exact $lcnames $encx] + } + } + if {$i < 0} { + foreach l $encoding_aliases { + set ll [string tolower $l] + if {[lsearch -exact $ll $enc] < 0} continue + # look through the aliases for one that tcl knows about + foreach e $ll { + set i [lsearch -exact $lcnames $e] + if {$i < 0} { + if {[regsub {^iso[-_]} $e iso ex]} { + set i [lsearch -exact $lcnames $ex] + } + } + if {$i >= 0} break + } + break + } + } + if {$i >= 0} { + return [lindex $names $i] + } + return {} +} -- cgit v0.10.2-6-g49f6 From a42289621e372763d5ef34067d5e38a0872fab15 Mon Sep 17 00:00:00 2001 From: "Shawn O. Pearce" Date: Thu, 19 Jul 2007 01:45:42 -0400 Subject: git-gui: Don't show blame tooltips that we have no data for If we haven't yet loaded any commit information for a given line but our tooltip timer fired and tried to draw the tooltip we shouldn't; there is nothing to show. Signed-off-by: Shawn O. Pearce diff --git a/lib/blame.tcl b/lib/blame.tcl index 4da60ac..9607284 100644 --- a/lib/blame.tcl +++ b/lib/blame.tcl @@ -879,6 +879,11 @@ method _open_tooltip {cur_w} { set org [lindex $amov_data $lno] } + if {$dat eq {}} { + _hide_tooltip $this + return + } + set cmit [lindex $dat 0] set tooltip_commit [list $cmit] -- cgit v0.10.2-6-g49f6 From 5dc2cae6f4c5d7218c4323ceafb96ab8469be52e Mon Sep 17 00:00:00 2001 From: "Shawn O. Pearce" Date: Thu, 19 Jul 2007 02:24:25 -0400 Subject: git-gui: Completely remove support for creating octopus merges I'm working on refactoring the UI of the merge dialog, because as it currently stands the dialog is absolutely horrible, especially when you have 200+ branches available from a single remote system. In that refactoring I plan on using the choose_rev widget to allow the user to select exactly which branch/commit they want to merge. However since that only selects a single commit I'm first removing the code that supports octopus merges. A brief consultation on #git tonight seemed to indicate that the octopus merge strategy is not as useful as originally thought when it was invented, and that most people don't commonly use them. So making users fall back to the command line to create an octopus is actually maybe a good idea here, as they might think twice before they use it. Signed-off-by: Shawn O. Pearce diff --git a/lib/merge.tcl b/lib/merge.tcl index 6caf25f..e5a7525 100644 --- a/lib/merge.tcl +++ b/lib/merge.tcl @@ -67,95 +67,44 @@ You should complete the current commit before starting a merge. Doing so will h return 1 } -method _refs {} { - set r {} - foreach i [$w_list curselection] { - lappend r [lindex [lindex $list $i] 0] +method _rev {} { + set i [$w_list curselection] + if {$i >= 0} { + return [lindex [lindex $list $i] 0] } - return $r + return {} } method _visualize {} { - set revs [_refs $this] - if {$revs eq {}} return - lappend revs --not HEAD - do_gitk $revs + set rev [_rev $this] + if {$rev ne {}} { + do_gitk [list $rev --not HEAD] + } } method _start {} { global HEAD current_branch - set cmd [list git merge] - set names [_refs $this] - set revcnt [llength $names] - append cmd { } $names - - if {$revcnt == 0} { - return - } elseif {$revcnt == 1} { - set unit branch - } elseif {$revcnt <= 15} { - set unit branches - - if {[tk_dialog \ - $w.confirm_octopus \ - [wm title $w] \ - "Use octopus merge strategy? - -You are merging $revcnt branches at once. This requires using the octopus merge driver, which may not succeed if there are file-level conflicts. -" \ - question \ - 0 \ - {Cancel} \ - {Use octopus} \ - ] != 1} return - } else { - tk_messageBox \ - -icon error \ - -type ok \ - -title [wm title $w] \ - -parent $w \ - -message "Too many branches selected. - -You have requested to merge $revcnt branches in an octopus merge. This exceeds Git's internal limit of 15 branches per merge. - -Please select fewer branches. To merge more than 15 branches, merge the branches in batches. -" + set name [_rev $this] + if {$name eq {}} { return } - set msg "Merging $current_branch, [join $names {, }]" + set cmd [list git merge $name] + set msg "Merging $current_branch and $name" ui_status "$msg..." - set cons [console::new "Merge" $msg] - console::exec $cons $cmd [cb _finish $revcnt $cons] + set cons [console::new "Merge" $cmd] + console::exec $cons $cmd [cb _finish $cons] wm protocol $w WM_DELETE_WINDOW {} destroy $w } -method _finish {revcnt cons ok} { +method _finish {cons ok} { console::done $cons $ok if {$ok} { set msg {Merge completed successfully.} } else { - if {$revcnt != 1} { - info_popup "Octopus merge failed. - -Your merge of $revcnt branches has failed. - -There are file-level conflicts between the branches which must be resolved manually. - -The working directory will now be reset. - -You can attempt this merge again by merging only one branch at a time." $w - - set fd [git_read read-tree --reset -u HEAD] - fconfigure $fd -blocking 0 -translation binary - fileevent $fd readable [cb _reset_wait $fd] - ui_status {Aborting... please wait...} - return - } - set msg {Merge failed. Conflict resolution is required.} } unlock_index @@ -235,7 +184,7 @@ constructor dialog {} { -height 10 \ -width 70 \ -font font_diff \ - -selectmode extended \ + -selectmode browse \ -yscrollcommand [list $w.source.sby set] scrollbar $w.source.sby -command [list $w_list yview] pack $w.source.sby -side right -fill y -- cgit v0.10.2-6-g49f6 From 4578c5cb690df98d0d5fbea043114b4b7dec8f57 Mon Sep 17 00:00:00 2001 From: "Shawn O. Pearce" Date: Sat, 21 Jul 2007 04:57:57 -0400 Subject: git-gui: Automatically backup the user's commit buffer A few users have been seeing crashes in Tk when using the undo key binding to undo the last few keystroke events in the commit buffer. Unfortunately that means the user loses their commit message and must start over from scratch when the user restarts the process. git-gui now saves the user's commit message buffer every couple of seconds to a temporary file under .git (specifically .git/GITGUI_BCK). At exit time we rename this file to .git/GITGUI_MSG if there is a message, the file exists, and it is currently synchronized with the Tk buffer. Otherwise we do our usual routine of saving the Tk buffer to .git/GITGUI_MSG and delete .git/GITGUI_BCK, if it exists. During startup we favor .git/GITGUI_BCK over .git/GITGUI_MSG. This way a crash doesn't take out the user's message buffer but instead will cause the user to lose only a few keystrokes. Most people do not type more than 200 WPM, and with 30 possible saves per minute we are unlikely to lose more than 7 words. Signed-off-by: Shawn O. Pearce diff --git a/git-gui.sh b/git-gui.sh index c5ff7c8..d85d707 100755 --- a/git-gui.sh +++ b/git-gui.sh @@ -1417,6 +1417,7 @@ set is_quitting 0 proc do_quit {} { global ui_comm is_quitting repo_config commit_type + global GITGUI_BCK_exists GITGUI_BCK_i if {$is_quitting} return set is_quitting 1 @@ -1425,18 +1426,30 @@ proc do_quit {} { # -- Stash our current commit buffer. # set save [gitdir GITGUI_MSG] - set msg [string trim [$ui_comm get 0.0 end]] - regsub -all -line {[ \r\t]+$} $msg {} msg - if {(![string match amend* $commit_type] - || [$ui_comm edit modified]) - && $msg ne {}} { - catch { - set fd [open $save w] - puts -nonewline $fd $msg - close $fd - } + if {$GITGUI_BCK_exists && ![$ui_comm edit modified]} { + file rename -force [gitdir GITGUI_BCK] $save + set GITGUI_BCK_exists 0 } else { - catch {file delete $save} + set msg [string trim [$ui_comm get 0.0 end]] + regsub -all -line {[ \r\t]+$} $msg {} msg + if {(![string match amend* $commit_type] + || [$ui_comm edit modified]) + && $msg ne {}} { + catch { + set fd [open $save w] + puts -nonewline $fd $msg + close $fd + } + } else { + catch {file delete $save} + } + } + + # -- Remove our editor backup, its not needed. + # + after cancel $GITGUI_BCK_i + if {$GITGUI_BCK_exists} { + catch {file delete [gitdir GITGUI_BCK]} } # -- Stash our current window geometry into this repository. @@ -2598,6 +2611,59 @@ if {[is_enabled transport]} { populate_push_menu } +if {[winfo exists $ui_comm]} { + set GITGUI_BCK_exists [load_message GITGUI_BCK] + + # -- If both our backup and message files exist use the + # newer of the two files to initialize the buffer. + # + if {$GITGUI_BCK_exists} { + set m [gitdir GITGUI_MSG] + if {[file isfile $m]} { + if {[file mtime [gitdir GITGUI_BCK]] > [file mtime $m]} { + catch {file delete [gitdir GITGUI_MSG]} + } else { + $ui_comm delete 0.0 end + $ui_comm edit reset + $ui_comm edit modified false + catch {file delete [gitdir GITGUI_BCK]} + set GITGUI_BCK_exists 0 + } + } + unset m + } + + proc backup_commit_buffer {} { + global ui_comm GITGUI_BCK_exists + + set m [$ui_comm edit modified] + if {$m || $GITGUI_BCK_exists} { + set msg [string trim [$ui_comm get 0.0 end]] + regsub -all -line {[ \r\t]+$} $msg {} msg + + if {$msg eq {}} { + if {$GITGUI_BCK_exists} { + catch {file delete [gitdir GITGUI_BCK]} + set GITGUI_BCK_exists 0 + } + } elseif {$m} { + catch { + set fd [open [gitdir GITGUI_BCK] w] + puts -nonewline $fd $msg + close $fd + set GITGUI_BCK_exists 1 + } + } + + $ui_comm edit modified false + } + + set ::GITGUI_BCK_i [after 2000 backup_commit_buffer] + } + + backup_commit_buffer +} + lock_index begin-read if {![winfo ismapped .]} { wm deiconify . diff --git a/lib/commit.tcl b/lib/commit.tcl index 75b13a0..6b86f98 100644 --- a/lib/commit.tcl +++ b/lib/commit.tcl @@ -379,6 +379,10 @@ A rescan will be automatically started now. $ui_comm delete 0.0 end $ui_comm edit reset $ui_comm edit modified false + if {$::GITGUI_BCK_exists} { + catch {file delete [gitdir GITGUI_BCK]} + set $::GITGUI_BCK_exists 0 + } if {[is_enabled singlecommit]} do_quit -- cgit v0.10.2-6-g49f6 From 60f7352fe1ae3d42ca7bd7611b6b787ff70cd813 Mon Sep 17 00:00:00 2001 From: "Shawn O. Pearce" Date: Fri, 20 Jul 2007 02:13:24 -0400 Subject: git-gui: Save the merge base during checkout_op processing I've decided to teach checkout_op how to perform more than just a fast-forward and reset type of merge. This way we can also do a full recursive merge even when we are recreating an existing branch from a remote. To help with that process I'm saving the merge-base we computed during the ff/reset/fail decision process, in case we need it later on when we actually start a true merge operation. Signed-off-by: Shawn O. Pearce diff --git a/lib/checkout_op.tcl b/lib/checkout_op.tcl index 00a994b..262dc96 100644 --- a/lib/checkout_op.tcl +++ b/lib/checkout_op.tcl @@ -12,6 +12,7 @@ field new_ref ; # ref we are updating/creating field parent_w .; # window that started us field merge_type none; # type of merge to apply to existing branch +field merge_base {}; # merge base if we have another ref involved field fetch_spec {}; # refetch tracking branch if used? field checkout 1; # actually checkout the branch? field create 0; # create the branch if it doesn't exist? @@ -180,15 +181,14 @@ method _update_ref {} { # No merge would be required, don't compute anything. # } else { - set mrb {} - catch {set mrb [git merge-base $new $cur]} + catch {set merge_base [git merge-base $new $cur]} switch -- $merge_type { ff { - if {$mrb eq $new} { + if {$merge_base eq $new} { # The current branch is actually newer. # set new $cur - } elseif {$mrb eq $cur} { + } elseif {$merge_base eq $cur} { # The current branch is older. # set reflog_msg "merge $new_expr: Fast-forward" @@ -198,7 +198,7 @@ method _update_ref {} { } } reset { - if {$mrb eq $cur} { + if {$merge_base eq $cur} { # The current branch is older. # set reflog_msg "merge $new_expr: Fast-forward" -- cgit v0.10.2-6-g49f6 From f66b8a68f21d7dba6b80ba213315974476001b93 Mon Sep 17 00:00:00 2001 From: "Shawn O. Pearce" Date: Fri, 20 Jul 2007 03:34:56 -0400 Subject: git-gui: Factor out common fast-forward merge case In both the ff and reset merge_types supported by checkout_op the result is the same if the merge base of our target commit and the existing commit is the existing commit: its a fast-forward as the existing commit is fully contained in the target commit. This minor cleanup in logic will make it easier to implement a new kind of merge_type that actually merges the two trees with a real merge strategy, such as git-merge-recursive. Signed-off-by: Shawn O. Pearce diff --git a/lib/checkout_op.tcl b/lib/checkout_op.tcl index 262dc96..6d87830 100644 --- a/lib/checkout_op.tcl +++ b/lib/checkout_op.tcl @@ -182,27 +182,23 @@ method _update_ref {} { # } else { catch {set merge_base [git merge-base $new $cur]} - switch -- $merge_type { - ff { - if {$merge_base eq $new} { - # The current branch is actually newer. - # - set new $cur - } elseif {$merge_base eq $cur} { - # The current branch is older. - # - set reflog_msg "merge $new_expr: Fast-forward" - } else { - _error $this "Branch '$newbranch' already exists.\n\nIt cannot fast-forward to $new_expr.\nA merge is required." - return 0 + if {$merge_base eq $cur} { + # The current branch is older. + # + set reflog_msg "merge $new_expr: Fast-forward" + } else { + switch -- $merge_type { + ff { + if {$merge_base eq $new} { + # The current branch is actually newer. + # + set new $cur + } else { + _error $this "Branch '$newbranch' already exists.\n\nIt cannot fast-forward to $new_expr.\nA merge is required." + return 0 + } } - } - reset { - if {$merge_base eq $cur} { - # The current branch is older. - # - set reflog_msg "merge $new_expr: Fast-forward" - } else { + reset { # The current branch will lose things. # if {[_confirm_reset $this $cur]} { @@ -211,11 +207,11 @@ method _update_ref {} { return 0 } } - } - default { - _error $this "Only 'ff' and 'reset' merge is currently supported." - return 0 - } + default { + _error $this "Only 'ff' and 'reset' merge is currently supported." + return 0 + } + } } } -- cgit v0.10.2-6-g49f6 From eea1ab6e23db4c929500fb11464a438b0ba569f0 Mon Sep 17 00:00:00 2001 From: "Shawn O. Pearce" Date: Fri, 20 Jul 2007 03:37:43 -0400 Subject: git-gui: Simplify error case for unsupported merge types If we are given a merge type we don't understand in checkout_op there is probably a bug in git-gui somewhere that allowed this unknown merge strategy to come into this part of the code path. We currently only recognize three merge types ('none', 'ff' and 'reset') but are going to be supporting more in the future. Rather than keep editing this message I'm going with a very generic "Uh, we don't do that!" type of error. Signed-off-by: Shawn O. Pearce diff --git a/lib/checkout_op.tcl b/lib/checkout_op.tcl index 6d87830..554c107 100644 --- a/lib/checkout_op.tcl +++ b/lib/checkout_op.tcl @@ -208,7 +208,7 @@ method _update_ref {} { } } default { - _error $this "Only 'ff' and 'reset' merge is currently supported." + _error $this "Merge strategy '$merge_type' not supported." return 0 } } -- cgit v0.10.2-6-g49f6 From dba07411da8debf9e39bf8d28f642b09c5794aff Mon Sep 17 00:00:00 2001 From: "Shawn O. Pearce" Date: Fri, 20 Jul 2007 03:56:06 -0400 Subject: git-gui: Skip unnecessary read-tree work during checkout I totally missed this obvious optimization in the checkout code path. If our current repository HEAD is actually at the commit we are moving to, and we agreed to perform this switch earlier, then we have no files to update in the working directory and any stale mtimes are simply not of consequence right now. We can pretend like we ran a read-tree and skip right into the post-read-tree work, such as updating the branch and setting the symbolic-ref. Signed-off-by: Shawn O. Pearce diff --git a/lib/checkout_op.tcl b/lib/checkout_op.tcl index 554c107..cb04d1e 100644 --- a/lib/checkout_op.tcl +++ b/lib/checkout_op.tcl @@ -266,7 +266,9 @@ The rescan will be automatically started now. return } - if {[is_config_true gui.trustmtime]} { + if {$curHEAD eq $new_hash} { + _after_readtree $this + } elseif {[is_config_true gui.trustmtime]} { _readtree $this } else { ui_status {Refreshing file status...} -- cgit v0.10.2-6-g49f6 From 54febd4fe62cc32b1337cd928af17a5a09624d74 Mon Sep 17 00:00:00 2001 From: "Shawn O. Pearce" Date: Fri, 20 Jul 2007 04:10:13 -0400 Subject: git-gui: Internally allow fetch without storing for future pull support This is actually just an underlying code improvement that has no user visible component yet. UI improvements to actually fetch and merge via an arbitrary remote with no tracking branches must still follow to make this change useful for the end-user. Our tracking branch specifications are a Tcl list of three components: - local tracking branch name - remote name/url - remote branch name/tag name This change just makes the first element optional. If it is an empty string we will run the fetch, but have the value be saved only into the special .git/FETCH_HEAD, where we can pick it up and use it for this one time operation. Signed-off-by: Shawn O. Pearce diff --git a/lib/checkout_op.tcl b/lib/checkout_op.tcl index cb04d1e..0571115 100644 --- a/lib/checkout_op.tcl +++ b/lib/checkout_op.tcl @@ -66,14 +66,19 @@ method run {} { set r_head [lindex $fetch_spec 2] regsub ^refs/heads/ $r_head {} r_name + set cmd [list git fetch $remote] + if {$l_trck ne {}} { + lappend cmd +$r_head:$l_trck + } else { + lappend cmd $r_head + } + _toplevel $this {Refreshing Tracking Branch} set w_cons [::console::embed \ $w.console \ "Fetching $r_name from $remote"] pack $w.console -fill both -expand 1 - $w_cons exec \ - [list git fetch $remote +$r_head:$l_trck] \ - [cb _finish_fetch] + $w_cons exec $cmd [cb _finish_fetch] bind $w <$M1B-Key-w> break bind $w <$M1B-Key-W> break @@ -114,6 +119,9 @@ method _noop {} {} method _finish_fetch {ok} { if {$ok} { set l_trck [lindex $fetch_spec 0] + if {$l_trck eq {}} { + set l_trck FETCH_HEAD + } if {[catch {set new_hash [git rev-parse --verify "$l_trck^0"]} err]} { set ok 0 $w_cons insert "fatal: Cannot resolve $l_trck" -- cgit v0.10.2-6-g49f6 From 854ffd3046ba9776934ffea79c5aceb1d51cf3c5 Mon Sep 17 00:00:00 2001 From: "Shawn O. Pearce" Date: Sat, 21 Jul 2007 16:32:42 -0400 Subject: git-gui: Completely remove my Tools/Migrate hack This menu option of Tools/Migrate has been living inside of git-gui as a local hack to support some coworkers of mine. It has no value to anyone outside of my day-job team and never really should have been in a release version of git-gui. So I'm pulling it out, so that nobody else has to deal with this garbage. Signed-off-by: Shawn O. Pearce diff --git a/git-gui.sh b/git-gui.sh index d85d707..07a478c 100755 --- a/git-gui.sh +++ b/git-gui.sh @@ -1895,35 +1895,6 @@ if {[is_MacOSX]} { .mbar.edit add separator .mbar.edit add command -label {Options...} \ -command do_options - - # -- Tools Menu - # - if {[is_Cygwin] - && [is_enabled multicommit] - && [file exists /usr/local/miga/lib/gui-miga]} { - proc do_miga {} { - if {![lock_index update]} return - set cmd [list sh --login -c "/usr/local/miga/lib/gui-miga \"[pwd]\""] - set miga_fd [open "|$cmd" r] - fconfigure $miga_fd -blocking 0 - fileevent $miga_fd readable [list miga_done $miga_fd] - ui_status {Running miga...} - } - proc miga_done {fd} { - read $fd 512 - if {[eof $fd]} { - close $fd - unlock_index - rescan ui_ready - } - } - .mbar add cascade -label Tools -menu .mbar.tools - menu .mbar.tools - .mbar.tools add command -label "Migrate" \ - -command do_miga - lappend disable_on_lock \ - [list .mbar.tools entryconf [.mbar.tools index last] -state] - } } # -- Help Menu -- cgit v0.10.2-6-g49f6 From 7bd197c7ba0b93744bf0f804ec4fb0d448044e83 Mon Sep 17 00:00:00 2001 From: "Shawn O. Pearce" Date: Sun, 22 Jul 2007 04:09:53 -0400 Subject: git-gui: Fix unnecessary fast-forward during checkout If we are trying to checkout a local branch which is matched to a remote tracking branch, but the local branch is newer than the remote tracking branch we actually just want to switch to the local branch. The local branch is "Already up to date". Unfortunately we tossed away the local branch's commit SHA-1 and kept the remote tracking branch's SHA-1, which meant that the user lost the local changes when we updated the working directory. At least we did not update the local branch ref, so the user's data was still intact. We now toss the tracking branch's SHA-1 and replace with the local branch's SHA-1 before the checkout, ensuring that we pass of the right tree to git-read-tree when we update the working directory. Signed-off-by: Shawn O. Pearce diff --git a/lib/checkout_op.tcl b/lib/checkout_op.tcl index 0571115..8c42ca8 100644 --- a/lib/checkout_op.tcl +++ b/lib/checkout_op.tcl @@ -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 -- cgit v0.10.2-6-g49f6 From e7d7b1a34ea3d3e4ee44471acbc97eda9bfffb55 Mon Sep 17 00:00:00 2001 From: "Shawn O. Pearce" Date: Mon, 23 Jul 2007 00:12:30 -0400 Subject: git-gui: Clarify meaning of add tracked menu option Junio recently pointed out on the mailing list that our "Add Existing" feature is a lot like `git add -u`, which is generally described as "(Re)Add Tracked Files". This came up during discussion of how to translate "Add Existing" into Japanese, as the individual working on the translation was not quite sure what the option meant and therefore had some trouble selecting the best translation. I'm changing the menu option to "Add Tracked Files To Commit" and the button to "Add Tracked". This should help new users to better understand the actions behind those GUI widgets. Signed-off-by: Shawn O. Pearce diff --git a/git-gui.sh b/git-gui.sh index 07a478c..67aed3a 100755 --- a/git-gui.sh +++ b/git-gui.sh @@ -1822,7 +1822,7 @@ if {[is_enabled multicommit] || [is_enabled singlecommit]} { lappend disable_on_lock \ [list .mbar.commit entryconf [.mbar.commit index last] -state] - .mbar.commit add command -label {Add Existing To Commit} \ + .mbar.commit add command -label {Add Tracked Files To Commit} \ -command do_add_all \ -accelerator $M1T-I lappend disable_on_lock \ @@ -2144,7 +2144,7 @@ pack .vpane.lower.commarea.buttons.rescan -side top -fill x lappend disable_on_lock \ {.vpane.lower.commarea.buttons.rescan conf -state} -button .vpane.lower.commarea.buttons.incall -text {Add Existing} \ +button .vpane.lower.commarea.buttons.incall -text {Add Tracked} \ -command do_add_all pack .vpane.lower.commarea.buttons.incall -side top -fill x lappend disable_on_lock \ -- cgit v0.10.2-6-g49f6 From 9c5a3c7797449e1b3e6455327394677c21f0f908 Mon Sep 17 00:00:00 2001 From: "Shawn O. Pearce" Date: Mon, 23 Jul 2007 00:20:04 -0400 Subject: git-gui: Paper bag fix quitting crash after commit My earlier introduction of the GITGUI_BCK file (which saves the user's commit message buffer while they are typing it) broke the Quit function. If the user makes a commit we delete the GITGUI_BCK file; if they then immediately quit the application we fail to rename the GITGUI_BCK file to GITGUI_MSG. This is because the file does not exist, but our flag still says it does. The root cause is we did not unset the flag during commit. Signed-off-by: Shawn O. Pearce diff --git a/lib/commit.tcl b/lib/commit.tcl index 6b86f98..1f5c2c3 100644 --- a/lib/commit.tcl +++ b/lib/commit.tcl @@ -381,7 +381,7 @@ A rescan will be automatically started now. $ui_comm edit modified false if {$::GITGUI_BCK_exists} { catch {file delete [gitdir GITGUI_BCK]} - set $::GITGUI_BCK_exists 0 + set ::GITGUI_BCK_exists 0 } if {[is_enabled singlecommit]} do_quit -- cgit v0.10.2-6-g49f6 From 83751fc109e951a5cbde9ee39970f6b1d2da07c7 Mon Sep 17 00:00:00 2001 From: "Shawn O. Pearce" Date: Mon, 23 Jul 2007 00:36:39 -0400 Subject: git-gui: Refactor diff popup into a procedure to ease i18n work The folks working on the i18n version of git-gui have had some trouble trying to convert these English strings into [mc] calls due to the double evaluation. Moving this block into a standard procedure eliminates the double evaluation, making their work easier. Signed-off-by: Shawn O. Pearce diff --git a/git-gui.sh b/git-gui.sh index 67aed3a..2912872 100755 --- a/git-gui.sh +++ b/git-gui.sh @@ -2418,17 +2418,19 @@ lappend diff_actions [list $ctxm entryconf [$ctxm index last] -state] $ctxm add separator $ctxm add command -label {Options...} \ -command do_options -bind_button3 $ui_diff " - set cursorX %x - set cursorY %y - if {\$ui_index eq \$current_diff_side} { - $ctxm entryconf $ui_diff_applyhunk -label {Unstage Hunk From Commit} +proc popup_diff_menu {ctxm x y X Y} { + set ::cursorX $x + set ::cursorY $y + if {$::ui_index eq $::current_diff_side} { + $ctxm entryconf $::ui_diff_applyhunk \ + -label {Unstage Hunk From Commit} } else { - $ctxm entryconf $ui_diff_applyhunk -label {Stage Hunk For Commit} + $ctxm entryconf $::ui_diff_applyhunk \ + -label {Stage Hunk For Commit} } - tk_popup $ctxm %X %Y -" -unset ui_diff_applyhunk + tk_popup $ctxm $X $Y +} +bind_button3 $ui_diff [list popup_diff_menu $ctxm %x %y %X %Y] # -- Status Bar # -- cgit v0.10.2-6-g49f6 From a8139888f8d250c6d173ddbe892e98fc49763702 Mon Sep 17 00:00:00 2001 From: "Shawn O. Pearce" Date: Mon, 23 Jul 2007 01:11:08 -0400 Subject: git-gui: Refactor current branch menu items to make i18n easier The i18n team has also identified a rather ugly block of code in git-gui that is used to make a pair of Repository menu items show the current branch name. This code is difficult to convert to use [mc ...] to lookup the translation, so I'm refactoring it into a procedure. Signed-off-by: Shawn O. Pearce diff --git a/git-gui.sh b/git-gui.sh index 2912872..a38293a 100755 --- a/git-gui.sh +++ b/git-gui.sh @@ -1682,7 +1682,7 @@ menu .mbar.repository .mbar.repository add command \ -label {Browse Current Branch's Files} \ -command {browser::new $current_branch} -trace add variable current_branch write ".mbar.repository entryconf [.mbar.repository index last] -label \"Browse \$current_branch's Files\" ;#" +set ui_browse_current [.mbar.repository index last] .mbar.repository add command \ -label {Browse Branch Files...} \ -command browser_open::dialog @@ -1691,12 +1691,21 @@ trace add variable current_branch write ".mbar.repository entryconf [.mbar.repos .mbar.repository add command \ -label {Visualize Current Branch's History} \ -command {do_gitk $current_branch} -trace add variable current_branch write ".mbar.repository entryconf [.mbar.repository index last] -label \"Visualize \$current_branch's History\" ;#" +set ui_visualize_current [.mbar.repository index last] .mbar.repository add command \ -label {Visualize All Branch History} \ -command {do_gitk --all} .mbar.repository add separator +proc current_branch_write {args} { + global current_branch + .mbar.repository entryconf $::ui_browse_current \ + -label "Browse $current_branch's Files" + .mbar.repository entryconf $::ui_visualize_current \ + -label "Visualize $current_branch's History" +} +trace add variable current_branch write current_branch_write + if {[is_enabled multicommit]} { .mbar.repository add command -label {Database Statistics} \ -command do_stats -- cgit v0.10.2-6-g49f6 From 7d5266a704ea55b11799bf0431d1648282f53d54 Mon Sep 17 00:00:00 2001 From: "Shawn O. Pearce" Date: Sun, 22 Jul 2007 04:49:06 -0400 Subject: 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 diff --git a/lib/checkout_op.tcl b/lib/checkout_op.tcl index 8c42ca8..40cc73a 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 -- cgit v0.10.2-6-g49f6 From 30d1990584301132892e9f184bff9705f74a1565 Mon Sep 17 00:00:00 2001 From: "Shawn O. Pearce" Date: Wed, 25 Jul 2007 03:27:57 -0400 Subject: git-gui: Save remote urls obtained from config/remotes setup I'm storing the URLs of any pre-configured remote repositories that we happen to come across so that we can later use these URLs to show to the user in parts of the UI that might care. Signed-off-by: Shawn O. Pearce diff --git a/lib/remote.tcl b/lib/remote.tcl index e235ca8..cf9b9d5 100644 --- a/lib/remote.tcl +++ b/lib/remote.tcl @@ -57,6 +57,7 @@ proc all_tracking_branches {} { proc load_all_remotes {} { global repo_config global all_remotes tracking_branches some_heads_tracking + global remote_url set some_heads_tracking 0 set all_remotes [list] @@ -76,6 +77,10 @@ proc load_all_remotes {} { catch { set fd [open [file join $rm_dir $name] r] while {[gets $fd line] >= 0} { + if {[regexp {^URL:[ ]*(.+)$} $line line url]} { + set remote_url($name) $url + continue + } if {![regexp {^Pull:[ ]*([^:]+):(.+)$} \ $line line src dst]} continue if {[string index $src 0] eq {+}} { @@ -100,6 +105,7 @@ proc load_all_remotes {} { foreach line [array names repo_config remote.*.url] { if {![regexp ^remote\.(.*)\.url\$ $line line name]} continue lappend all_remotes $name + set remote_url($name) $repo_config(remote.$name.url) if {[catch {set fl $repo_config(remote.$name.fetch)}]} { set fl {} -- cgit v0.10.2-6-g49f6 From 844c3f6fe9d4d2bdc4e76f6a3bf3dfe86ce8c544 Mon Sep 17 00:00:00 2001 From: "Shawn O. Pearce" Date: Wed, 25 Jul 2007 04:13:00 -0400 Subject: git-gui: Display commit/tag/remote info in tooltip of revision picker Our revision chooser mega-widget now sets up tooltips for itself so that it displays details about a commit (or a tag and the commit it refers to) when the user mouses over that line in the filtered ref list. If the item is from a remote tracking branch then we also show the remote url and what branch on that remote we fetch from, so the user has a clear concept of where that revision data originated. To help the merge dialog I've also added a new constructor that makes the dialog only offer unmerged revisions (those not in HEAD), as this allows users to avoid performing merges only to get "Already up to date" messages back from core Git. Signed-off-by: Shawn O. Pearce diff --git a/lib/choose_rev.tcl b/lib/choose_rev.tcl index 6c4c318..bb6966e 100644 --- a/lib/choose_rev.tcl +++ b/lib/choose_rev.tcl @@ -16,8 +16,21 @@ field cur_specs [list]; # list of specs for $revtype field spec_head ; # list of all head specs field spec_trck ; # list of all tracking branch specs field spec_tag ; # list of all tag specs +field tip_data ; # array of tip commit info by refname -constructor new {path {title {}}} { +field tooltip_wm {} ; # Current tooltip toplevel, if open +field tooltip_t {} ; # Text widget in $tooltip_wm +field tooltip_timer {} ; # Current timer event for our tooltip + +proc new {path {title {}}} { + return [_new $path 0 $title] +} + +proc new_unmerged {path {title {}}} { + return [_new $path 1 $title] +} + +constructor _new {path unmerged_only title} { global current_branch is_detached set w $path @@ -93,6 +106,10 @@ constructor new {path {title {}}} { -yscrollcommand [cb _sb_set $w.list.sby v] pack $w_list -fill both -expand 1 grid $w.list -sticky nswe -padx {20 5} -columnspan 2 + bind $w_list [cb _show_tooltip @%x,%y] + bind $w_list [cb _hide_tooltip] + bind $w_list [cb _hide_tooltip] + bind $w_list [cb _hide_tooltip] grid columnconfigure $w 1 -weight 1 if {$is_detached} { @@ -105,21 +122,89 @@ constructor new {path {title {}}} { bind $w_filter [list focus $w_list]\;break bind $w_filter [list focus $w_list] + set fmt list + append fmt { %(refname)} + append fmt { [list} + append fmt { %(objecttype)} + append fmt { %(objectname)} + append fmt { [concat %(taggername) %(authorname)]} + append fmt { [concat %(taggerdate) %(authordate)]} + append fmt { %(subject)} + append fmt {] [list} + append fmt { %(*objecttype)} + append fmt { %(*objectname)} + append fmt { %(*authorname)} + append fmt { %(*authordate)} + append fmt { %(*subject)} + append fmt {]} + set all_refn [list] + set fr_fd [git_read for-each-ref \ + --tcl \ + --sort=-taggerdate \ + --format=$fmt \ + refs/heads \ + refs/remotes \ + refs/tags \ + ] + fconfigure $fr_fd -translation lf -encoding utf-8 + while {[gets $fr_fd line] > 0} { + set line [eval $line] + if {[lindex $line 1 0] eq {tag}} { + if {[lindex $line 2 0] eq {commit}} { + set sha1 [lindex $line 2 1] + } else { + continue + } + } elseif {[lindex $line 1 0] eq {commit}} { + set sha1 [lindex $line 1 1] + } else { + continue + } + set refn [lindex $line 0] + set tip_data($refn) [lrange $line 1 end] + lappend cmt_refn($sha1) $refn + lappend all_refn $refn + } + close $fr_fd + + if {$unmerged_only} { + set fr_fd [git_read rev-list --all ^$::HEAD] + while {[gets $fr_fd sha1] > 0} { + if {[catch {set rlst $cmt_refn($sha1)}]} continue + foreach refn $rlst { + set inc($refn) 1 + } + } + close $fr_fd + } else { + foreach refn $all_refn { + set inc($refn) 1 + } + } + set spec_head [list] foreach name [load_all_heads] { - lappend spec_head [list $name refs/heads/$name] + set refn refs/heads/$name + if {[info exists inc($refn)]} { + lappend spec_head [list $name $refn] + } } set spec_trck [list] foreach spec [all_tracking_branches] { - set name [lindex $spec 0] - regsub ^refs/(heads|remotes)/ $name {} name - lappend spec_trck [concat $name $spec] + set refn [lindex $spec 0] + if {[info exists inc($refn)]} { + regsub ^refs/(heads|remotes)/ $refn {} name + lappend spec_trck [concat $name $spec] + } } set spec_tag [list] foreach name [load_all_tags] { - lappend spec_tag [list $name refs/tags/$name] + set refn refs/tags/$name + if {[info exists inc($refn)]} { + lappend spec_tag [list $name $refn] + } } if {$is_detached} { set revtype HEAD @@ -364,4 +449,143 @@ method _sb_set {sb orient first last} { $sb set $first $last } +method _show_tooltip {pos} { + if {$tooltip_wm ne {}} { + _open_tooltip $this + } elseif {$tooltip_timer eq {}} { + set tooltip_timer [after 1000 [cb _open_tooltip]] + } +} + +method _open_tooltip {} { + global remote_url + + set tooltip_timer {} + set pos_x [winfo pointerx $w_list] + set pos_y [winfo pointery $w_list] + if {[winfo containing $pos_x $pos_y] ne $w_list} { + _hide_tooltip $this + return + } + + set pos @[join [list \ + [expr {$pos_x - [winfo rootx $w_list]}] \ + [expr {$pos_y - [winfo rooty $w_list]}]] ,] + set lno [$w_list index $pos] + if {$lno eq {}} { + _hide_tooltip $this + return + } + + set spec [lindex $cur_specs $lno] + set refn [lindex $spec 1] + if {$refn eq {}} { + _hide_tooltip $this + return + } + + if {$tooltip_wm eq {}} { + set tooltip_wm [toplevel $w_list.tooltip -borderwidth 1] + wm overrideredirect $tooltip_wm 1 + wm transient $tooltip_wm [winfo toplevel $w_list] + set tooltip_t $tooltip_wm.label + text $tooltip_t \ + -takefocus 0 \ + -highlightthickness 0 \ + -relief flat \ + -borderwidth 0 \ + -wrap none \ + -background lightyellow \ + -foreground black + $tooltip_t tag conf section_header -font font_uibold + bind $tooltip_wm [cb _hide_tooltip] + pack $tooltip_t + } else { + $tooltip_t conf -state normal + $tooltip_t delete 0.0 end + } + + set data $tip_data($refn) + if {[lindex $data 0 0] eq {tag}} { + set tag [lindex $data 0] + if {[lindex $data 1 0] eq {commit}} { + set cmit [lindex $data 1] + } else { + set cmit {} + } + } elseif {[lindex $data 0 0] eq {commit}} { + set tag {} + set cmit [lindex $data 0] + } + + $tooltip_t insert end "[lindex $spec 0]\n" + + if {$tag ne {}} { + $tooltip_t insert end "\n" + $tooltip_t insert end "tag" section_header + $tooltip_t insert end " [lindex $tag 1]\n" + $tooltip_t insert end [lindex $tag 2] + $tooltip_t insert end " ([lindex $tag 3])\n" + $tooltip_t insert end [lindex $tag 4] + $tooltip_t insert end "\n" + } + + if {$cmit ne {}} { + $tooltip_t insert end "\n" + $tooltip_t insert end "commit" section_header + $tooltip_t insert end " [lindex $cmit 1]\n" + $tooltip_t insert end [lindex $cmit 2] + $tooltip_t insert end " ([lindex $cmit 3])\n" + $tooltip_t insert end [lindex $cmit 4] + } + + if {[llength $spec] > 2} { + $tooltip_t insert end "\n" + $tooltip_t insert end "remote" section_header + $tooltip_t insert end " [lindex $spec 2]\n" + $tooltip_t insert end "url" + $tooltip_t insert end " $remote_url([lindex $spec 2])\n" + $tooltip_t insert end "branch" + $tooltip_t insert end " [lindex $spec 3]" + } + + $tooltip_t conf -state disabled + _position_tooltip $this +} + +method _position_tooltip {} { + set max_h [lindex [split [$tooltip_t index end] .] 0] + set max_w 0 + for {set i 1} {$i <= $max_h} {incr i} { + set c [lindex [split [$tooltip_t index "$i.0 lineend"] .] 1] + if {$c > $max_w} {set max_w $c} + } + $tooltip_t conf -width $max_w -height $max_h + + set req_w [winfo reqwidth $tooltip_t] + set req_h [winfo reqheight $tooltip_t] + set pos_x [expr {[winfo pointerx .] + 5}] + set pos_y [expr {[winfo pointery .] + 10}] + + set g "${req_w}x${req_h}" + if {$pos_x >= 0} {append g +} + append g $pos_x + if {$pos_y >= 0} {append g +} + append g $pos_y + + wm geometry $tooltip_wm $g + raise $tooltip_wm +} + +method _hide_tooltip {} { + if {$tooltip_wm ne {}} { + destroy $tooltip_wm + set tooltip_wm {} + } + if {$tooltip_timer ne {}} { + after cancel $tooltip_timer + set tooltip_timer {} + } +} + } -- cgit v0.10.2-6-g49f6 From becafaace69980d2980802432e86e7873317a4b6 Mon Sep 17 00:00:00 2001 From: "Shawn O. Pearce" Date: Wed, 25 Jul 2007 04:20:02 -0400 Subject: git-gui: Show ref last update times in revision chooser tooltips If we can we now show the last modification date of a loose ref as part of the tooltip information shown in the revision picker. This gives the user an indication of when was the last time that the ref was modified locally, and may especially be of interest when looking at a tracking branch. If we cannot find the loose ref file than we try to fallback on the reflog and scan it for the date of the last record. We don't start with the reflog however as scanning it backwards from the end is not an easy thing to do in Tcl. So I'm being lazy here and just going through the entire file, line by line. Since that is less efficient than a single stat system call, its our fallback strategy. Signed-off-by: Shawn O. Pearce diff --git a/lib/choose_rev.tcl b/lib/choose_rev.tcl index bb6966e..4147b7c 100644 --- a/lib/choose_rev.tcl +++ b/lib/choose_rev.tcl @@ -17,6 +17,7 @@ field spec_head ; # list of all head specs field spec_trck ; # list of all tracking branch specs field spec_tag ; # list of all tag specs field tip_data ; # array of tip commit info by refname +field log_last ; # array of reflog date by refname field tooltip_wm {} ; # Current tooltip toplevel, if open field tooltip_t {} ; # Text widget in $tooltip_wm @@ -518,7 +519,14 @@ method _open_tooltip {} { set cmit [lindex $data 0] } - $tooltip_t insert end "[lindex $spec 0]\n" + $tooltip_t insert end [lindex $spec 0] + set last [_reflog_last $this [lindex $spec 1]] + if {$last ne {}} { + $tooltip_t insert end "\n" + $tooltip_t insert end "updated" + $tooltip_t insert end " $last" + } + $tooltip_t insert end "\n" if {$tag ne {}} { $tooltip_t insert end "\n" @@ -553,6 +561,30 @@ method _open_tooltip {} { _position_tooltip $this } +method _reflog_last {name} { + if {[info exists reflog_last($name)]} { + return reflog_last($name) + } + + set last {} + if {[catch {set last [file mtime [gitdir $name]]}] + && ![catch {set g [open [gitdir logs $name] r]}]} { + fconfigure $g -translation binary + while {[gets $g line] >= 0} { + if {[regexp {> ([1-9][0-9]*) } $line line when]} { + set last $when + } + } + close $g + } + + if {$last ne {}} { + set last [clock format $last -format {%a %b %e %H:%M:%S %Y}] + } + set reflog_last($name) $last + return $last +} + method _position_tooltip {} { set max_h [lindex [split [$tooltip_t index end] .] 0] set max_w 0 -- cgit v0.10.2-6-g49f6 From 350a35f0a17af071af3f6f76d9fc6f63265b23d2 Mon Sep 17 00:00:00 2001 From: "Shawn O. Pearce" Date: Wed, 25 Jul 2007 03:44:50 -0400 Subject: git-gui: Replace merge dialog with our revision picker widget Now that we only support merging one branch we can offer the user a better user interface experience by allowing them to select the revision they want to merge through our revision picking widget. This change neatly solves the problem of locating a branch out of a sea of 200 tracking branches, and of dealing with very long branch names that all have a common prefix. Signed-off-by: Shawn O. Pearce diff --git a/lib/merge.tcl b/lib/merge.tcl index e5a7525..f8d92b3 100644 --- a/lib/merge.tcl +++ b/lib/merge.tcl @@ -4,8 +4,7 @@ class merge { field w ; # top level window -field w_list ; # widget of available branches -field list ; # list of available branches +field w_rev ; # mega-widget to pick the revision to merge method _can_merge {} { global HEAD commit_type file_states @@ -68,11 +67,10 @@ You should complete the current commit before starting a merge. Doing so will h } method _rev {} { - set i [$w_list curselection] - if {$i >= 0} { - return [lindex [lindex $list $i] 0] + if {[catch {$w_rev commit_or_die}]} { + return {} } - return {} + return [$w_rev get] } method _visualize {} { @@ -121,38 +119,6 @@ constructor dialog {} { return } - set fmt {list %(objectname) %(*objectname) %(refname) %(subject)} - set fr_fd [git_read for-each-ref \ - --tcl \ - --format=$fmt \ - refs/heads \ - refs/remotes \ - refs/tags \ - ] - fconfigure $fr_fd -translation binary - while {[gets $fr_fd line] > 0} { - set line [eval $line] - set ref [lindex $line 2] - regsub ^refs/(heads|remotes|tags)/ $ref {} ref - set subj($ref) [lindex $line 3] - lappend sha1([lindex $line 0]) $ref - if {[lindex $line 1] ne {}} { - lappend sha1([lindex $line 1]) $ref - } - } - close $fr_fd - - set list [list] - set fr_fd [git_read rev-list --all --not HEAD] - while {[gets $fr_fd line] > 0} { - if {[catch {set ref $sha1($line)}]} continue - foreach n $ref { - lappend list [list $n $line] - } - } - close $fr_fd - set list [lsort -unique $list] - make_toplevel top w wm title $top "[appname] ([reponame]): Merge" if {$top ne {.}} { @@ -178,39 +144,11 @@ constructor dialog {} { pack $w.buttons.cancel -side right -padx 5 pack $w.buttons -side bottom -fill x -pady 10 -padx 10 - labelframe $w.source -text {Source Branches} - set w_list $w.source.l - listbox $w_list \ - -height 10 \ - -width 70 \ - -font font_diff \ - -selectmode browse \ - -yscrollcommand [list $w.source.sby set] - scrollbar $w.source.sby -command [list $w_list yview] - pack $w.source.sby -side right -fill y - pack $w_list -side left -fill both -expand 1 - pack $w.source -fill both -expand 1 -pady 5 -padx 5 - - foreach ref $list { - set n [lindex $ref 0] - if {[string length $n] > 20} { - set n "[string range $n 0 16]..." - } - $w_list insert end [format {%s %-20s %s} \ - [string range [lindex $ref 1] 0 5] \ - $n \ - $subj([lindex $ref 0])] - } - - bind $w_list [list event generate %W ] - bind $w_list [list event generate %W ] - bind $w_list [list event generate %W ] - bind $w_list [list event generate %W ] - bind $w_list [list event generate %W ] - bind $w_list [list event generate %W ] - bind $w_list $_visualize + set w_rev [::choose_rev::new_unmerged $w.rev {Revision To Merge}] + pack $w.rev -anchor nw -fill both -expand 1 -pady 5 -padx 5 bind $w <$M1B-Key-Return> $_start + bind $w $_start bind $w [cb _visible] bind $w [cb _cancel] wm protocol $w WM_DELETE_WINDOW [cb _cancel] @@ -219,7 +157,10 @@ constructor dialog {} { method _visible {} { grab $w - focus $w_list + if {[is_config_true gui.matchtrackingbranch]} { + $w_rev pick_tracking_branch + } + $w_rev focus_filter } method _cancel {} { -- cgit v0.10.2-6-g49f6 From 9feefbd2d285f9af629cff9075eff06cf33d9de9 Mon Sep 17 00:00:00 2001 From: "Shawn O. Pearce" Date: Wed, 25 Jul 2007 04:32:18 -0400 Subject: git-gui: Cleanup bindings within merge dialog Misc. code cleanups in the merge dialog's binding setup and action button creation. Signed-off-by: Shawn O. Pearce diff --git a/lib/merge.tcl b/lib/merge.tcl index f8d92b3..62434ff 100644 --- a/lib/merge.tcl +++ b/lib/merge.tcl @@ -125,7 +125,6 @@ constructor dialog {} { wm geometry $top "+[winfo rootx .]+[winfo rooty .]" } - set _visualize [cb _visualize] set _start [cb _start] label $w.header \ @@ -134,10 +133,14 @@ constructor dialog {} { pack $w.header -side top -fill x frame $w.buttons - button $w.buttons.visualize -text Visualize -command $_visualize + button $w.buttons.visualize \ + -text Visualize \ + -command [cb _visualize] pack $w.buttons.visualize -side left - button $w.buttons.create -text Merge -command $_start - pack $w.buttons.create -side right + button $w.buttons.merge \ + -text Merge \ + -command $_start + pack $w.buttons.merge -side right button $w.buttons.cancel \ -text {Cancel} \ -command [cb _cancel] @@ -149,9 +152,10 @@ constructor dialog {} { bind $w <$M1B-Key-Return> $_start bind $w $_start - bind $w [cb _visible] bind $w [cb _cancel] wm protocol $w WM_DELETE_WINDOW [cb _cancel] + + bind $w.buttons.merge [cb _visible] tkwait window $w } -- cgit v0.10.2-6-g49f6 From ead49f5a4f6c87e5dc61ed5daaeda1bae7644d05 Mon Sep 17 00:00:00 2001 From: "Shawn O. Pearce" Date: Wed, 25 Jul 2007 04:54:53 -0400 Subject: git-gui: Format tracking branch merges as though they were pulls If we are merging a tracking branch we know exactly what remote URL that branch is fetched from, and what its name is on that remote repository. In this case we can setup a merge message that looks just like a standard `git-pull $remote $branch` operation by filling out FETCH_HEAD before we start git-merge, and then run git-merge just like git-pull does. I think the result of this behavior is that merges look a lot nicer when the came off of local tracking branches, because they no longer say "commit 'origin/...'" to describe the commit being merged but instead now mention the specific repository we fetched those commits from. Signed-off-by: Shawn O. Pearce diff --git a/lib/merge.tcl b/lib/merge.tcl index 62434ff..c8b4867 100644 --- a/lib/merge.tcl +++ b/lib/merge.tcl @@ -81,17 +81,41 @@ method _visualize {} { } method _start {} { - global HEAD current_branch + global HEAD current_branch remote_url set name [_rev $this] if {$name eq {}} { return } - set cmd [list git merge $name] - set msg "Merging $current_branch and $name" + set spec [$w_rev get_tracking_branch] + set cmit [$w_rev get_commit] + set cmd [list git] + lappend cmd merge + lappend cmd --strategy=recursive + + set fh [open [gitdir FETCH_HEAD] w] + fconfigure $fh -translation lf + if {$spec eq {}} { + set remote . + set branch $name + set stitle $branch + } else { + set remote $remote_url([lindex $spec 1]) + set branch [lindex $spec 2] + set stitle "$branch of $remote" + } + regsub ^refs/heads/ $branch {} branch + puts $fh "$cmit\t\tbranch '$branch' of $remote" + close $fh + + lappend cmd [git fmt-merge-msg <[gitdir FETCH_HEAD]] + lappend cmd HEAD + lappend cmd $cmit + + set msg "Merging $current_branch and $stitle" ui_status "$msg..." - set cons [console::new "Merge" $cmd] + set cons [console::new "Merge" "merge $stitle"] console::exec $cons $cmd [cb _finish $cons] wm protocol $w WM_DELETE_WINDOW {} -- cgit v0.10.2-6-g49f6 From bc318ea86d3ecd4074ecde3122b1e65f84cf9996 Mon Sep 17 00:00:00 2001 From: "Shawn O. Pearce" Date: Wed, 25 Jul 2007 05:02:38 -0400 Subject: git-gui: Remove usernames from absolute SSH urls during merging If we are being asked to merge a tracking branch that comes from a remote repository accessed by the very common SSH URL format of "user@host:/path/to/repo" then we really don't need the username as part of the merge message, it only clutters up the history and makes things more confusing. So we instead clip the username part off if the local filesystem path is absolute, as its probably not going to be an ambiguous URL even when it is missing the username. On the other hand we cannot clip the username off if the URL is not absolute, because in such cases (e.g. "user@host:myrepo") the directory that the repository path is resolved in is relative to the user's home directory, and the username becomes important. Signed-off-by: Shawn O. Pearce diff --git a/lib/merge.tcl b/lib/merge.tcl index c8b4867..148d859 100644 --- a/lib/merge.tcl +++ b/lib/merge.tcl @@ -102,6 +102,9 @@ method _start {} { set stitle $branch } else { set remote $remote_url([lindex $spec 1]) + if {[regexp {^[^:@]*@[^:]*:/} $remote]} { + regsub {^[^:@]*@} $remote {} remote + } set branch [lindex $spec 2] set stitle "$branch of $remote" } -- cgit v0.10.2-6-g49f6 From 1e0a92fdf74caa0bf850f73e284818473c8f76e0 Mon Sep 17 00:00:00 2001 From: "Shawn O. Pearce" Date: Fri, 27 Jul 2007 02:30:15 -0400 Subject: git-gui: Don't kill modified commit message buffer with merge templates If the user is in the middle of a merge and has already started to modify their commit message we were losing the user's changes when they pressed 'Rescan' after resolving issues or making changes in the working directory. The problem here was our background timer that saves the commit message buffer. It marks the commit message buffer as not being modified when it writes it out to disk, so during the rescan we assumed the buffer should be replaced with what we read from the MERGE_MSG file. So we now only read these files from .git if we have a valid backup file. Since we clear it on commit this will only have an impact while the user is actively editing the current commit. Signed-off-by: Shawn O. Pearce diff --git a/git-gui.sh b/git-gui.sh index a38293a..f87b955 100755 --- a/git-gui.sh +++ b/git-gui.sh @@ -829,8 +829,9 @@ proc rescan {after {honor_trustmtime 1}} { array unset file_states - if {![$ui_comm edit modified] - || [string trim [$ui_comm get 0.0 end]] eq {}} { + if {!$::GITGUI_BCK_exists && + (![$ui_comm edit modified] + || [string trim [$ui_comm get 0.0 end]] eq {})} { if {[string match amend* $commit_type]} { } elseif {[load_message GITGUI_MSG]} { } elseif {[load_message MERGE_MSG]} { -- cgit v0.10.2-6-g49f6 From 360cc106e76ea2a4ba424905c4924e9ed6a4165d Mon Sep 17 00:00:00 2001 From: Christian Stimming Date: Sat, 28 Jul 2007 22:17:10 +0200 Subject: git-gui: Unify wording to say "to stage" instead of "to add" Also, the warning message when clicking "Reset" is adapted to the wording "Reset" rather than a confusion "Cancel commit?". Signed-off-by: Christian Stimming Signed-off-by: Shawn O. Pearce diff --git a/git-gui.sh b/git-gui.sh index f87b955..d7fad46 100755 --- a/git-gui.sh +++ b/git-gui.sh @@ -1827,12 +1827,12 @@ if {[is_enabled multicommit] || [is_enabled singlecommit]} { lappend disable_on_lock \ [list .mbar.commit entryconf [.mbar.commit index last] -state] - .mbar.commit add command -label {Add To Commit} \ + .mbar.commit add command -label {Stage To Commit} \ -command do_add_selection lappend disable_on_lock \ [list .mbar.commit entryconf [.mbar.commit index last] -state] - .mbar.commit add command -label {Add Tracked Files To Commit} \ + .mbar.commit add command -label {Stage Changed Files To Commit} \ -command do_add_all \ -accelerator $M1T-I lappend disable_on_lock \ @@ -2154,7 +2154,7 @@ pack .vpane.lower.commarea.buttons.rescan -side top -fill x lappend disable_on_lock \ {.vpane.lower.commarea.buttons.rescan conf -state} -button .vpane.lower.commarea.buttons.incall -text {Add Tracked} \ +button .vpane.lower.commarea.buttons.incall -text {Stage Changed} \ -command do_add_all pack .vpane.lower.commarea.buttons.incall -side top -fill x lappend disable_on_lock \ diff --git a/lib/checkout_op.tcl b/lib/checkout_op.tcl index 40cc73a..170f737 100644 --- a/lib/checkout_op.tcl +++ b/lib/checkout_op.tcl @@ -248,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 } } diff --git a/lib/commit.tcl b/lib/commit.tcl index 1f5c2c3..f857a2f 100644 --- a/lib/commit.tcl +++ b/lib/commit.tcl @@ -153,7 +153,7 @@ The rescan will be automatically started now. U? { error_popup "Unmerged files cannot be committed. -File [short_path $path] has merge conflicts. You must resolve them and add the file before committing. +File [short_path $path] has merge conflicts. You must resolve them and stage the file before committing. " unlock_index return @@ -169,7 +169,7 @@ File [short_path $path] cannot be committed by this program. if {!$files_ready && ![string match *merge $curType]} { info_popup {No changes to commit. -You must add at least 1 file before you can commit. +You must stage at least 1 file before you can commit. } unlock_index return diff --git a/lib/index.tcl b/lib/index.tcl index 3ea72e1..f47f929 100644 --- a/lib/index.tcl +++ b/lib/index.tcl @@ -360,7 +360,7 @@ proc revert_helper {txt paths} { "[appname] ([reponame])" \ "Revert changes in $s? -Any unadded changes will be permanently lost by the revert." \ +Any unstaged changes will be permanently lost by the revert." \ question \ 1 \ {Do Nothing} \ diff --git a/lib/merge.tcl b/lib/merge.tcl index 148d859..f6a2df3 100644 --- a/lib/merge.tcl +++ b/lib/merge.tcl @@ -45,7 +45,7 @@ The rescan will be automatically started now. File [short_path $path] has merge conflicts. -You must resolve them, add the file, and commit to complete the current merge. Only then can you begin another merge. +You must resolve them, stage the file, and commit to complete the current merge. Only then can you begin another merge. " unlock_index return 0 @@ -219,16 +219,20 @@ You must finish amending this commit. if {![lock_index abort]} return if {[string match *merge* $commit_type]} { - set op merge + set op_question "Abort merge? + +Aborting the current merge will cause *ALL* uncommitted changes to be lost. + +Continue with aborting the current merge?" } else { - set op commit - } + set op_question "Reset changes? - if {[ask_popup "Abort $op? +Resetting the changes will cause *ALL* uncommitted changes to be lost. -Aborting the current $op will cause *ALL* uncommitted changes to be lost. +Continue with resetting the current changes?" + } -Continue with aborting the current $op?"] eq {yes}} { + if {[ask_popup $op_question] eq {yes}} { set fd [git_read read-tree --reset -u HEAD] fconfigure $fd -blocking 0 -translation binary fileevent $fd readable [namespace code [list _reset_wait $fd]] -- cgit v0.10.2-6-g49f6 From 94a4dd9bfda79a226f8dd57fd20c39c6603ec194 Mon Sep 17 00:00:00 2001 From: "Shawn O. Pearce" Date: Sun, 29 Jul 2007 03:22:27 -0400 Subject: git-gui: Honor core.excludesfile when listing extra files Recent git versions have a git-status that honors the core.excludesfile configuration option when it reports on untracked files. Unfortunately I missed the introduction of this configuration option in the core porcelain implementation, so it was not reflected here in git-gui. Found and reported by Lars Noschinski . Signed-off-by: Shawn O. Pearce diff --git a/git-gui.sh b/git-gui.sh index d7fad46..4e3b58c 100755 --- a/git-gui.sh +++ b/git-gui.sh @@ -872,6 +872,10 @@ proc rescan_stage2 {fd after} { if {[file readable $info_exclude]} { lappend ls_others "--exclude-from=$info_exclude" } + set user_exclude [get_config core.excludesfile] + if {$user_exclude ne {} && [file readable $user_exclude]} { + lappend ls_others "--exclude-from=$user_exclude" + } set buf_rdi {} set buf_rdf {} -- cgit v0.10.2-6-g49f6 From 0fe055cd2480763393b20676a10fd0bea56b2fc2 Mon Sep 17 00:00:00 2001 From: "Shawn O. Pearce" Date: Sun, 29 Jul 2007 04:06:51 -0400 Subject: git-gui: Use progress bar while resetting/aborting files Resetting a large number of files on a slow filesystem can take considerable time, just as switching branches in such a case can take more than two seconds. We now take advantage of the progress meter output by read-tree and show it in the main window status bar, just like we do during checkout (branch switch). Signed-off-by: Shawn O. Pearce diff --git a/lib/merge.tcl b/lib/merge.tcl index f6a2df3..66d1bcd 100644 --- a/lib/merge.tcl +++ b/lib/merge.tcl @@ -233,10 +233,10 @@ Continue with resetting the current changes?" } if {[ask_popup $op_question] eq {yes}} { - set fd [git_read read-tree --reset -u HEAD] + set fd [git_read --stderr read-tree --reset -u -v HEAD] fconfigure $fd -blocking 0 -translation binary fileevent $fd readable [namespace code [list _reset_wait $fd]] - ui_status {Aborting... please wait...} + $::main_status start {Aborting} {files reset} } else { unlock_index } @@ -245,9 +245,12 @@ Continue with resetting the current changes?" proc _reset_wait {fd} { global ui_comm - read $fd + $::main_status update_meter [read $fd] + + fconfigure $fd -blocking 1 if {[eof $fd]} { - close $fd + set fail [catch {close $fd} err] + $::main_status stop unlock_index $ui_comm delete 0.0 end @@ -259,7 +262,12 @@ proc _reset_wait {fd} { catch {file delete [gitdir MERGE_MSG]} catch {file delete [gitdir GITGUI_MSG]} + if {$fail} { + warn_popup "Abort failed.\n\n$err" + } rescan {ui_status {Abort completed. Ready.}} + } else { + fconfigure $fd -blocking 0 } } -- cgit v0.10.2-6-g49f6 From 95af4d8de16e8e681c196fce6d42e40909933115 Mon Sep 17 00:00:00 2001 From: "Shawn O. Pearce" Date: Sun, 29 Jul 2007 21:26:42 -0400 Subject: git-gui: Make sure remotes are loaded when picking revisions If we are started for only a blame/browser/citool run we don't usually initialize the list of remotes, or determine which refs are tracking branches and which are local branch heads. This is because some of that work is relatively expensive and is usually not going to be needed if we are started only for a blame, or to make a single commit. However by not loading the remote configuration we were crashing if the user tried to open a browser for another branch through the Repository menu, as our load_all_heads procedure was unable to decide which refs/heads/ items were actually local heads. We now force all remote configuration data to be loaded if we have not done so already and we are trying to create a revision mega widget. Signed-off-by: Shawn O. Pearce diff --git a/lib/choose_rev.tcl b/lib/choose_rev.tcl index 4147b7c..ec064b3 100644 --- a/lib/choose_rev.tcl +++ b/lib/choose_rev.tcl @@ -34,6 +34,10 @@ proc new_unmerged {path {title {}}} { constructor _new {path unmerged_only title} { global current_branch is_detached + if {![info exists ::all_remotes]} { + load_all_remotes + } + set w $path if {$title ne {}} { -- cgit v0.10.2-6-g49f6 From 37e2199c4c5b45e060f973097d814726cabe2a86 Mon Sep 17 00:00:00 2001 From: "Shawn O. Pearce" Date: Sun, 29 Jul 2007 20:29:52 -0400 Subject: git-gui: Don't offer to stage hunks from untracked files If the user looks at an untracked file in our diff pane we used to offer "Stage Hunk For Commit" in the context menu when they right-clicked in that pane. The problem is we don't actually have any diff hunks in untracked files, so there is nothing to really select for staging. So we now grey out the menu item, so the user cannot invoke it and think its broken when it does not perform any useful action. Signed-off-by: Shawn O. Pearce diff --git a/git-gui.sh b/git-gui.sh index 4e3b58c..0180756 100755 --- a/git-gui.sh +++ b/git-gui.sh @@ -2437,9 +2437,15 @@ proc popup_diff_menu {ctxm x y X Y} { set ::cursorY $y if {$::ui_index eq $::current_diff_side} { $ctxm entryconf $::ui_diff_applyhunk \ + -state normal \ -label {Unstage Hunk From Commit} + } elseif {{_O} eq [lindex $::file_states($::current_diff_path) 0]} { + $ctxm entryconf $::ui_diff_applyhunk \ + -state disabled \ + -label {Stage Hunk For Commit} } else { $ctxm entryconf $::ui_diff_applyhunk \ + -state normal \ -label {Stage Hunk For Commit} } tk_popup $ctxm $X $Y -- cgit v0.10.2-6-g49f6 From dac70892638d08f50c49c539155c4cb54a9b9c28 Mon Sep 17 00:00:00 2001 From: "Shawn O. Pearce" Date: Sun, 29 Jul 2007 21:19:54 -0400 Subject: git-gui: Use more modern looking icons in the tree browser This is a replacement of all of the icons in our tree browser window, as the prior icons just looked too 1980s Tk-ish. The icons used here are actually from a KDE themed look, so they might actually be familiar to some users of git-gui. Aside from using more modern looking icons we now have a special icon for executable blobs, to make them stand out from the normal non-executable blobs. We also denote symlinks now with a different icon, so they stand out from the other types of objects in the tree. Signed-off-by: Shawn O. Pearce diff --git a/git-gui.sh b/git-gui.sh index 0180756..671b887 100755 --- a/git-gui.sh +++ b/git-gui.sh @@ -1296,32 +1296,6 @@ static unsigned char file_merge_bits[] = { 0xfa, 0x17, 0x02, 0x10, 0xfe, 0x1f}; } -maskdata $filemask -set file_dir_data { -#define file_width 18 -#define file_height 18 -static unsigned char file_bits[] = { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0x03, 0x00, - 0x0c, 0x03, 0x00, 0x04, 0xfe, 0x00, 0x06, 0x80, 0x00, 0xff, 0x9f, 0x00, - 0x03, 0x98, 0x00, 0x02, 0x90, 0x00, 0x06, 0xb0, 0x00, 0x04, 0xa0, 0x00, - 0x0c, 0xe0, 0x00, 0x08, 0xc0, 0x00, 0xf8, 0xff, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; -} -image create bitmap file_dir -background white -foreground blue \ - -data $file_dir_data -maskdata $file_dir_data -unset file_dir_data - -set file_uplevel_data { -#define up_width 15 -#define up_height 15 -static unsigned char up_bits[] = { - 0x80, 0x00, 0xc0, 0x01, 0xe0, 0x03, 0xf0, 0x07, 0xf8, 0x0f, 0xfc, 0x1f, - 0xfe, 0x3f, 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01, - 0xc0, 0x01, 0xc0, 0x01, 0x00, 0x00}; -} -image create bitmap file_uplevel -background white -foreground red \ - -data $file_uplevel_data -maskdata $file_uplevel_data -unset file_uplevel_data - set ui_index .vpane.files.index.list set ui_workdir .vpane.files.workdir.list diff --git a/lib/browser.tcl b/lib/browser.tcl index b684c67..888db3c 100644 --- a/lib/browser.tcl +++ b/lib/browser.tcl @@ -3,6 +3,13 @@ class browser { +image create photo ::browser::img_parent -data {R0lGODlhEAAQAIUAAPwCBBxSHBxOHMTSzNzu3KzCtBRGHCSKFIzCjLzSxBQ2FAxGHDzCLCyeHBQ+FHSmfAwuFBxKLDSCNMzizISyjJzOnDSyLAw+FAQSDAQeDBxWJAwmDAQOBKzWrDymNAQaDAQODAwaDDyKTFSyXFTGTEy6TAQCBAQKDAwiFBQyHAwSFAwmHAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAZ1QIBwSCwaj0hiQCBICpcDQsFgGAaIguhhi0gohIsrQEDYMhiNrRfgeAQC5fMCAolIDhD2hFI5WC4YRBkaBxsOE2l/RxsHHA4dHmkfRyAbIQ4iIyQlB5NFGCAACiakpSZEJyinTgAcKSesACorgU4mJ6uxR35BACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=} +image create photo ::browser::img_rblob -data {R0lGODlhEAAQAIUAAPwCBFxaXNze3Ly2rJSWjPz+/Ozq7GxqbJyanPT29HRydMzOzDQyNIyKjERCROTi3Pz69PTy7Pzy7PTu5Ozm3LyqlJyWlJSSjJSOhOzi1LyulPz27PTq3PTm1OzezLyqjIyKhJSKfOzaxPz29OzizLyidIyGdIyCdOTOpLymhOzavOTStMTCtMS+rMS6pMSynMSulLyedAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAaQQIAQECgajcNkQMBkDgKEQFK4LFgLhkMBIVUKroWEYlEgMLxbBKLQUBwc52HgAQ4LBo049atWQyIPA3pEdFcQEhMUFYNVagQWFxgZGoxfYRsTHB0eH5UJCJAYICEinUoPIxIcHCQkIiIllQYEGCEhJicoKYwPmiQeKisrKLFKLCwtLi8wHyUlMYwM0tPUDH5BACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=} +image create photo ::browser::img_xblob -data {R0lGODlhEAAQAIYAAPwCBFRWVFxaXNza3OTi3Nze3Ly2tJyanPz+/Ozq7GxubNzSxMzOzMTGxHRybDQyNLy+vHRydHx6fKSipISChIyKjGxqbERCRCwuLLy6vGRiZExKTCQiJAwKDLSytLy2rJSSlHx+fDw6PKyqrBQWFPTu5Ozm3LyulLS2tCQmJAQCBPTq3Ozi1MSynCwqLAQGBOTazOzizOzezLyqjBweHNzSvOzaxKyurHRuZNzOtLymhDw+PIyCdOzWvOTOpLyidNzKtOTStLyifMTCtMS+rLyedAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAfZgACCAAEChYeGg4oCAwQFjgYBBwGKggEECJkICQoIkwADCwwNDY2mDA4Lng8QDhESsLARExQVDhYXGBkWExIaGw8cHR4SCQQfFQ8eFgUgIQEiwiMSBMYfGB4atwEXDyQd0wQlJicPKAHoFyIpJCoeDgMrLC0YKBsX6i4kL+4OMDEyZijr5oLGNxUqUCioEcPGDAwjPNyI6MEDChQjcOSwsUDHgw07RIgI4KCkAgs8cvTw8eOBogAxQtXIASTISiEuBwUYMoRIixYnZggpUgTDywdIkWJIitRPIAAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7} +image create photo ::browser::img_tree -data {R0lGODlhEAAQAIYAAPwCBAQCBExKTBwWHMzKzOzq7ERCRExGTCwqLARqnAQ+ZHR2dKyqrNTOzHx2fCQiJMTi9NTu9HzC3AxmnAQ+XPTm7Dy67DymzITC3IzG5AxypHRydKymrMzOzOzu7BweHByy9AyGtFyy1IzG3NTu/ARupFRSVByazBR6rAyGvFyuzJTK3MTm9BR+tAxWhHS61MTi7Pz+/IymvCxulBRelAx2rHS63Pz6/PTy9PTu9Nza3ISitBRupFSixNTS1CxqnDQyNMzGzOTi5MTCxMTGxGxubGxqbLy2vLSutGRiZLy6vLSytKyurDQuNFxaXKSipDw6PAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAfDgACCAAECg4eIAAMEBQYHCImDBgkKCwwNBQIBBw4Bhw8QERITFJYEFQUFnoIPFhcYoRkaFBscHR4Ggh8gIRciEiMQJBkltCa6JyUoKSkXKhIrLCQYuQAPLS4TEyUhKb0qLzDVAjEFMjMuNBMoNcw21QY3ODkFOjs82RM1PfDzFRU3fOggcM7Fj2pAgggRokOHDx9DhhAZUqQaISBGhjwMEvEIkiIHEgUAkgSJkiNLmFSMJChAEydPGBSBwvJQgAc0/QQCACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=} +image create photo ::browser::img_symlink -data {R0lGODlhEAAQAIQAAPwCBCwqLLSytLy+vERGRFRWVDQ2NKSmpAQCBKyurMTGxISChJyanHR2dIyKjGxubHRydGRmZIyOjFxeXHx6fAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAVbICACwWieY1CibCCsrBkMb0zchSEcNYskCtqBBzshFkOGQFk0IRqOxqPBODRHCMhCQKteRc9FI/KQWGOIyFYgkDC+gPR4snCcfRGKOIKIgSMQE31+f4OEYCZ+IQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7} +image create photo ::browser::img_unknown -data {R0lGODlhEAAQAIUAAPwCBFxaXIyKjNTW1Nze3LS2tJyanER2RGS+VPz+/PTu5GxqbPz69BQ6BCxeLFSqRPT29HRydMzOzDQyNERmPKSypCRWHIyKhERCRDyGPKz2nESiLBxGHCyCHGxubPz6/PTy7Ozi1Ly2rKSipOzm3LyqlKSWhCRyFOzizLymhNTKtNzOvOzaxOTStPz27OzWvOTOpLSupLyedMS+rMS6pMSulLyqjLymfLyifAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAamQIAQECgajcOkYEBoDgoBQyAJOCCuiENCsWBIh9aGw9F4HCARiXciRDQoBUnlYRlcIgsMG5CxXAgMGhscBRAEBRd7AB0eBBoIgxUfICEiikSPgyMMIAokJZcBkBybJgomIaBJAZoMpyCmqkMBFCcVCrgKKAwpoSorKqchKCwtvasIFBIhLiYvLzDHsxQNMcMKLDAwMqEz3jQ1NTY3ONyrE+jp6hN+QQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7} + field w field browser_commit field browser_path @@ -177,7 +184,7 @@ method _ls {tree_id {name {}}} { $w image create end \ -align center -padx 5 -pady 1 \ -name icon0 \ - -image file_uplevel + -image ::browser::img_parent $w insert end {[Up To Parent]} lappend browser_files parent } @@ -207,14 +214,21 @@ method _read {fd} { switch -- $type { blob { - set image file_mod + scan [lindex $info 0] %o mode + if {$mode == 0120000} { + set image ::browser::img_symlink + } elseif {($mode & 0100) != 0} { + set image ::browser::img_xblob + } else { + set image ::browser::img_rblob + } } tree { - set image file_dir + set image ::browser::img_tree append path / } default { - set image file_question + set image ::browser::img_unknown } } -- cgit v0.10.2-6-g49f6 From 84f67537b13bf0a959b1cad50b0d490071dc921a Mon Sep 17 00:00:00 2001 From: "Shawn O. Pearce" Date: Sun, 29 Jul 2007 20:21:54 -0400 Subject: git-gui: Minor refactoring of merge command line in merge support This is just a small code movement to cleanup how we generate the command line for a merge. I'm only doing it to make the next series of changes slightly more readable. Signed-off-by: Shawn O. Pearce diff --git a/lib/merge.tcl b/lib/merge.tcl index 66d1bcd..5de0d82 100644 --- a/lib/merge.tcl +++ b/lib/merge.tcl @@ -90,9 +90,6 @@ method _start {} { set spec [$w_rev get_tracking_branch] set cmit [$w_rev get_commit] - set cmd [list git] - lappend cmd merge - lappend cmd --strategy=recursive set fh [open [gitdir FETCH_HEAD] w] fconfigure $fh -translation lf @@ -112,6 +109,9 @@ method _start {} { puts $fh "$cmit\t\tbranch '$branch' of $remote" close $fh + set cmd [list git] + lappend cmd merge + lappend cmd --strategy=recursive lappend cmd [git fmt-merge-msg <[gitdir FETCH_HEAD]] lappend cmd HEAD lappend cmd $cmit -- cgit v0.10.2-6-g49f6