git config:列出所有变量及其默认值 [英] git config: list all variables and their default values

查看:108
本文介绍了git config:列出所有变量及其默认值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

与MySQL show变量命令类似,它显示所有变量,而不仅仅是 my.ini 中定义的变量。 ,我希望看到 git 中的所有配置变量以及的默认值列表,而不仅仅是那些在我的〜/ .gitconfig 中定义的。



这是可能的吗?

解决方案

=http://git.661346.n2.nabble.com/Why-does-quot-git-config-quot-output-nothing-instead-of-the-default-value-for-unset-variables-td7582632。 塞巴斯蒂安·舒伯斯 href =noreferrer> ) =https://github.com/peff =noreferrer> Jeff King( Peff )添加:


预期的输出肯定是一个问题,但问题在于比
更基本: git config 甚至不知道任何给定选项的默认
是什么。



假设调用者知道如何处理未设定的价值。而
这与 git config 无关;内部C代码以相同的方式运行


实际的默认值甚至不一定通过配置来表示

例如,我知道 http.receivepack 认为未设置
不同于 true false ,但设置它只能产生后面两个值中的


我确定也有其他值(我刚刚发生本周注意到这一点)。


例如: gc.prune


我可以当然如果代码中有一个大的选项表和它们的描述表,可能的
值和默认值,并且如果我们用它来生成文档为
以及验证输入。

但是没有人花费麻烦来构建该表并转换所有的调用者。正如 Jakub(JakubNarębski)所提到的那样,这样一个中心表对于外部程序无能为力将它们的配置与git一起存储。

总之:


git config 甚至不知道它管理的任何选项或值,
,但只是写入/读取任何您传递的任何笨前端$ b $从/到一个文件。






注意:git config是在 commit 1771299(git 0.99.9a,2005年10月)


不同的程序可以对不同的配置选项作出反应,尽管它们
应该总是回退到在它们无法识别的任何config
选项名称上调用git_default_config()。


因此,在内部,有一种方法可以加载默认配置,最近用作 commit 72549df,git 2.2.0-rc1,2014年11月,通过相同的Peff:

< blockquote>

当我们启动git-fetch程序时,我们调用git_config加载所有配置,但我们的回调只处理 fetch.prune 选项;我们根本不链接到 git_default_config



这意味着我们可能不会加载一些核心配置,效果。例如,我们不加载 core.logAllRefUpdates ,这会影响我们是否在裸仓库中创建reflog。



<我们只是在获取开始时加载核心配置,所以我们知道我们有它

查看另一个带有提交3e1dd17,git 1.7.7-rc1,2011年8月与默认颜色配置。


Similar to the MySQL show variables command that shows all variables and not just the ones defined in my.ini, I would like to see a list of all config variables in git along with their default values, and not just those defined in my ~/.gitconfig.

Is this possible?

解决方案

That was debated in this thread in 2013, requested by Sebastian Schuberth, Jeff King (Peff) adding:

The expected output is certainly a problem, but the issue is more fundamental than that: git config does not even know what the default is for any given option.

It is assumed that the caller knows what to do with an unset value. And this is nothing to do with git config; the internal C code works the same way.
The actual defaults are not even necessarily expressible through the config.
E.g., I know that http.receivepack considers "unset" to be distinct either "true" or "false", but setting it can yield only one of those latter two values.
I'm sure there are others, too (I just happened to notice that one this week).

(For instance: gc.prune)

I could certainly see an argument that the world would be a better place if the code had a big table of options and their descriptions, possible values, and defaults, and if we used that to generate documentation as well as validate input.
But nobody has gone to the trouble to construct that table and convert all of the callers. And as Jakub (Jakub Narębski) mentioned, such a central table can do nothing for external programs that store their config alongside git's.

In short:

git config does not even know any of the options or values it manages, but just is a "dumb" front-end to writing / reading whatever you pass it to / from a file.


Note: git config was introduced in commit 1771299 (git 0.99.9a, Oct. 2005)

Different programs can react to different config options, although they should always fall back to calling "git_default_config()" on any config option name that they don't recognize.

So internally, there is a way to load default config, used as recently as commit 72549df, git 2.2.0-rc1, Nov. 2014, by the same Peff:

When we start the git-fetch program, we call git_config to load all config, but our callback only processes the fetch.prune option; we do not chain to git_default_config at all.

This means that we may not load some core configuration which will have an effect. For instance, we do not load core.logAllRefUpdates, which impacts whether or not we create reflogs in a bare repository.

Let's just load the core config at the start of fetch, so we know we have it

See another example with commit 3e1dd17, git 1.7.7-rc1, Aug. 2011 with the default color config.

这篇关于git config:列出所有变量及其默认值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆