@matheusbsbs / matheus-bagliano / commits / 0d4f3eb5f3
Fork 0

git-gui: Cache all repo-config data in an array.

We're likely going to need key/value pairs from the repo-config beyond just remote.*.url, so cache them all up front into a Tcl array where we have fast access to them without needing to refork a repo-config --list process. Signed-off-by: Shawn O. Pearce <spearce@spearce.org>

Shawn O. Pearce committed Nov 7, 2006 at 04:26 UTC 0d4f3eb5f330a53300e630c1ffe4ea1fa61f5dd9
1 file changed +19 -5
git-gui
+19 -5
@@ -791,8 +791,23 @@ proc toggle_mode {path} {
791 ##
792 ## config (fetch push pull)
793
794 +proc load_repo_config {} {
795 + global repo_config
796 +
797 + array unset repo_config
798 + catch {
799 + set fd_rc [open "| git repo-config --list" r]
800 + while {[gets $fd_rc line] >= 0} {
801 + if {[regexp {^([^=]+)=(.*)$} $line line name value]} {
802 + lappend repo_config($name) $value
803 + }
804 + }
805 + close $fd_rc
806 + }
807 +}
808 +
809 proc load_all_remotes {} {
795 - global gitdir all_remotes
810 + global gitdir all_remotes repo_config
811
812 set all_remotes [list]
813 set rm_dir [file join $gitdir remotes]
@@ -804,13 +819,11 @@ proc load_all_remotes {} {
819 -directory $rm_dir *]]
820 }
821
807 - set fd_rc [open "| git repo-config --list" r]
808 - while {[gets $fd_rc line] >= 0} {
809 - if {[regexp ^remote\.(.*)\.url= $line line name]} {
822 + foreach line [array names repo_config remote.*.url] {
823 + if {[regexp ^remote\.(.*)\.url\$ $line line name]} {
824 lappend all_remotes $name
825 }
826 }
813 - close $fd_rc
827
828 set all_remotes [lsort -unique $all_remotes]
829 }
@@ -1541,6 +1554,7 @@ if {$appname == {git-citool}} {
1554
1555 wm title . "$appname ([file normalize [file dirname $gitdir]])"
1556 focus -force $ui_comm
1557 +load_repo_config
1558 load_all_remotes
1559 populate_remote_menu .mbar.fetch From fetch_from
1560 populate_remote_menu .mbar.push To push_to