What does the term "porcelain" mean in Git?

GitTerminology

Git Problem Overview


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

Git Solutions


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

Solution 2 - Git

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

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 --porcelain option.
For instance: git status --porcelain, 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 thread mentioned above 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 using 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.

Solution 3 - Git

The coinage and usage of the term "porcelain" in git was actually by Mike Taht, while otherwise losing a heated argument with 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.

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

Solution 4 - Git

>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

Solution 5 - Git

Simple Explanation

  • There are two types of git commands: "porcelain" and "plumbing".
  • "Porcelain" commands should NOT be relied on when scripting: (because they are likely to change; they and are meant for humans, not machines).
  • "Plumbing" commands should be used for scripting, (because they are more stable / less likely to change).

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 use the output for scripting.

Example: I may use git status --porcelain and use the output for scripting, no problem.

(I say this with the utmost respect to the creators of git. it is easy to criticize, especially if no alternative is specified. But to me, the flags seem confusing.)

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.

Solution 6 - Git

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.

Solution 7 - Git

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.

Solution 8 - Git

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

Solution 9 - Git

> 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

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionJan HettichView Question on Stackoverflow
Solution 1 - GitGreg HewgillView Answer on Stackoverflow
Solution 2 - GitVonCView Answer on Stackoverflow
Solution 3 - Gitdave tahtView Answer on Stackoverflow
Solution 4 - GitJohnsywebView Answer on Stackoverflow
Solution 5 - GitBenKoshyView Answer on Stackoverflow
Solution 6 - GitdahlbykView Answer on Stackoverflow
Solution 7 - GittymtamView Answer on Stackoverflow
Solution 8 - GitPablo HalpernView Answer on Stackoverflow
Solution 9 - GitAndré PuelView Answer on Stackoverflow