“瓷器”这个词是什么意思?在 Git 中是什么意思?
“瓷器”一词偶尔出现在 Git 文档中。这是什么意思?
The term "porcelain" appears occasionally in the Git documentation. What does it mean?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(9)
“瓷器”是通常制造厕所(有时也制造洗脸盆等其他固定装置)的材料。这与“管道”(实际的管道和排水管)不同,在“管道”中,瓷器为管道提供了更用户友好的界面。
Git 类比地使用这个术语,将用户通常不需要直接使用的低级命令(“管道”)与更用户友好的高级命令(“瓷器”)分开。
"Porcelain" is the material from which toilets are usually made (and sometimes other fixtures such as washbasins). This is distinct from "plumbing" (the actual pipes and drains), where the porcelain provides a more user-friendly interface to the plumbing.
Git uses this terminology in analogy, to separate the low-level commands that users don't usually need to use directly (the "plumbing") from the more user-friendly high level commands (the "porcelain").
更重要的是,术语“porcelain”适用于高级命令,带有输出:
这是关键:如果你编写脚本,你应尽可能使用 plumbing 命令,并具有稳定的输出。不是瓷器命令。
但是,您可以使用在脚本中具有
--porcelain
选项的瓷器命令的输出(见下文),例如:请参阅“如何以编程方式确定是否有未提交的更改?”作为使用管道命令而不是陶瓷命令的示例。
注意:瓷器命令可以有
--porcelain
选项。例如:
git status --porcelain
(Git 邮件列表),指定要解析的输出。上述 Git 邮件列表中的线程 包括以下详细信息:
这反映了 git 用户在其脚本中使用瓷器命令的需要!
但只有稳定的输出(使用
--porcelain
)如评论由 william-berg,同样适用于
git 推送
!正如 John Glassmyer 提议的在评论:
这可以通过“
--porcelain
选项”介绍的第一个案例来支持(在
git status --porcelain
之前,提交 6f15787,2009 年 9 月,git 1.7 .0,在
git push --porcelain
之前,提交 1965ff7,2009 年 6 月,git 1.6。 4):git Blame --porcelain
:提交 b5c698d,2006 年 10 月,git 1.4.4
More importantly, the term "porcelain" applies to high-level commands, with output:
That is key: if you script, you should use if possible plumbing commands, with stable outputs. Not porcelain commands.
However, you can use the output of a porcelain command which has a
--porcelain
option in script (see below), like:See "How do I programmatically determine if there are uncommitted changes?" as an example of using plumbing commands instead of porcelain ones.
Note: A porcelain command can have a
--porcelain
option.For instance:
git status --porcelain
(Git mailing list), which designates an output meant to be parsed.The aforementioned thread from the Git mailing list included the following details:
That reflects the need, for git users, to use porcelain commands in their scripts!
But only with stable output (with
--porcelain
)As commented by william-berg, the same goes for
git push
!As John Glassmyer proposes in the comments:
And that could be supported by the very first case of "
--porcelain
option" introduction(before
git status --porcelain
, commit 6f15787, September 2009, git 1.7.0,before
git push --porcelain
, commit 1965ff7, June 2009, git 1.6.4):git blame --porcelain
:Commit b5c698d, October 2006, git 1.4.4
git 中“瓷器”一词的创造和使用实际上是由 Mike Taht 提出的,但在其他方面却输掉了与 Linus Torvalds 的激烈争论。
https://web.archive.org/web/20190427113112/http://www.gelato.unsw.edu.au/archives/git/0504/0881.html
The coinage and usage of the term "porcelain" in git was actually by Mike Taht, while otherwise losing a heated argument with Linus Torvalds.
https://web.archive.org/web/20190427113112/http://www.gelato.unsw.edu.au/archives/git/0504/0881.html
简单解释
瓷器== easy_to_change
。是的,但是令人困惑的
--porcelain
选项怎么样?如果您想:
......那么您可以添加
--porcelain
选项并使用输出进行脚本编写。示例:我可以使用
git status --porcelain
并使用输出进行脚本编写,没问题。(批评很容易,尤其是在没有指定替代方案的情况下 - 对 git 的创建者表示最大的尊重。)
瓷器/管道术语从何而来?
Simple Explanation
porcelain == easy_to_change
.yeah, but what about the confusing
--porcelain
option!?If you want to:
....then you can add the
--porcelain
option and use the output for scripting.Example: I may use
git status --porcelain
and use the output for scripting, no problem.(It is easy to criticize, especially if no alternative is specified - with the utmost respect to the creators of git.)
Where does porcelain/plumbing terminology come from?
--瓷器,Git Wiki
--Porcelain, Git Wiki
git 中的瓷器有两种不同的含义。
这两种含义虽然可以说并不严格矛盾,但可能看起来是矛盾的。
A. 概念(管道与瓷器)
官方 Pro Git 书籍:
B.
--porcelain
/=porcelain
选项许多 git 命令都带有
--porcelain
选项,其意思是用于脚本编写。git status
' 文档:git diff
的文档< /a>:There are two distinct meanings of porcelain in git.
These two meanings, while it can be argued are not strictly contradictory, can appear contradictory.
A. Conceptual (plumbing vs porcelain)
The official Pro Git book:
B.
--porcelain
/=porcelain
optionsMany git commands come with a
--porcelain
option which is meant for scripting.git status
' documentation:git diff
's documentation:Porcelain 命令是为人类使用而设计的,而不是其输出易于计算机解析的命令。 git status 就是一个例子。
Porcelain commands are designed for human consumption, as opposed to commands whose output is easy for computers to parse.
git status
would be one example.格雷格休吉尔的回答是完全正确的。请注意,Git 有可用的替代品,包括 Easy Git、yap、pyrite 和 vng。每个都是为了让社区的某些部分更容易学习/使用 Git。所有这些项目的链接位于 Easy Git 页面上: http://people.gnome.org/ ~newren/eg/。
Greg Hewgill's answer is exactly correct. Note that there are alternative porcelains available for Git, including Easy Git, yap, pyrite, and vng. Each is intended to make Git easier to learn/use for some part of the community. Links to all of these projects is on the Easy Git page: http://people.gnome.org/~newren/eg/.
https://git.wiki.kernel.org/index.php/Porcelain
https://git.wiki.kernel.org/index.php/Porcelain