@@ -29,9 +29,9 @@ use std::ops::Range;
29
29
/// *For brevity, `HEAD` denotes the starting point of the blame operation. It could be any commit, or even commits that
30
30
/// represent the worktree state.
31
31
/// We begin with a single *Unblamed Hunk* and a single suspect, usually the `HEAD` commit as the commit containing the
32
- /// *Original File*, so that it contains the entire file, with the first commit being a candidate for the entire *Original File*.
32
+ /// *Blamed File*, so that it contains the entire file, with the first commit being a candidate for the entire *Blamed File*.
33
33
/// We traverse the commit graph starting at the first suspect, and see if there have been changes to `file_path`.
34
- /// If so, we have found a *Blamed File* and a *Suspect* commit, and have hunks that represent these changes.
34
+ /// If so, we have found a *Source File* and a *Suspect* commit, and have hunks that represent these changes.
35
35
/// Now the *Unblamed Hunk* is split at the boundaries of each matching change, creating a new *Unblamed Hunk* on each side,
36
36
/// along with a [`BlameEntry`] to represent the match.
37
37
/// This is repeated until there are no non-empty *Unblamed Hunk*s left.
@@ -69,22 +69,22 @@ where
69
69
70
70
let mut stats = Statistics :: default ( ) ;
71
71
let ( mut buf, mut buf2, mut buf3) = ( Vec :: new ( ) , Vec :: new ( ) , Vec :: new ( ) ) ;
72
- let original_file_entry = find_path_entry_in_commit ( & odb, & suspect, file_path, & mut buf, & mut buf2, & mut stats) ?
72
+ let blamed_file_entry = find_path_entry_in_commit ( & odb, & suspect, file_path, & mut buf, & mut buf2, & mut stats) ?
73
73
. ok_or_else ( || Error :: FileMissing {
74
74
file_path : file_path. to_owned ( ) ,
75
75
commit_id : suspect,
76
76
} ) ?;
77
- let original_file_blob = odb. find_blob ( & original_file_entry . oid , & mut buf) ?. data . to_vec ( ) ;
78
- let num_lines_in_original = {
79
- let mut interner = gix_diff:: blob:: intern:: Interner :: new ( original_file_blob . len ( ) / 100 ) ;
80
- tokens_for_diffing ( & original_file_blob )
77
+ let blamed_file_blob = odb. find_blob ( & blamed_file_entry . oid , & mut buf) ?. data . to_vec ( ) ;
78
+ let num_lines_in_blamed = {
79
+ let mut interner = gix_diff:: blob:: intern:: Interner :: new ( blamed_file_blob . len ( ) / 100 ) ;
80
+ tokens_for_diffing ( & blamed_file_blob )
81
81
. tokenize ( )
82
82
. map ( |token| interner. intern ( token) )
83
83
. count ( )
84
84
} ;
85
85
86
86
let mut hunks_to_blame = vec ! [ UnblamedHunk :: new(
87
- 0 ..num_lines_in_original as u32 ,
87
+ 0 ..num_lines_in_blamed as u32 ,
88
88
suspect,
89
89
Offset :: Added ( 0 ) ,
90
90
) ] ;
@@ -194,7 +194,7 @@ where
194
194
out. sort_by ( |a, b| a. range_in_blamed_file . start . cmp ( & b. range_in_blamed_file . start ) ) ;
195
195
Ok ( Outcome {
196
196
entries : coalesce_blame_entries ( out) ,
197
- blob : original_file_blob ,
197
+ blob : blamed_file_blob ,
198
198
statistics : stats,
199
199
} )
200
200
}
@@ -218,7 +218,7 @@ fn unblamed_to_out(hunks_to_blame: &mut Vec<UnblamedHunk>, out: &mut Vec<BlameEn
218
218
}
219
219
220
220
/// This function merges adjacent blame entries. It merges entries that are adjacent both in the
221
- /// blamed file and in the original file that introduced them. This follows `git`’s
221
+ /// blamed file and in the source file that introduced them. This follows `git`’s
222
222
/// behaviour. `libgit2`, as of 2024-09-19, only checks whether two entries are adjacent in the
223
223
/// blamed file which can result in different blames in certain edge cases. See [the commit][1]
224
224
/// that introduced the extra check into `git` for context. See [this commit][2] for a way to test
@@ -237,12 +237,11 @@ fn coalesce_blame_entries(lines_blamed: Vec<BlameEntry>) -> Vec<BlameEntry> {
237
237
if previous_entry. commit_id == entry. commit_id
238
238
&& previous_entry. range_in_blamed_file . end == entry. range_in_blamed_file . start
239
239
// As of 2024-09-19, the check below only is in `git`, but not in `libgit2`.
240
- && previous_entry. range_in_original_file . end == entry. range_in_original_file . start
240
+ && previous_entry. range_in_source_file . end == entry. range_in_source_file . start
241
241
{
242
242
let coalesced_entry = BlameEntry {
243
243
range_in_blamed_file : previous_entry. range_in_blamed_file . start ..entry. range_in_blamed_file . end ,
244
- range_in_original_file : previous_entry. range_in_original_file . start
245
- ..entry. range_in_original_file . end ,
244
+ range_in_source_file : previous_entry. range_in_source_file . start ..entry. range_in_source_file . end ,
246
245
commit_id : previous_entry. commit_id ,
247
246
} ;
248
247
@@ -304,7 +303,7 @@ fn blob_changes(
304
303
file_path : & BStr ,
305
304
stats : & mut Statistics ,
306
305
) -> Result < Vec < Change > , Error > {
307
- /// Record all [`Change`]s to learn about additions, deletions and unchanged portions of a *Blamed File*.
306
+ /// Record all [`Change`]s to learn about additions, deletions and unchanged portions of a *Source File*.
308
307
struct ChangeRecorder {
309
308
last_seen_after_end : u32 ,
310
309
hunks : Vec < Change > ,
0 commit comments