Skip to content
This repository was archived by the owner on Sep 11, 2020. It is now read-only.

Commit e408162

Browse files
committed
Simplify Blame documentation
1 parent be7e1e6 commit e408162

File tree

1 file changed

+26
-25
lines changed

1 file changed

+26
-25
lines changed

blame.go

+26-25
Original file line numberDiff line numberDiff line change
@@ -23,32 +23,33 @@ type BlameResult struct {
2323
Lines []*Line
2424
}
2525

26-
// Blame returns a BlameResult that contains all the data needed to know the
27-
// last author of each line of an specified file starting the history from
28-
// a specified commit. The file to blame is identified by the input arguments:
29-
// commit and path. commit is a Commit object obtained from a Repository. Path
30-
// represents a path to a specific file contained into the repository.
31-
//
32-
// Blaming a file is a two step process:
33-
//
34-
// 1. Create a linear history of the commits affecting a file. We use
35-
// revlist.New for that.
36-
//
37-
// 2. Then build a graph with a node for every line in every file in
38-
// the history of the file.
39-
//
40-
// Each node is assigned a commit: Start by the nodes in the first
41-
// commit. Assign that commit as the creator of all its lines.
42-
//
43-
// Then jump to the nodes in the next commit, and calculate the diff
44-
// between the two files. Newly created lines get
45-
// assigned the new commit as its origin. Modified lines also get
46-
// this new commit. Untouched lines retain the old commit.
47-
//
48-
// All this work is done in the assignOrigin function which holds all
49-
// the internal relevant data in a "blame" struct, that is not
50-
// exported.
26+
// Blame returns a BlameResult with the information about the last author of
27+
// each line from file `path` at commit `c`.
5128
func Blame(c *object.Commit, path string) (*BlameResult, error) {
29+
// The file to blame is identified by the input arguments:
30+
// commit and path. commit is a Commit object obtained from a Repository. Path
31+
// represents a path to a specific file contained into the repository.
32+
//
33+
// Blaming a file is a two step process:
34+
//
35+
// 1. Create a linear history of the commits affecting a file. We use
36+
// revlist.New for that.
37+
//
38+
// 2. Then build a graph with a node for every line in every file in
39+
// the history of the file.
40+
//
41+
// Each node is assigned a commit: Start by the nodes in the first
42+
// commit. Assign that commit as the creator of all its lines.
43+
//
44+
// Then jump to the nodes in the next commit, and calculate the diff
45+
// between the two files. Newly created lines get
46+
// assigned the new commit as its origin. Modified lines also get
47+
// this new commit. Untouched lines retain the old commit.
48+
//
49+
// All this work is done in the assignOrigin function which holds all
50+
// the internal relevant data in a "blame" struct, that is not
51+
// exported.
52+
//
5253
// TODO: ways to improve the efficiency of this function:
5354
// 1. Improve revlist
5455
// 2. Improve how to traverse the history (example a backward traversal will

0 commit comments

Comments
 (0)