Skip to contentSkip to conversation

blame: documentation update

PATCH Superseded Bagas Sanjaya 3 participants 7 messages Oct 1, 2021 – Oct 4, 2021 Documentation

v3 of 5 Superseded Latest is v5 →

lore
Share & tools
lore
#0 lore raw

v3 cover blame: documentation update

Document the default output format for git-blame(1), as well as the --color-* options which are currently undocumented but mentioned in usage help.

Changes since v2 [1]:
- describe that the default blame format has "author ident" (suggested by Junio)
- s/they belong to/they come from/ (suggested by Junio)

Bagas Sanjaya (2):
blame: Describe default output format
blame: document --color-* options

 Documentation/blame-options.txt | 12 ++++++++++++
 Documentation/config/color.txt  | 12 ++++++------
 Documentation/git-blame.txt     | 17 +++++++++++++++--
 3 files changed, 33 insertions(+), 8 deletions(-)

Range-diff against v2 [1]:
1: d6433fc682 ! 1: 2478909d67 blame: Describe default output format

    @@ Documentation/git-blame.txt: include::blame-options.txt[]
     +------------------
     +
     +When neither `--porcelain` nor `--incremental` option is specified,
    -+`git blame` will output inline annotation for each line with:
    ++`git blame` will output annotation for each line with:
     +
    -+- abbreviated SHA-1 of the commit the line is attributed to;
    -+- author name (or author email if `-e` or `--show-email` is specified);
    -+- author date; and
    ++- abbreviated object name for the commit the line came from;
    ++- author ident (by default author name and date unless `-s` or `-e` is
    ++specified); and
     +- line number
     +
    ++before the line contents.
     +
      THE PORCELAIN FORMAT
      --------------------

2: 5a5ca69012 ! 2: a6f75786ec blame: document --color-* options
@@ Documentation/blame-options.txt: take effect.
previously processed files.

+--color-lines::
-+ Color lines differently, if they belong to the same commit as the preceding line.
++ Color lines differently, if they come from the same commit as the preceding line.
+ This facilitates distinguishing code blocks introduced by different commits.
+ The color defaults to cyan and be adjusted using the color.blame.repeatedLines
+ config option. Only the line annotation (see "The Default Format" section)
@@ Documentation/config/color.txt: before the given timestamp, overwriting older ti
- Use the customized color for the part of git-blame output that
- is repeated meta information per line (such as commit id,
- author name, date and timezone). Defaults to cyan.
-+ Use the specified color to colorize line annotations, if they belong to the
++ Use the specified color to colorize line annotations, if they come from the
+ same commit as the preceding line (git blame --color-lines). Defaults to
+ cyan.

[1]:
https://lore.kernel.org/git/[email protected]/T/#t

base-commit: cefe983a320c03d7843ac78e73bd513a27806845

Signature · 1 line
An old man doll... just what I always wanted! - Clara
#1 lore raw

PATCH v3 1/2 blame: Describe default output format

While there is descriptions for porcelain and incremental output formats, the default format isn't described. Describe that format for the sake of completeness.

---
 Documentation/git-blame.txt | 13 +++++++++++++
 1 file changed, 13 insertions(+)
Documentation/git-blame.txt +13 -0
index 3bf5d5d8b4..683f8ab0b0 100644
@@ -93,6 +93,19 @@ include::blame-options.txt[]
 	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 author name and date unless `-s` or `-e` is
+specified); and
+- line number
+
+before the line contents.
+
 THE PORCELAIN FORMAT
 --------------------
 
Signature · 1 line
An old man doll... just what I always wanted! - Clara
#2 lore raw

Re: [PATCH v3 1/2] blame: Describe default output format

Quoted 16 lines · Bagas Sanjaya

While there is descriptions for porcelain and incremental output formats, the default format isn't described. Describe that format for the sake of completeness.

---
 Documentation/git-blame.txt | 13 +++++++++++++
 1 file changed, 13 insertions(+)
Documentation/git-blame.txt +0 -0
index 3bf5d5d8b4..683f8ab0b0 100644
@@ -93,6 +93,19 @@ include::blame-options.txt[]
 	is used for a caret to mark the boundary commit.
 

Documentation/git-blame.txt include::blame-options.txt[] · line 104

Quoted 10 lines
Documentation/git-blame.txt +9 -0
 
+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 author name and date unless `-s` or `-e` is
+specified); and

It probably would become easier to read with a comma before "unless".

Other than that (and the downcasing of Describe in the title), looks good to me.

Thanks.

Quoted 6 lines
Documentation/git-blame.txt +4 -0
+- line number
+
+before the line contents.
+
 THE PORCELAIN FORMAT
 --------------------
#3 lore raw

PATCH v3 2/2 blame: document --color-* options

In reply to Bagas Sanjaya

Commit cdc2d5f11f1a (builtin/blame: dim uninteresting metadata lines, 2018-04-23) and 25d5f52901f0 (builtin/blame: highlight recently changed lines, 2018-04-23) introduce --color-lines and --color-by-age options to git blame, respectively. While both options are mentioned in usage help, they aren't documented in git-blame(1). Document them.

---
 Documentation/blame-options.txt | 12 ++++++++++++
 Documentation/config/color.txt  | 12 ++++++------
 Documentation/git-blame.txt     |  4 ++--
 3 files changed, 20 insertions(+), 8 deletions(-)
Documentation/blame-options.txt +12 -0
index 117f4cf806..9f82936bf1 100644
@@ -136,5 +136,17 @@ take effect.
 	option.  An empty file name, `""`, will clear the list of revs from
 	previously processed files.
 
+--color-lines::
+	Color lines differently, if they come from the same commit as the preceding line.
+	This facilitates distinguishing code blocks introduced by different commits.
+	The color defaults to cyan and be adjusted using the `color.blame.repeatedLines`
+	config option. Only the line annotation (see "The Default Format" section)
+	is colored.
+
+--color-by-age::
+	Color lines depending on the age of the line. The `color.blame.highlightRecent`
+	config option controls what color is used for which range of age. Only the
+	line annotation (see "The Default Format" section) is colored.
+
 -h::
 	Show help message.
Documentation/config/color.txt +6 -6
index e05d520a86..5634f5b800 100644
@@ -9,8 +9,8 @@ color.advice.hint::
 	Use customized color for hints.
 
 color.blame.highlightRecent::
-	This can be used to color the metadata of a blame line depending
-	on age of the line.
+	Used to color line annotations differently depending on the age of the commit
+	(`git blame --color-by-age`).
 +
 This setting should be set to a comma-separated list of color and date settings,
 starting and ending with a color, the dates should be set from oldest to newest.
@@ -20,15 +20,15 @@ before the given timestamp, overwriting older timestamped colors.
 Instead of an absolute timestamp relative timestamps work as well, e.g.
 2.weeks.ago is valid to address anything older than 2 weeks.
 +
-It defaults to 'blue,12 month ago,white,1 month ago,red', which colors
+It defaults to `blue,12 month ago,white,1 month ago,red`, which colors
 everything older than one year blue, recent changes between one month and
 one year old are kept white, and lines introduced within the last month are
 colored red.
 
 color.blame.repeatedLines::
-	Use the customized color for the part of git-blame output that
-	is repeated meta information per line (such as commit id,
-	author name, date and timezone). Defaults to cyan.
+	Use the specified color to colorize line annotations, if they come from the
+	same commit as the preceding line (`git blame --color-lines`). Defaults to
+	cyan.
 
 color.branch::
 	A boolean to enable/disable color in the output of
Documentation/git-blame.txt +2 -2
index 683f8ab0b0..9d7b6003cd 100644
@@ -11,8 +11,8 @@ SYNOPSIS
 'git blame' [-c] [-b] [-l] [--root] [-t] [-f] [-n] [-s] [-e] [-p] [-w] [--incremental]
 	    [-L <range>] [-S <revs-file>] [-M] [-C] [-C] [-C] [--since=<date>]
 	    [--ignore-rev <rev>] [--ignore-revs-file <file>]
-	    [--progress] [--abbrev=<n>] [<rev> | --contents <file> | --reverse <rev>..<rev>]
-	    [--] <file>
+	    [--color-lines] [--color-by-age] [--progress] [--abbrev=<n>]
+	    [<rev> | --contents <file> | --reverse <rev>..<rev>] [--] <file>
 
 DESCRIPTION
 -----------
Signature · 1 line
An old man doll... just what I always wanted! - Clara
#4 lore raw

Re: [PATCH v3 2/2] blame: document --color-* options

Quoted 12 lines · Bagas Sanjaya

Commit cdc2d5f11f1a (builtin/blame: dim uninteresting metadata lines, 2018-04-23) and 25d5f52901f0 (builtin/blame: highlight recently changed lines, 2018-04-23) introduce --color-lines and --color-by-age options to git blame, respectively. While both options are mentioned in usage help, they aren't documented in git-blame(1). Document them.

---

Documentation/blame-options.txt take effect. · line 137

Quoted 2 lines
Documentation/blame-options.txt +2 -0
@@ -136,5 +136,17 @@ take effect.
+--color-lines::
+       Color lines differently, if they come from the same commit as the preceding line.

Drop the comma: s/differently,/differently/

Documentation/blame-options.txt take effect. · line 141

Quoted 1 line
Documentation/blame-options.txt +1 -0
+       This facilitates distinguishing code blocks introduced by different commits.

Taking non-native English speakers into account, perhaps:
s/facilitates distinguishing/makes it easier to distinguish/

Documentation/blame-options.txt take effect. · line 142

Quoted 1 line
Documentation/blame-options.txt +1 -0
+       The color defaults to cyan and be adjusted using the `color.blame.repeatedLines`

s/and be/and can be/

Documentation/blame-options.txt take effect. · line 144

Quoted 2 lines
Documentation/blame-options.txt +2 -0
+       config option. Only the line annotation (see "The Default Format" section)
+       is colored.

You can drop the last sentence entirely if you start the blurb like this:

Color line annotations differently, if...

Documentation/blame-options.txt take effect. · line 149

Quoted 4 lines
Documentation/blame-options.txt +4 -0
+--color-by-age::
+       Color lines depending on the age of the line. The `color.blame.highlightRecent`
+       config option controls what color is used for which range of age. Only the
+       line annotation (see "The Default Format" section) is colored.

Ditto about dropping the last sentence.

Color line annotations depending upon the age of the line.

Documentation/config/color.txt color.advice.hint:: · line 11

Quoted 7 lines
Documentation/config/color.txt +2 -2
@@ -9,8 +9,8 @@ color.advice.hint::
 color.blame.highlightRecent::
-       This can be used to color the metadata of a blame line depending
-       on age of the line.
+       Used to color line annotations differently depending on the age of the commit
+       (`git blame --color-by-age`).

This can be tightened up:

Specify the line annotation color depending upon the age of the commit (git blame...).

Documentation/config/color.txt before the given timestamp, overwriting older timestamped colors. · line 23

Quoted 8 lines
Documentation/config/color.txt +3 -3
@@ -20,15 +20,15 @@ before the given timestamp, overwriting older timestamped colors.
 color.blame.repeatedLines::
-       Use the customized color for the part of git-blame output that
-       is repeated meta information per line (such as commit id,
-       author name, date and timezone). Defaults to cyan.
+       Use the specified color to colorize line annotations, if they come from the
+       same commit as the preceding line (`git blame --color-lines`). Defaults to
+       cyan.

Likewise:

Specify the line annotation color for lines which originate with the same commit (git blame...).

#5 lore raw

Re: [PATCH v3 2/2] blame: document --color-* options

Quoted 7 lines · Eric Sunshine

Documentation/blame-options.txt take effect. · line 144

Quoted 2 lines
Documentation/blame-options.txt +2 -0
+       config option. Only the line annotation (see "The Default Format" section)
+       is colored.

You can drop the last sentence entirely if you start the blurb like this:

Color line annotations differently, if...

Quoted 9 lines

Documentation/blame-options.txt take effect. · line 149

Quoted 4 lines

+--color-by-age::

Documentation/blame-options.txt +3 -0
+       Color lines depending on the age of the line. The `color.blame.highlightRecent`
+       config option controls what color is used for which range of age. Only the
+       line annotation (see "The Default Format" section) is colored.

Ditto about dropping the last sentence.

Color line annotations depending upon the age of the line.

I observed that both --color-lines and --color-by-age only apply to default blame format, so the wording can be Color line annotations ... if neither --porcelain nor --incremental option is specified ...

Signature · 1 line
An old man doll... just what I always wanted! - Clara
#6 lore raw

Re: [PATCH v3 2/2] blame: document --color-* options

Quoted 11 lines · Bagas Sanjaya
Quoted 10 lines · Eric Sunshine

Documentation/blame-options.txt take effect. · line 144

Quoted 2 lines
Documentation/blame-options.txt +2 -0
+       config option. Only the line annotation (see "The Default Format" section)
+       is colored.

You can drop the last sentence entirely if you start the blurb like this:
Color line annotations differently, if...

Quoted 4 lines

+--color-by-age::

Documentation/blame-options.txt +3 -0
+       Color lines depending on the age of the line. The `color.blame.highlightRecent`
+       config option controls what color is used for which range of age. Only the
+       line annotation (see "The Default Format" section) is colored.
Quoted 6 lines
Quoted 3 lines

Ditto about dropping the last sentence.
Color line annotations depending upon the age of the line.

I observed that both --color-lines and --color-by-age only apply to default blame format, ...

Technically, it is sufficient to say "color line annotations" because the default format is the only one that is described to give "line annotations". I do not think it would hurt too much to be a bit more explicit, perhaps like:

Color line annotations, depending upon the age of the line, in the default output format.

I personally feel "(see section X)" is being a bit more ditracting than being helpful to readers.

Thanks.