关于术语:Git中的术语“瓷器”是什么意思?

What does the term “porcelain” mean in Git?

Git文档中偶尔出现"瓷器"一词。 这是什么意思?


"瓷器"是通常制作厕所的材料(有时还有其他固定装置,如洗脸盆)。这与"管道"(实际的管道和排水管)不同,瓷器为管道提供了更加用户友好的界面。

Git以类比的方式使用这个术语,将用户通常不需要直接使用的低级命令("管道")与更加用户友好的高级命令("瓷器")分开。


更重要的是,术语"瓷器"适用于高级命令,输出:

  • 意味着人类可读
  • 不打算解析
  • 易受变化/演变的影响

这是关键:如果你编写脚本,你应该使用可能的管道命令,输出稳定。不是瓷器命令。

但是,您可以使用在命令中具有--porcelain选项的瓷命令的输出(见下文),如:

1
2
3
git status --porcelain
git push --porcelain
git blame --porcelain

Although git includes its own porcelain layer, its low-level commands are sufficient to support development of alternative porcelains.
The interface (input, output, set of options and the semantics) to these low-level commands are meant to be a lot more stable than Porcelain level commands, because these commands are primarily for scripted use.
The interface to Porcelain commands on the other hand are subject to change in order to improve the end user experience.

请参阅"如何以编程方式确定是否存在未提交的更改?"作为使用管道命令而不是瓷器命令的示例。

注意:瓷器命令可以有--porcelain选项。
例如:git status --porcelain,指定要解析的输出。

1
--porcelain

Give the output in an easy-to-parse format for scripts. This is similar to the short output, but will remain stable across git versions and regardless of user configuration. See below for details.

上面提到的主题细节:

This is my fault, to some degree.
The"short-status" form is meant for human eyeballs, and was designed by Junio.
Some people wanted a scriptable status output, too, so I slapped a"--porcelain" on the same format that turns off configurable features like relative pathnames and colorizing, and makes an implicit promise that we won't make further changes to the format.
The idea was to prevent people from scripting around --short, because it was never intended to be stable.
So yeah, while --porcelain by itself is stable and scriptable, it is perhaps not the most friendly to parsers. The"-z --porcelain" format is much more so, and I would recommend it to anyone scripting around"git status"

这反映了git用户在脚本中使用瓷器命令的需要!
但只有稳定的输出(--porcelain)

正如威廉伯格所评论的那样,git push也是如此!

1
--porcelain

Produce machine-readable output.
The output status line for each ref will be tab-separated and sent to stdout instead of stderr.
The full symbolic names of the refs will be given.

正如John Glassmyer在评论中提出的那样:

Perhaps the meaning of --porcelain here is"produce output suitable for consumption by porcelain scripts".

这可以通过"--porcelain选项"介绍的第一个案例得到支持
(在git status --porcelain之前,提交6f15787,2009年9月,git 1.7.0,
git push --porcelain之前,提交1965ff7,2009年6月,git 1.6.4):

git blame --porcelain

1
2
-p
--porcelain

Show in a format designed for machine consumption.

承诺b5c698d,2006年10月,git 1.4.4

The new option makes the command's native output format to emit output that is easier to handle by Porcelain.


git中的"瓷器"一词的使用和使用实际上是由迈克·塔特(Mike Taht)进行的,而其他方面则与Linus Torvalds失去了激烈的争论。

http://www.gelato.unsw.edu.au/archives/git/0504/0881.html

In fact, one of my hopes was that other SCM's could just use the git plumbing.
But then I'd really suggest that you use"git" itself, not any"libgit". Ie you take all the plumbing as real programs, and instead of trying to link against individual routines, you'd script it.

如果你不想要它,我就不会这样做。
但是,将管道与瓷器分开仍然是有意义的。


Porcelain is cute name for programs and program suites depending on core git, presenting a high level access to core git. Porcelains expose more of a SCM interface than the"plumbing".

--Porcelain,Git Wiki


瓷器命令是为人类消费而设计的,而不是命令,其输出很容易被计算机解析。 git status就是一个例子。


Greg Hewgill的回答是完全正确的。请注意,Git还有其他可用的瓷器,包括Easy Git,yap,pyrite和vng。每个都旨在使Git更容易学习/使用社区的某些部分。所有这些项目的链接都在Easy Git页面上:http://people.gnome.org/~newren/eg/。


Porcelain is cute name for programs and program suites depending on core git, presenting a high level access to core git.

https://git.wiki.kernel.org/index.php/Porcelain