Git 中的“瓷器”一词是什么意思?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/6976473/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-10 11:30:51  来源:igfitidea点击:

What does the term "porcelain" mean in Git?

gitterminology

提问by Jan Hettich

The term "porcelain" appears occasionally in the Git documentation. What does it mean?

术语“瓷器”偶尔出现在 Git 文档中。这是什么意思?

回答by Greg Hewgill

"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").

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

回答by VonC

More importantly, the term "porcelain" applies to high-level commands, with output:

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

  • meant to be readable by human
  • not meant to be parsed
  • susceptible to changes/evolutions
  • 旨在供人类阅读
  • 不打算被解析
  • 易受变化/演变的影响

That is key: if you script, you should use if possible plumbingcommands, with stable outputs. Not porcelain commands.

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

However, you can use the output of a porcelain command which has a --porcelainoption in script(see below), like:

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

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

虽然 git 包含自己的瓷器层,但它的低级命令足以支持替代瓷器的开发。
这些低级命令的接口(输入、输出、选项集和语义)比 Porcelain 级命令要稳定得多,因为这些命令主要用于脚本使用
另一方面,Porcelain 命令的界面可能会发生变化,以改善最终用户体验。

See "How do I programmatically determine if there are uncommitted changes?" as an example to using plumbing commands instead of porcelain ones.

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



Note: A porcelain command can have a --porcelainoption.
For instance: git status --porcelain, which designates an output meant to be parsed.

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

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

以易于解析的格式为脚本提供输出。这类似于短输出,但无论用户配置如何,在 git 版本中都将保持稳定。详情请见下文。

The thread mentioned above details:

上面提到的线程详细信息:

This is my fault, to some degree.
The "short-status" form ismeant 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 --porcelainby itself isstable 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"

这在某种程度上是我的错。
“短状态”的形式指对人的眼球,被JUNIO设计。
有些人也想要一个可编写脚本的状态输出,所以我--porcelain在相同的格式上打了一个“ ”,以关闭诸如相对路径名和着色等可配置功能,并隐含地承诺我们不会对格式进行进一步的更改。
这个想法是为了防止人们编写脚本--short,因为它从来就不是稳定的。
所以是的,虽然--porcelain它本身稳定和可编写脚本的,但它可能对解析器不是最友好的。“ -z --porcelain”格式更是如此,我会向任何围绕“git status”编写脚本的人推荐它

That reflects the need, for git users, to using porcelain commands in their scripts!
But only with stable output (with --porcelain)

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



As commentedby william-berg, the same goes for git push!

正如william-berg评论的那样,同样适用!git push

--porcelain

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

生成机器可读的输出。
每个 ref 的输出状态行将以制表符分隔并发送到stdout而不是stderr.
将给出 refs 的完整符号名称。



As John Glassmyerproposes in the comments:

正如约翰·格拉斯迈尔在评论中提出的那样

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

或许这里的意思--porcelain是“用瓷器生产适合消费的产品”

And that could be supported by the very first case of "--porcelainoption" 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):

这可以得到“--porcelain选项”介绍的第一个案例的支持
(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:

git blame --porcelain

-p
--porcelain

Show in a format designed for machine consumption.

以专为机器消费设计的格式显示。

Commit b5c698d, October 2006, git 1.4.4

提交 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.

新选项使命令的本机输出格式发出更易于 Porcelain 处理的输出

回答by dave taht

The coinage and usage of the term "porcelain" in git was actually by Mike Taht, while otherwise losing a heated argument with Linus Torvalds.

git 中“瓷器”一词的造币和用法实际上是由 Mike Taht 提出的,但在其他方面与 Linus Torvalds 发生了激烈的争论。

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

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 allthe plumbing as real programs, and instead of trying to link against individual routines, you'd scriptit.

If you don't want it, I won't do it.
Still makes sense to separate the plumbing from the porcelain, though.

事实上,我的一个希望是其他 SCM 可以只使用 git 管道。
但是我真的建议你使用“git”本身,而不是任何“ libgit”。即,您将所有管道视为真正的程序,而不是尝试链接单个例程,而是编写脚本

如果你不想要,我就不做。
不过,将管道与瓷器分开仍然有意义

回答by Johnsyweb

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

瓷器是依赖于核心 git 的程序和程序套件的可爱名称,表示对核心 git 的高级访问。瓷器比“管道”暴露更多的 SCM 接口。

--Porcelain, Git Wiki

-瓷器,Git Wiki

回答by BKSpurgeon

The Short and Simple Explanation

简短的解释

  • There are two types of commands: "poreclain" and "plumbing".
  • "Porcelain" commands should notbe relied on when programming/scripting: because they are likely to change, and are meant for humans not machines.
  • "Plumbing" commands should be used for scripting, because they are more stable, and are less likely to change.
  • 有两种类型的命令:“poreclain”和“plumbing”。
  • 编程/脚本编写时不应依赖“瓷器”命令:因为它们可能会改变,并且是为人类而非机器设计的。
  • 管道”命令应该用于脚本编写,因为它们更稳定,并且不太可能改变。

But what about the confusing --porcelainoption!?

但是这个令人困惑的--porcelain选项呢!?

  • If you want to: (i) use a porcelain command AND (ii) you want to ensure that the output can reliably be parsed (remember, porcelain commands are meant for humans only and not parsing), then you canadd the --porcelainoption and thenuse the output for scripting. Basically the authors of git are implicitly promising not to change anything in there, any time soon. example: I may use git status --porcelainand use the output for scripting and that would be perfectly ok.
  • 如果您想:(i) 使用瓷器命令和 (ii) 您想确保可以可靠地解析输出(请记住,瓷器命令仅适用于人类而不是解析),然后您可以添加--porcelain选项,然后使用输出进行脚本编写。基本上 git 的作者都含蓄地承诺不会改变那里的任何东西,任何时候。示例:我可以git status --porcelain将输出用于脚本编写,这完全没问题。

Where does porcelain/plumbing terminology come from?

瓷器/管道术语从何而来?

  • If English is not your first language then Greg Hewgillexplains it perfectly.
  • For more detail, checkout VonC'sanswer.
  • 如果英语不是您的第一语言,那么Greg Hewgill会完美地解释它。
  • 有关更多详细信息,请查看VonC 的答案。

回答by dahlbyk

Porcelain commands are designed for human consumption, as opposed to commands whose output is easy for computers to parse. git statuswould be one example.

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

回答by Pablo Halpern

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

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

回答by André Puel

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

瓷器是依赖于核心 git 的程序和程序套件的可爱名称,表示对核心 git 的高级访问。

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

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

回答by tymtam

There are two distinct meanings of porcelain in git.

在 git 中,瓷器有两种不同的含义。

These two meanings, while it can be argued are not strictly contradictory, can appear contradictory.

这两种含义,虽然可以说并不严格矛盾,但可以显得矛盾。

A. Conceptual (plumbing vs porcelain)

A. 概念(管道与瓷器)

The official Pro Git book:

官方Pro Git 书

But because Git was initially a toolkit for a version control system rather than a full user-friendly VCS, it has a number of subcommands that do low-level work and were designed to be chained together UNIX-style or called from scripts. These commands are generally referred to as Git's “plumbing” commands, while the more user-friendly commands are called “porcelain” commands.

但是因为 Git 最初是一个用于版本控制系统的工具包,而不是一个完整的用户友好的 VCS,它有许多子命令执行低级工作,并被设计为以 UNIX 风格链接在一起或从脚本调用。这些命令通常被称为 Git 的“管道”命令,而对用户更友好的命令被称为“瓷器”命令。

B. --porcelain/ =porcelainoptions

B. --porcelain/=porcelain选项

Many git commands come with a --porcelainoption which ismeant for scripting.

许多Git命令都配有--porcelain该选项指用于脚本。

git status' documentation:

git status'文档

--porcelain[=<version>]

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.

--porcelain[=<version>]

以易于解析的格式为脚本提供输出。这类似于短输出,但无论用户配置如何,都将在 Git 版本中保持稳定。详情请见下文。

git diff's documentation:

git diff文档

--word-diff[=<mode>]

porcelain

      Use a special line-based format intended for script consumption.

--word-diff[=<mode>]

      使用专门用于脚本使用的基于行的特殊格式。