# "git maintenance start" adds entry to the main config file, not to already existing maintenance section in included file

2 messages from 2024-03-10 to 2024-04-02. Participants: Jan Katins, Phillip Wood.
Thread: https://gitlist.dev/t/61082

## Jan Katins, 2024-03-10 13:12

Subject: "git maintenance start" adds entry to the main config file, not to already existing maintenance section in included file
Message-ID: <CAP+2wOWvb8Xy5Q_u26FhZrVHazBG0ZCoKnzR8LUKo51f-NXndA@mail.gmail.com>
URL: https://gitlist.dev/e/CAP%2B2wOWvb8Xy5Q_u26FhZrVHazBG0ZCoKnzR8LUKo51f-NXndA%40mail.gmail.com

```
Hello!

What did you do before the bug happened? (Steps to reproduce your issue)

I've a git config (in ~/.config/git/config) which reads:

ˋˋˋini
...
[include]
    path = git_config_local_maintenance
....
ˋˋˋ

In ~/.config/git/git_config_local_maintenance I have:

ˋˋˋini
[maintenance]
    repo =/User/jankatins/projects/whatever
ˋˋˋ

ran `git maintenance start` in a new repo.

What did you expect to happen? (Expected behavior)

That the new repo gets appended in
~/.config/git/git_config_local_maintenance to the already existing
maintenance section.

What happened instead? (Actual behavior)

An additional maintenance section was added in the main config file
with the repo key added there.

What's different between what you expected and what actually happened?

The additional maintenance section in the main config file instead of
appending the repo in the already existing section in the included
file.

This is "undesired", as I have my main git config file in a dotfile
manager, but don't want to have the (much more frequently changing and
laptop specific) maintenance entries in the dotfile repo.

ˋˋˋ
[System Info]
git version: git version 2.44.0
cpu: x86_64
sizeof-long: 8
sizeof-size_t: 8
shell-path: /bin/sh
feature: fsmonitor--daemon
uname: Darwin 23.4.0 Darwin Kernel Version 23.4.0: Wed Feb 21 21:44:31
PST 2024; root:xnu-10063.101.15~2/RELEASE_X86_64 x86_64
compiler info: clang: 15.0.0 (clang-1500.1.0.2.5)
libc info: no libc information available
$SHELL (typically, interactive shell): /usr/local/bin/zsh
ˋˋˋ

Kind regards

Jan
--
jasc@gmx.net

```

## Phillip Wood, 2024-04-02 15:27

Subject: Re: "git maintenance start" adds entry to the main config file, not to already existing maintenance section in included file
Message-ID: <460e41d1-0680-4e23-93a7-5134b48eedd0@gmail.com>
URL: https://gitlist.dev/e/460e41d1-0680-4e23-93a7-5134b48eedd0%40gmail.com
In-Reply-To: <CAP+2wOWvb8Xy5Q_u26FhZrVHazBG0ZCoKnzR8LUKo51f-NXndA@mail.gmail.com>

```
Hi Jan

Sorry for the slow response, unfortunately the main contributor to "git 
maintenance" changed jobs last year.

On 10/03/2024 13:12, Jan Katins wrote:
> Hello!
> 
> What did you do before the bug happened? (Steps to reproduce your issue)
> 
> I've a git config (in ~/.config/git/config) which reads:
> 
> ˋˋˋini
> ...
> [include]
>      path = git_config_local_maintenance
> ....
> ˋˋˋ
> 
> In ~/.config/git/git_config_local_maintenance I have:
> 
> ˋˋˋini
> [maintenance]
>      repo =/User/jankatins/projects/whatever
> ˋˋˋ
> 
> ran `git maintenance start` in a new repo.
> 
> What did you expect to happen? (Expected behavior)
> 
> That the new repo gets appended in
> ~/.config/git/git_config_local_maintenance to the already existing
> maintenance section.
> 
> What happened instead? (Actual behavior)
> 
> An additional maintenance section was added in the main config file
> with the repo key added there.

"git maintenance start" always uses the user's global config file, "git 
maintenance register" has a "--config-file" option which would allow you 
to use a separate file which we should add to "git maintenance start". 
"git maintenance" is a bit of a special case as it must use the global 
config file so that "git maintenance run" can find the list of 
repositories no matter which directory it is started in. Having said 
that I'm not sure what guarantees the config system normally makes when 
adding a new key to a existing config section.

I can see this frustrating, I'd recommend using "git maintenance 
register --config-file" when adding new repositories - you only need to 
run "git maintenance start" once to enable maintenance, not for each new 
repository.

Best Wishes

Phillip

> What's different between what you expected and what actually happened?
> 
> The additional maintenance section in the main config file instead of
> appending the repo in the already existing section in the included
> file.
> 
> This is "undesired", as I have my main git config file in a dotfile
> manager, but don't want to have the (much more frequently changing and
> laptop specific) maintenance entries in the dotfile repo.
> 
> ˋˋˋ
> [System Info]
> git version: git version 2.44.0
> cpu: x86_64
> sizeof-long: 8
> sizeof-size_t: 8
> shell-path: /bin/sh
> feature: fsmonitor--daemon
> uname: Darwin 23.4.0 Darwin Kernel Version 23.4.0: Wed Feb 21 21:44:31
> PST 2024; root:xnu-10063.101.15~2/RELEASE_X86_64 x86_64
> compiler info: clang: 15.0.0 (clang-1500.1.0.2.5)
> libc info: no libc information available
> $SHELL (typically, interactive shell): /usr/local/bin/zsh
> ˋˋˋ
> 
> Kind regards
> 
> Jan
> --
> jasc@gmx.net
> 

```
