@@ -23,32 +23,33 @@ type BlameResult struct {
23
23
Lines []* Line
24
24
}
25
25
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`.
51
28
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
+ //
52
53
// TODO: ways to improve the efficiency of this function:
53
54
// 1. Improve revlist
54
55
// 2. Improve how to traverse the history (example a backward traversal will
0 commit comments