Re: [PATCHv2 2/2] git-gui: handle bare repos correctly
- From
Giuseppe Bilotta <giuseppe.bilotta@gmail.com>
- Date
- Feb 20, 2009, 00:34 UTC
- Message-ID
- <cb7bb73a0902191634n30f97c24t4d1840f5660c3eb3@mail.gmail.com>
- In-Reply-To
- <alpine.DEB.1.00.0902190322470.10279@pacific.mpi-cbg.de>
On Thu, Feb 19, 2009 at 3:25 AM, Johannes Schindelin <Johannes.Schindelin@gmx.de> wrote:
Show 21 quoted lines
> Hi,
>
>>
>> +proc is_bare {} {
>> + global _isbare
>> + global _gitdir
>> + global _gitworktree
>> +
>> + if {$_isbare eq {}} {
>> + if {[is_config_true core.bare]
>> + || ($_gitworktree eq {}
>> + && [lindex [file split $_gitdir] end] ne {.git})} {
>> + set _isbare 1
>> + } else {
>> + set _isbare 0
>> + }
>> + }
>> + return $_isbare
>> +}
>
> git rev-parse --is-bare-repository anyone?As mentioned elsewhere, git-gui is supposed to be backwards compatible with git 1.5.0; --is-bare-repository was introduced in 1.5.2. What I can do is try that and fall back to this other implementation otherwise.
Show 8 quoted lines
>> @@ -1913,7 +1931,7 @@ proc do_gitk {revs} {
>> }
>>
>> set pwd [pwd]
>> - if { $_gitworktree ne {} } {
>> + if { ![is_bare] } {
>
> Why is this change needed at all?Because the worktree being undefined in non-bare repositories is an error and should raise consequently.
Show 16 quoted lines
>> @@ -2317,10 +2335,12 @@ if {[is_enabled multicommit] || [is_enabled singlecommit]} {
>> #
>> menu .mbar.repository
>>
>> -.mbar.repository add command \
>> - -label [mc "Explore Working Copy"] \
>> - -command {do_explore}
>> -.mbar.repository add separator
>> +if {![is_bare]} {
>> + .mbar.repository add command \
>> + -label [mc "Explore Working Copy"] \
>> + -command {do_explore}
>> + .mbar.repository add separator
>> +}
>
> How did you make sure that there are no more places?I looked at the code and tested it.
> (I, for one, would expect the standard mode of staging to fail in a bare > repository.)
That's the reason why the only thing you can do in bare repositories is git gui blame.
-- Giuseppe "Oblomov" Bilotta