122
set _appname {Git Gui}
123
set _gitdir {}
124
set _gitworktree {}
125
+set _isbare {}
126
set _gitexec {}
127
set _githtmldir {}
128
set _reponame {}
278
}
279
}
280
281
+proc is_bare {} {
282
+ global _isbare
283
+ global _gitdir
284
+ global _gitworktree
285
+
286
+ if {$_isbare eq {}} {
287
+ if {[catch {
288
+ set _bare [git rev-parse --is-bare-repository]
289
+ switch -- $_bare {
290
+ true { set _isbare 1 }
291
+ false { set _isbare 0}
292
+ default { throw }
293
+ }
294
+ }]} {
295
+ if {[is_config_true core.bare]
296
+ || ($_gitworktree eq {}
297
+ && [lindex [file split $_gitdir] end] ne {.git})} {
298
+ set _isbare 1
299
+ } else {
300
+ set _isbare 0
301
+ }
302
+ }
303
+ }
304
+ return $_isbare
305
+}
306
+
307
######################################################################
308
##
309
## handy utils
1149
set _gitworktree [pwd]
1150
unset cdup
1151
} elseif {![is_enabled bare]} {
1125
- if {[lindex [file split $_gitdir] end] ne {.git}} {
1152
+ if {[is_bare]} {
1153
catch {wm withdraw .}
1127
- error_popup [strcat [mc "Cannot use funny .git directory:"] "\n\n$_gitdir"]
1154
+ error_popup [strcat [mc "Cannot use bare repository:"] "\n\n$_gitdir"]
1155
exit 1
1156
}
1157
if {$_gitworktree eq {}} {
2000
set pwd [pwd]
2001
2002
if {!$is_submodule} {
1976
- if {$_gitworktree ne {}} {
2003
+ if {![is_bare]} {
2004
cd $_gitworktree
2005
}
2006
set env(GIT_DIR) [file normalize [gitdir]]
2484
#
2485
menu .mbar.repository
2486
2460
-.mbar.repository add command \
2461
- -label [mc "Explore Working Copy"] \
2462
- -command {do_explore}
2463
-.mbar.repository add separator
2487
+if {![is_bare]} {
2488
+ .mbar.repository add command \
2489
+ -label [mc "Explore Working Copy"] \
2490
+ -command {do_explore}
2491
+ .mbar.repository add separator
2492
+}
2493
2494
.mbar.repository add command \
2495
-label [mc "Browse Current Branch's Files"] \