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

Re: [QUESTION] How to add new configuration variable

From
Junio C Hamano <gitster@pobox.com>
Date
Sep 17, 2021, 20:02 UTC
Message-ID
<xmqqilyzgecx.fsf@gitster.g>
In-Reply-To
<YUSyNqd51euzvt8N@danh.dev>
Đoàn Trần Công Danh  <congdanhqx@gmail.com> writes:
Show 19 quoted lines
> On 2021-09-17 09:43:18-0400, Konstantin Ryabitsev <konstantin@linuxfoundation.org> wrote:
>> On Fri, Sep 17, 2021 at 05:44:42PM +0700, Bagas Sanjaya wrote:
>> > Supposed that I'm writing git-foobar script ("git-foobar.sh"), which takes
>> > configuration variable "foobar.something" (string type).
>> > 
>> > How can I add that configuration variable so that it can be used by the
>> > script?
>> 
>> You can just add it. :) Git doesn't complain when it finds configuration
>> parameters it doesn't know anything about, it just ignores them.
>> 
>> E.g. in your .gitconfig or individual repository .git/config:
>> 
>>     [foobar]
>>         something = yourvalue
>
> Or just:
>
> 	git config [--global] foobar.something yourvalue

In addition to that, unless it is a script for your throw-away use that we do not have to worry about, consider if the users of "git foobar" needs to override a configured value with --no-something or --something=anothervalue from the command line, and if so, make sure these command line options are available to them.

Previous: Đoàn Trần Công DanhNext: Carlo Arenas
Message 4 of 5 in “[QUESTION] How to add new configuration variable”
  1. Bagas SanjayaSep 17, 2021
  2. Konstantin RyabitsevSep 17, 2021
  3. Đoàn Trần Công DanhSep 17, 2021
  4. Junio C HamanoSep 17, 2021
  5. Carlo ArenasSep 17, 2021

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.