1125
##
1126
## repository setup
1127
1128
+proc set_gitdir_vars {} {
1129
+ global _gitdir _gitworktree env
1130
+ set env(GIT_DIR) $_gitdir
1131
+ if {$_gitworktree ne {}} {
1132
+ set env(GIT_WORK_TREE) $_gitworktree
1133
+ }
1134
+}
1135
+
1136
+proc unset_gitdir_vars {} {
1137
+ global env
1138
+ catch {unset env(GIT_DIR)}
1139
+ catch {unset env(GIT_WORK_TREE)}
1140
+}
1141
+
1142
set picked 0
1143
if {[catch {
1144
set _gitdir $env(GIT_DIR)
1224
set _reponame [lindex $_reponame end]
1225
}
1226
1213
-set env(GIT_DIR) $_gitdir
1214
-set env(GIT_WORK_TREE) $_gitworktree
1227
+# Export the final paths
1228
+set_gitdir_vars
1229
1230
######################################################################
1231
##
2024
2025
proc do_gitk {revs {is_submodule false}} {
2026
global current_diff_path file_states current_diff_side ui_index
2013
- global _gitdir _gitworktree
2027
2028
# -- Always start gitk through whatever we were loaded with. This
2029
# lets us bypass using shell process on Windows systems.
2033
if {$exe eq {}} {
2034
error_popup [mc "Couldn't find gitk in PATH"]
2035
} else {
2023
- global env
2024
-
2036
set pwd [pwd]
2037
2038
if {$is_submodule} {
2060
# TODO we could make life easier (start up faster?) for gitk
2061
# by setting these to the appropriate values to allow gitk
2062
# to skip the heuristics to find their proper value
2052
- unset env(GIT_DIR)
2053
- unset env(GIT_WORK_TREE)
2063
+ unset_gitdir_vars
2064
}
2065
safe_exec_bg [concat $cmd $revs "--" "--"]
2066
2057
- set env(GIT_DIR) $_gitdir
2058
- set env(GIT_WORK_TREE) $_gitworktree
2067
+ set_gitdir_vars
2068
cd $pwd
2069
2070
if {[info exists main_status]} {
2087
if {$exe eq {}} {
2088
error_popup [mc "Couldn't find git gui in PATH"]
2089
} else {
2081
- global env
2082
- global _gitdir _gitworktree
2083
-
2090
# see note in do_gitk about unsetting these vars when
2091
# running tools in a submodule
2086
- unset env(GIT_DIR)
2087
- unset env(GIT_WORK_TREE)
2092
+ unset_gitdir_vars
2093
2094
set pwd [pwd]
2095
cd $current_diff_path
2096
2097
safe_exec_bg [concat $exe gui]
2098
2094
- set env(GIT_DIR) $_gitdir
2095
- set env(GIT_WORK_TREE) $_gitworktree
2099
+ set_gitdir_vars
2100
cd $pwd
2101
2102
set status_operation [$::main_status \