I agree with kostix; git log
is a porcelain command. But the problem here is that there are some things git log
can do that are too difficult to do with other commands, so we can sometimes make git log
act like a plumbing command.
The key distinction between plumbing and porcelain shows up when comparing, e.g., git branch
and git tag
to git for-each-ref
, or git diff
to git diff-tree
and git diff-files
and git diff-index
. It's not how many porcelains there are per plumbing. Here, for instance, the plumbing git for-each-ref
has two separate porcelain front ends, while the single front-end git diff
has three plumbing back-ends. No, the key is that git diff
changes its behavior based on user-selected configuration items:
diff.algorithm
diff.dirstat
diff.renameLimit
diff.renames
diff.statGraphWidth
diff.submodule
and so on. The plumbing versions ignore all user configuration, so that a script you write behaves the same for Alice, Bob, Carol, and Dave, even though they have different settings.
When using this definition, we can decide whether git log
acts like a plumbing command. This requires enumerating all the git log
configuration options. Unfortunately, there's no clean way to do that—more options can be added at any time, and some have been added over time.
Here's a list I found by scraping through the git log
and git config
manual. Note that I omit all the diff-oriented ones (e.g., color.diff
and the diff.*
items mentioned above) as there are plumbing commands to handle the equivalent of -p
in git log
(though you must work through one commit at a time).
color.decorate.<slot>
core.notesRef
format.pretty
i18n.logOutputEncoding
log.abbrevCommit
log.date
log.decorate
log.follow
log.graphColors
log.mailmap
log.showRoot
log.showSignature
notes.displayRef
pretty.<name>
So, let's say we want to get the committer date from some particular commit, formatted some particular way. To do that we might run:
git log --no-walk --pretty=format:%cd
We find in the main git log
documentation that pretty format %cd
is described this way:
%cd: committer date (format respects --date= option)
We failed to give a --date=
option, so git log
will look up the log.date
setting. That's a user-configuration option, and our git log
output will depend on the user's choice, rather than ours.
To make this git log
act like a plumbing command, then, we must override the log.date
configuration setting, with, e.g., --date=default
or -c log.date=default
:
git -c log.date=default log --no-walk --pretty=format:%cd
or:
git log --no-walk --date=default --pretty=format:%cd
Ideally, Git should have either a plog
command that is defined as plumbing variant of git log, or a git format-log-metadata
plumbing command that takes the --pretty=<directives>
options and formats log metadata. Since it doesn't, it's up to anyone writing a script, that needs git log --pretty=format:...
output, to make sure that they know about configuration options that might affect them.
git log
, with machine-oriented format, are mentioned in Chapter 2.3, which is in "this book's first nine chapters". – Ruhnke