threads / discuss / 56521

[QUESTION] How to add new configuration variable

Subject: [QUESTION] How to add new configuration variable

## tl;dr

5 messages between Sep 17, 2021 and Sep 17, 2021.

replies: 4people: 5as markdown or json

Bagas Sanjaya· Sep 17, 2021, 10:44 UTC · lore
Hi,

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?

-- 
An old man doll... just what I always wanted! - Clara
Konstantin Ryabitsev· Sep 17, 2021, 13:43 UTC · re: Bagas Sanjaya · lore

Re: [QUESTION] How to add new configuration variable

On Fri, Sep 17, 2021 at 05:44:42PM +0700, Bagas Sanjaya wrote:
Show 5 quoted lines
> 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
-K
Đoàn Trần Công Danh· Sep 17, 2021, 15:20 UTC · re: Konstantin Ryabitsev · lore

Re: [QUESTION] How to add new configuration variable

On 2021-09-17 09:43:18-0400, Konstantin Ryabitsev <konstantin@linuxfoundation.org> wrote:
Show 14 quoted lines
> 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
-- 
Danh
Junio C Hamano· Sep 17, 2021, 20:02 UTC · re: Đoàn Trần Công Danh · lore

Re: [QUESTION] How to add new configuration variable

Đ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.

Carlo Arenas· Sep 17, 2021, 16:21 UTC · re: Bagas Sanjaya · lore

Re: [QUESTION] How to add new configuration variable

you might want this in --global instead, but assuming it is ok to be repository specific:

$ git config foobar.something baz
and in your script
  baz=$(git config foobar.something)
Carlo

← back to recent threads