Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a programmatic method to find if a git config variable uses multiple values or only a single value?

Tags:

git

git-config

So far as I've observed, when multiple values are specified to a git config variable in one scope or in multiple scopes, the variable falls into one of the two groups. One uses the last value and the other uses all the values.

git config --system user.name foo
git config --global user.name bar

git commit uses bar as the committer name. The global user.name overwrites the system-wide one.

git config --global remote.origin.fetch +refs/heads/*:refs/remotes/origin/*
git config --local remote.origin.fetch +refs/heads/*:refs/remotes/origin2/*

git fetch origin foo updates/creates both refs/remotes/origin/foo and refs/remotes/origin2/foo. Both the global and the local values are used.

For a random config variable, is there a programmatic method to find into which group it falls?

To be more clear, I look for a method to find if the value of the highest precedence takes effect or all of the multiple values take effect.

like image 681
ElpieKay Avatar asked Oct 29 '25 10:10

ElpieKay


1 Answers

This is not possible.

It is not even the case that the category is fixed for a given variable. For example, given the global and local settings as in your post, the output of

git config --get-all user.name

is

foo
bar

i.e., it is treated as multi-valued variable even though it is treated as single-value when git commit uses it.

It depends on every case where the variable is used whether it is single-valued or multi-valued. UTSL.

like image 173
j6t Avatar answered Oct 31 '25 00:10

j6t



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!