git/list[1] front-page[2] threads[3] people[4] search[5] about
 

RFC GSoC idea: new "git config" features

From
Michael Haggerty <mhagger@alum.mit.edu>
Date
Feb 28, 2014, 12:51 UTC
Message-ID
<53108650.2020708@alum.mit.edu>

I just wrote up another double-idea that has been stewing in my head for a while:

* Allow configuration values to be unset via a config file
* Fix "git config --unset" to clean up detritus from sections that are
left empty.

These ideas are more "out there" than the last, and might be too controversial to be implemented, let alone as a GSoC project. I'd definitely like some feedback.

And if you like this idea or the other one I proposed, please volunteer to be a co-mentor! I will be traveling for a few weeks this summer, so I *won't* be able to be the sole mentor to a student.

I wrote up this idea in the following pull request:
    https://github.com/git/git.github.io/pull/6
I will also append the text, for your mailing-list-reading convenience.
Michael
### `git config` improvements

This project proposes the following two improvements to `git config`. Please note that this project has a significant "political" component to it, because some of the details of the features will be controversial.

#### Unsetting configuration options

Some Git configuration options have an effect by their mere existence. (I.e., setting the option to "false" or the empty string is different than leaving it unset altogether.) Also, some configuration options can take multiple values.

However, there is no way for an option file to "unset" an option--that is, to change the option back to "unset". This is awkward, because configuration values are read from various places (`/etc/gitconfig`, `~/.config/git/config` or `~/.gitconfig`, and `$GIT_DIR/config`, plus perhaps files that are included by other configuration files). Therefore, if an option is set in one of the earlier files, there is no way for it to be unset in a later one. The unwanted option might have even been set in a file like `/etc/gitconfig` that the user doesn't have permission to modify.

It would be nice to have a syntax that can be used to unset any previously-defined values for an option. Perhaps

    [section "subsection"]
            !option

The above is currently currently a syntax error that causes Git to terminate, so some thought has to go into a transition plan for enabling this feature. Maybe a syntax has to be invented that conforms to the current format, like

    [unset]
            name = section.subsection.option

Because options are currently processed as they are read, this change will require the code that reads options files to be changed significantly.

Leave yourself a lot of time to attain a consensus on the mailing list about how this can be done while retaining reasonable backwards compatibility.

#### Tidy configuration files

When a configuration file is repeatedly modified, often garbage is left behind. For example, after

    git config my.option true
    git config --unset my.option
    git config my.option true
    git config --unset my.option
the bottom of the configuration file is left with the useless lines
    [my]
    [my]

It would be nice to clean up such garbage when rewriting the configuration file. This project is a bit tricky because of the possible presence of comments. For example, what if an empty section looks like this:

    [my]
            # This section is for my own private settings
or this:
    [my]
    # This section is for my own private settings
or this:
    # This section is for my own private settings:
    [my]

? In some such cases it might be desireable either to retain the section even though it is empty, or to delete the comment along with the section. Very likely there will be some obvious patterns when everybody agrees that an empty section can be deleted, and other, more controversial cases where you will have to reach a consensus on the mailing list about what should be done.

 - Language: C
 - Difficulty: medium
 - Possible mentors: Michael Haggerty
-- 
Michael Haggerty
mhagger@alum.mit.edu
http://softwareswirl.blogspot.com/
Next: Junio C Hamano
Message 1 of 8 in “RFC GSoC idea: new "git config" features”
  1. Michael HaggertyFeb 28, 2014
  2. Junio C HamanoFeb 28, 2014
  3. Michael HaggertyMar 1, 2014
  4. Jeff KingMar 1, 2014
  5. Matthieu MoyMar 1, 2014
  6. Jeff KingMar 14, 2014
  7. Junio C HamanoMar 14, 2014
  8. Junio C HamanoMar 3, 2014

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.