Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does git log --exit-code mean?

The git-log man page describes the --check option as incompatible with the --exit-code option. I'd like to know what this --exit-code means but I can't find it anywhere. I've tried man git log, man git, Google and direct search here on SO... to no avail!

What does --exit-code mean for git log?

like image 613
Alois Mahdal Avatar asked Sep 29 '15 21:09

Alois Mahdal


People also ask

How do I exit git log command?

You can press q to exit. git hist is using a pager tool so you can scroll up and down the results before returning to the console.

What is the output of git log?

By default, git log includes merge commits in its output. But, if your team has an always-merge policy (that is, you merge upstream changes into topic branches instead of rebasing the topic branch onto the upstream branch), you'll have a lot of extraneous merge commits in your project history.

What does git log mean?

What does git log do? The git log command displays all of the commits in a repository's history. By default, the command displays each commit's: Secure Hash Algorithm (SHA) author.

How do I check git logs?

The command for that would be git log –oneline -n where n represents the number up to which commit you to want to see the logs.


2 Answers

TL; DR

I'd like to know what this --exit-code means [...]

--exit-code is a diff-*1 option that makes the Git command exit with 1 if there are changes, and 0 otherwise.

[...] but I can't find it anywhere.

You can read about it in the git-diff man page (it's only mentioned in passing in the git-log man page).

More details

Both --check and --exit-code are described in the git-diff man page (more specifically, in Documentation/diff-options.txt):

   --check
 Warn if changes introduce whitespace errors. What are considered
 whitespace errors is controlled by core.whitespace configuration.
 By default, trailing whitespaces (including lines that solely
 consist of whitespaces) and a space character that is immediately
 followed by a tab character inside the initial indent of the line
 are considered whitespace errors. Exits with non-zero status if
 problems are found. Not compatible with --exit-code.

and

   --exit-code
 Make the program exit with codes similar to diff(1). That is, it
 exits with 1 if there were differences and 0 means no differences.

Some, though not all, diff-* options are compatible with git-log. The --check option is, whereas the --exit-code option is not, as hinted at by the following commit message from the Git-project repository:

docs: don't mention --quiet or --exit-code in git-log(1)

These are diff-options, but they don't actually make sense in the context of log.

(1) diff-* stands for the plumbing commands that porcelain git-diff is based on.

like image 92
jub0bs Avatar answered Sep 21 '22 18:09

jub0bs


It's mentioned in the git-diff docs (and is apparently not intended to be used with git-log):

"Make the program exit with codes similar to diff(1). That is, it exits with 1 if there were differences and 0 means no differences."

like image 30
isherwood Avatar answered Sep 21 '22 18:09

isherwood