“瓷器”这个词是什么意思?在 Git 中是什么意思?

发布于 2024-11-28 12:20:54 字数 34 浏览 1 评论 0原文

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

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(9

跨年 2024-12-05 12:20:54

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

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

银河中√捞星星 2024-12-05 12:20:54

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

  • 意味着人类可读
  • 不意味着被解析
  • 容易发生变化/演变

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

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

git status --porcelain
git push --porcelain
git blame --porcelain

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

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


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

--porcelain

以易于解析的脚本格式提供输出。这与短输出类似,但在不同 git 版本之间并且无论用户配置如何,都将保持稳定。详情请参阅下文。

上述 Git 邮件列表中的线程 包括以下详细信息:

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

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


评论william-berg,同样适用于 git 推送

--porcelain

产生机器可读的输出。
每个引用的输出状态行将以制表符分隔并发送到 stdout 而不是 stderr
将给出参考文献的完整符号名称。


正如 John Glassmyer 提议的在评论

也许这里的--porcelain的意思是“产生适合瓷器文字消费的输出”

这可以通过“--porcelain选项”介绍的第一个案例来支持
(在 git status --porcelain 之前,提交 6f15787,2009 年 9 月,git 1.7 .0,
git push --porcelain 之前,提交 1965ff7,2009 年 6 月,git 1.6。 4):

git Blame --porcelain

-p
--porcelain

以专为机器使用而设计的格式显示。

提交 b5c698d,2006 年 10 月,git 1.4.4

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

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

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 to improve the end-user experience.

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.

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

The aforementioned thread from the Git mailing list included the following 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"

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!

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


As John Glassmyer proposes in the comments:

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

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:

-p
--porcelain

Show in a format designed for machine consumption.

Commit b5c698d, October 2006, git 1.4.4

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

我三岁 2024-12-05 12:20:54

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

https://web.archive.org/web/20190427113112/http://www.gelato.unsw.edu.au/archives/git/0504/0881.html

<块引用>

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

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

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

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.

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

计㈡愣 2024-12-05 12:20:54

简单解释

  • Porcelain”命令:用于脚本编写因为:他们可能会改变;适用于人类,而不是机器。为了帮助您记住浴室中的陶瓷水龙头(或水龙头) - 您可以轻松地用不同的颜色替换它们。 瓷器== easy_to_change
  • Plumbing”命令可用于脚本编写,因为:它们更稳定/不太可能改变)。管道是指浴室中的管道 - 管道是永久性的,不能轻易改变!

是的,但是令人困惑的 --porcelain 选项怎么样?

如果您想:

  1. 使用瓷器命令(用于人类,而不是解析)并
  2. 可靠地解析它

......那么您可以添加--porcelain 选项并使用输出进行脚本编写。

示例:我可以使用git status --porcelain并使用输出进行脚本编写,没问题。

(批评很容易,尤其是在没有指定替代方案的情况下 - 对 git 的创建者表示最大的尊重。)

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

  • 如果英语不是您的母语,那么 Greg Hewgill 会完美地解释它。
  • 有关更多详细信息:请查看VonC的答案。

Simple Explanation

  • "Porcelain" commands: NOT for scripting because: they are likely to change; meant for humans, not machines. To help you remember think of a porcelain tap (or faucet) in your bathroom - you can easily replace them with a different colour. porcelain == easy_to_change.
  • "Plumbing" commands can be used for scripting because: they are more stable / less likely to change). Plumbing refers to the pipes in your bathroom - PIPES are permanent and they cannot change very easily!

yeah, but what about the confusing --porcelain option!?

If you want to:

  1. use a porcelain command (meant for humans, not parsing) AND
  2. parse it reliably

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

  • If English is not your first language then Greg Hewgill explains it perfectly.
  • For greater detail: checkout VonC's answer.
顾挽 2024-12-05 12:20:54

Porcelain 是依赖于核心 git 的程序和程序套件的可爱名字,呈现出对核心 git 的高级访问。瓷器暴露出更多的 SCM 接口,而不是“管道”。

--瓷器,Git Wiki

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

那请放手 2024-12-05 12:20:54

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

这两种含义虽然可以说并不严格矛盾,但可能看起来是矛盾的。

A. 概念(管道与瓷器)

官方 Pro Git 书籍

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

B. --porcelain / =porcelain 选项

许多 git 命令都带有 --porcelain 选项,其意思是用于脚本编写。

git status' 文档

--瓷器[=<版本>]

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

git diff文档< /a>:

--word-diff[=<模式>]

瓷器

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

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:

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.

B. --porcelain / =porcelain options

Many git commands come with a --porcelain option which is meant for scripting.

git status' documentation:

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

git diff's documentation:

--word-diff[=<mode>]

porcelain

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

素染倾城色 2024-12-05 12:20:54

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.

云巢 2024-12-05 12:20:54

格雷格休吉尔的回答是完全正确的。请注意,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/.

甜是你 2024-12-05 12:20:54

Porcelain 是依赖于核心 git 的程序和程序套件的可爱名字,呈现出对核心 git 的高级访问。

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

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文