Home Explore Blog CI



git

2nd chunk of `Documentation/git-blame.adoc`
16175541076e8436c0ab7de4dd14a1a0cc09accf38c004460000000100000b7b
	option.

-w::
	Ignore whitespace when comparing the parent's version and
	the child's to find where the lines came from.

--abbrev=<n>::
	Instead of using the default 7+1 hexadecimal digits as the
	abbreviated object name, use <m>+1 digits, where <m> is at
	least <n> but ensures the commit object names are unique.
	Note that 1 column
	is used for a caret to mark the boundary commit.


THE DEFAULT FORMAT
------------------

When neither `--porcelain` nor `--incremental` option is specified,
`git blame` will output annotation for each line with:

- abbreviated object name for the commit the line came from;
- author ident (by default the author name and date, unless `-s` or `-e`
  is specified); and
- line number

before the line contents.

THE PORCELAIN FORMAT
--------------------

In this format, each line is output after a header; the
header at the minimum has the first line which has:

- 40-byte SHA-1 of the commit the line is attributed to;
- the line number of the line in the original file;
- the line number of the line in the final file;
- on a line that starts a group of lines from a different
  commit than the previous one, the number of lines in this
  group.  On subsequent lines this field is absent.

This header line is followed by the following information
at least once for each commit:

- the author name ("author"), email ("author-mail"), time
  ("author-time"), and time zone ("author-tz"); similarly
  for committer.
- the filename in the commit that the line is attributed to.
- the first line of the commit log message ("summary").

The contents of the actual line are output after the above
header, prefixed by a TAB. This is to allow adding more
header elements later.

The porcelain format generally suppresses commit information that has
already been seen. For example, two lines that are blamed to the same
commit will both be shown, but the details for that commit will be shown
only once. Information which is specific to individual lines will not be
grouped together, like revs to be marked 'ignored' or 'unblamable'. This
is more efficient, but may require more state be kept by the reader. The
`--line-porcelain` option can be used to output full commit information
for each line, allowing simpler (but less efficient) usage like:

	# count the number of lines attributed to each author
	git blame --line-porcelain file |
	sed -n 's/^author //p' |
	sort | uniq -c | sort -rn


SPECIFYING RANGES
-----------------

Unlike 'git blame' and 'git annotate' in older versions of git, the extent
of the annotation can be limited to both line ranges and revision
ranges. The `-L` option, which limits annotation to a range of lines, may be
specified multiple times.

When you are interested in finding the origin for
lines 40-60 for file `foo`, you can use the `-L` option like so
(they mean the same thing -- both ask for 21 lines starting at
line 40):

	git blame -L 40,60 foo
	git blame -L 40,+21

Title: Git Blame Output Formats and Options
Summary
The git-blame command can produce output in different formats, including the default format and the porcelain format, and can be customized with options such as ignoring whitespace, abbreviating object names, and specifying line and revision ranges to limit the annotation.