@@ -29,9 +29,9 @@ use std::ops::Range;
2929/// *For brevity, `HEAD` denotes the starting point of the blame operation. It could be any commit, or even commits that
3030/// represent the worktree state.
3131/// 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*.
3333/// 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.
3535/// Now the *Unblamed Hunk* is split at the boundaries of each matching change, creating a new *Unblamed Hunk* on each side,
3636/// along with a [`BlameEntry`] to represent the match.
3737/// This is repeated until there are no non-empty *Unblamed Hunk*s left.
@@ -69,22 +69,22 @@ where
6969
7070 let mut stats = Statistics :: default ( ) ;
7171 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) ?
7373 . ok_or_else ( || Error :: FileMissing {
7474 file_path : file_path. to_owned ( ) ,
7575 commit_id : suspect,
7676 } ) ?;
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 )
8181 . tokenize ( )
8282 . map ( |token| interner. intern ( token) )
8383 . count ( )
8484 } ;
8585
8686 let mut hunks_to_blame = vec ! [ UnblamedHunk :: new(
87- 0 ..num_lines_in_original as u32 ,
87+ 0 ..num_lines_in_blamed as u32 ,
8888 suspect,
8989 Offset :: Added ( 0 ) ,
9090 ) ] ;
@@ -194,7 +194,7 @@ where
194194 out. sort_by ( |a, b| a. range_in_blamed_file . start . cmp ( & b. range_in_blamed_file . start ) ) ;
195195 Ok ( Outcome {
196196 entries : coalesce_blame_entries ( out) ,
197- blob : original_file_blob ,
197+ blob : blamed_file_blob ,
198198 statistics : stats,
199199 } )
200200}
@@ -218,7 +218,7 @@ fn unblamed_to_out(hunks_to_blame: &mut Vec<UnblamedHunk>, out: &mut Vec<BlameEn
218218}
219219
220220/// 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
222222/// behaviour. `libgit2`, as of 2024-09-19, only checks whether two entries are adjacent in the
223223/// blamed file which can result in different blames in certain edge cases. See [the commit][1]
224224/// 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> {
237237 if previous_entry. commit_id == entry. commit_id
238238 && previous_entry. range_in_blamed_file . end == entry. range_in_blamed_file . start
239239 // 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
241241 {
242242 let coalesced_entry = BlameEntry {
243243 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 ,
246245 commit_id : previous_entry. commit_id ,
247246 } ;
248247
@@ -304,7 +303,7 @@ fn blob_changes(
304303 file_path : & BStr ,
305304 stats : & mut Statistics ,
306305) -> 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*.
308307 struct ChangeRecorder {
309308 last_seen_after_end : u32 ,
310309 hunks : Vec < Change > ,
0 commit comments