@matheusbsbs / matheus-bagliano / commits / 16d18b853b
Fork 0

git-gui: Refactor reponame computation.

We use reponame in a number of locations, and every time its always the same value. Instead of computing this multiple times with code that was copied and pasted around we can compute it once immediately after the global gitdir has been computed and set. Signed-off-by: Shawn O. Pearce <spearce@spearce.org>

Shawn O. Pearce committed Jan 20, 2007 at 21:36 UTC 16d18b853b91e66219a26130c0485914c2969389
1 file changed +7 -19
git-gui.sh
+7 -19
@@ -239,6 +239,9 @@ if {[catch {cd [file dirname $gitdir]} err]} {
239 error_popup "No working directory [file dirname $gitdir]:\n\n$err"
240 exit 1
241 }
242 +set reponame [lindex [file split \
243 + [file normalize [file dirname $gitdir]]] \
244 + end]
245
246 set single_commit 0
247 if {$appname eq {git-citool}} {
@@ -2417,7 +2420,7 @@ proc do_include_all {} {
2420 }
2421
2422 proc revert_helper {txt paths} {
2420 - global gitdir appname
2423 + global gitdir appname reponame
2424 global file_states current_diff
2425
2426 if {![lock_index begin-update]} return
@@ -2450,10 +2453,6 @@ proc revert_helper {txt paths} {
2453 set s "these $n files"
2454 }
2455
2453 - set reponame [lindex [file split \
2454 - [file normalize [file dirname $gitdir]]] \
2455 - end]
2456 -
2456 set reply [tk_dialog \
2457 .confirm_revert \
2458 "$appname ($reponame)" \
@@ -2599,7 +2598,7 @@ $copyright" \
2598 }
2599
2600 proc do_options {} {
2602 - global appname gitdir font_descs
2601 + global appname gitdir reponame font_descs
2602 global repo_config global_config
2603 global repo_config_new global_config_new
2604
@@ -2618,9 +2617,6 @@ proc do_options {} {
2617 foreach name [array names global_config] {
2618 set global_config_new($name) $global_config($name)
2619 }
2621 - set reponame [lindex [file split \
2622 - [file normalize [file dirname $gitdir]]] \
2623 - end]
2620
2621 set w .options_editor
2622 toplevel $w
@@ -2756,11 +2752,7 @@ proc do_save_config {w} {
2752 }
2753
2754 proc do_windows_shortcut {} {
2759 - global gitdir appname argv0
2760 -
2761 - set reponame [lindex [file split \
2762 - [file normalize [file dirname $gitdir]]] \
2763 - end]
2755 + global gitdir appname reponame argv0
2756
2757 if {[catch {
2758 set desktop [exec cygpath \
@@ -2806,11 +2798,7 @@ proc do_windows_shortcut {} {
2798 }
2799
2800 proc do_macosx_app {} {
2809 - global gitdir appname argv0 env
2810 -
2811 - set reponame [lindex [file split \
2812 - [file normalize [file dirname $gitdir]]] \
2813 - end]
2801 + global gitdir appname reponame argv0 env
2802
2803 set fn [tk_getSaveFile \
2804 -parent . \