--- title: 'cgit: Idle has no value' description: 'How to populate the idle column in cgit if you dont have a default setup' date: '2024-10-24T16:00:00+02:00' tags: ['cgit', 'git'] --- I decided to brush-up on my cgit setup today and I realized that the 'idle' column had no data for non of my repositories. There's a reason for this that might not be obvious for many people. By default cgit is hard-coded to look at the "master" branch for determining idle time. The reason for this is that this was conventionally the name of the main branch. After the some controversies in mid 2020, Github (and a bunch of others) changed the default main branch name from "master" to "main"[[1]](#reference-1). In order to tell cgit that we want to use "main" instead, we can either use a repository specific cgitrc file or use the git config file that comes with our repository. Both of these options require you to set `scan-path` in your `/etc/cgitrc` file. If we search in `man cgitrc`, this is what it tells us: ``` enable-git-config Flag which, when set to "1", will allow cgit to use git config to set any repo specific settings. This option is used in conjunction with "scan-path", and must be defined prior, to augment repo-specific settings. The keys gitweb.owner, gitweb.category, gitweb.description, and gitweb.homepage will map to the cgit keys repo.owner, repo.section, repo.desc, and repo.homepage respectively. All git config keys that begin with "cgit." will be mapped to the corresponding "repo." key in cgit. Default value: "0". See also: scan-path, section-from-path. ... REPOSITORY-SPECIFIC CGITRC FILE When the option "scan-path" is used to auto-discover git repositories, cgit will try to parse the file "cgitrc" within any found repository. Such a repo-specific config file may contain any of the repo-specific options described above, except "repo.url" and "repo.path". Additionally, the "filter" options are only acknowledged in repo-specific config files when "enable-filter-overrides" is set to "1". Note: the "repo." prefix is dropped from the option names in repo-specific config files, e.g. "repo.desc" becomes "desc". ``` So let's tell cgit to use "main" as our default branch, instead of the hard-coded "master". First we need to make sure that `scan-path` is set correctly in our `/etc/cgitrc`. I have all my repositories in `/var/www/git` and so my config looks like this: ```conf # ... scan-path=/var/www/git/ ``` Then we can either use an `cgitrc` file or the `config` file that is generated by git. I myself use the `config` file generated by git, because it's already there. One less file to remember when setting up a new repository. But I will show you both examples. ```plaintext # /path/to/repo/cgitrc defbranch = main ``` or (my prefered way) ```plaintext # /path/to/repo/config # ... [cgit] defbranch = main ``` You can of course change "main" to whatever you call your default branch. ## References {{< rawhtml >}}
{{< /rawhtml >}}