# 'git maintenance' won't work on bare repos

4 messages from 2021-02-23 to 2021-02-23. Participants: Clement Moyroud, Eric Sunshine.
Thread: https://gitlist.dev/t/55189

## Clement Moyroud, 2021-02-23 02:01

Subject: 'git maintenance' won't work on bare repos
Message-ID: <CABXAcUzRhkeQhVtwtx-NBR0hbkoo=aCTwN464Dsj8680GPMDxw@mail.gmail.com>
URL: https://gitlist.dev/e/CABXAcUzRhkeQhVtwtx-NBR0hbkoo%3DaCTwN464Dsj8680GPMDxw%40mail.gmail.com

```
Hello,

Because we have a fairly large repository, our developers rely on
worktrees created off a bare mirror clone. I'd like to enable
maintenance, and since the worktrees are rather short-lived instances,
we cannot point 'git maintenance' to it.
So the proper solution is to do it from the bare clone itself.
However, 'git maintenance register' silently fails (with an 0 exit
code). There are two tell-tale signs:
1. 'git config --global --get maintenance.repo' returns '.'
2. There are no Crontab entries inserted.

Running 'git maintenance register' from a worktree created off the
bare clone works as expected.

To reproduce:
git init --bare test-me
git -C test-me maintenance register
git config --global --get maintenance.repo

The workaround, for now, is to run this from a worktree, then use 'git
config' to reset to the corresponding bare clone location.

Thanks,

Clément

```

## Eric Sunshine, 2021-02-23 05:03

Subject: Re: 'git maintenance' won't work on bare repos
Message-ID: <CAPig+cSvYLMtML5ya4GR30-nfNNt19okLjchkkdhdzAEB19H4g@mail.gmail.com>
URL: https://gitlist.dev/e/CAPig%2BcSvYLMtML5ya4GR30-nfNNt19okLjchkkdhdzAEB19H4g%40mail.gmail.com
In-Reply-To: <CABXAcUzRhkeQhVtwtx-NBR0hbkoo=aCTwN464Dsj8680GPMDxw@mail.gmail.com>

```
On Mon, Feb 22, 2021 at 9:02 PM Clement Moyroud
<clement.moyroud@gmail.com> wrote:
> So the proper solution is to do it from the bare clone itself.
> However, 'git maintenance register' silently fails (with an 0 exit
> code). There are two tell-tale signs:
> 1. 'git config --global --get maintenance.repo' returns '.'
> 2. There are no Crontab entries inserted.

I can confirm that problem 1 is a bug. However, I am unable to
reproduce problem 2.

Note that the crontab entry won't be created until you run `git
maintenance start`. Is it possible that you are forgetting that step?
(Be aware that `git maintenance start` will show a misleading "no
crontab for <user>" message if you don't already have a crontab file,
but the crontab entry will be created nevertheless, as evidenced by
`crontab -l`.)

> To reproduce:
> git init --bare test-me
> git -C test-me maintenance register
> git config --global --get maintenance.repo

I have a patch which fixes the problem with the bare repo path being
incorrectly registered as ".", but I still need to create a regression
test for it.

```

## Eric Sunshine, 2021-02-23 07:36

Subject: Re: 'git maintenance' won't work on bare repos
Message-ID: <CAPig+cTGe1=uqLw1Hxe+5=0WyWEJCOaqHEqLkuYmgR1pG+xVOA@mail.gmail.com>
URL: https://gitlist.dev/e/CAPig%2BcTGe1%3DuqLw1Hxe%2B5%3D0WyWEJCOaqHEqLkuYmgR1pG%2BxVOA%40mail.gmail.com
In-Reply-To: <CAPig+cSvYLMtML5ya4GR30-nfNNt19okLjchkkdhdzAEB19H4g@mail.gmail.com>

```
On Tue, Feb 23, 2021 at 12:03 AM Eric Sunshine <sunshine@sunshineco.com> wrote:
> On Mon, Feb 22, 2021 at 9:02 PM Clement Moyroud
> <clement.moyroud@gmail.com> wrote:
> > So the proper solution is to do it from the bare clone itself.
> > However, 'git maintenance register' silently fails (with an 0 exit
> > code). There are two tell-tale signs:
> > 1. 'git config --global --get maintenance.repo' returns '.'
>
> I have a patch which fixes the problem with the bare repo path being
> incorrectly registered as ".", but I still need to create a regression
> test for it.

Patch posted here:
https://lore.kernel.org/git/20210223073107.40675-1-sunshine@sunshineco.com/

```

## Clement Moyroud, 2021-02-23 15:31

Subject: Re: 'git maintenance' won't work on bare repos
Message-ID: <CABXAcUwdpJa1osz=9xarVgbP9wFK82rbx8J1vk-EZEA5x25ffQ@mail.gmail.com>
URL: https://gitlist.dev/e/CABXAcUwdpJa1osz%3D9xarVgbP9wFK82rbx8J1vk-EZEA5x25ffQ%40mail.gmail.com
In-Reply-To: <CAPig+cSvYLMtML5ya4GR30-nfNNt19okLjchkkdhdzAEB19H4g@mail.gmail.com>

```
On Mon, Feb 22, 2021 at 9:03 PM Eric Sunshine <sunshine@sunshineco.com> wrote:
> > 1. 'git config --global --get maintenance.repo' returns '.'
> > 2. There are no Crontab entries inserted.
>
> I can confirm that problem 1 is a bug. However, I am unable to
> reproduce problem 2.
>
> Note that the crontab entry won't be created until you run `git
> maintenance start`. Is it possible that you are forgetting that step?
> (Be aware that `git maintenance start` will show a misleading "no
> crontab for <user>" message if you don't already have a crontab file,
> but the crontab entry will be created nevertheless, as evidenced by
> `crontab -l`.)
>

My bad. I misread the manpage, and didn't try to run 'git maintenance start'
on the bare repo, since the first step did not look right.

> I have a patch which fixes the problem with the bare repo path being
> incorrectly registered as ".", but I still need to create a regression
> test for it.

I saw the patch, thanks for the quick fix!

```
