File tree Expand file tree Collapse file tree 3 files changed +71
-0
lines changed Expand file tree Collapse file tree 3 files changed +71
-0
lines changed Original file line number Diff line number Diff line change @@ -333,6 +333,37 @@ fn diff_disparity() {
333333 }
334334}
335335
336+ #[ test]
337+ fn file_that_was_added_in_two_branches ( ) -> gix_testtools:: Result {
338+ let worktree_path = gix_testtools:: scripted_fixture_read_only ( "make_blame_two_roots_repo.sh" ) ?;
339+
340+ let Fixture {
341+ odb,
342+ mut resource_cache,
343+ suspect,
344+ } = Fixture :: for_worktree_path ( worktree_path. to_path_buf ( ) ) ?;
345+
346+ let source_file_name = "file-with-two-roots.txt" ;
347+ let lines_blamed = gix_blame:: file (
348+ & odb,
349+ suspect,
350+ None ,
351+ & mut resource_cache,
352+ source_file_name. into ( ) ,
353+ gix_blame:: Options :: default ( ) ,
354+ ) ?
355+ . entries ;
356+
357+ assert_eq ! ( lines_blamed. len( ) , 4 ) ;
358+
359+ let git_dir = worktree_path. join ( ".git" ) ;
360+ let baseline = Baseline :: collect ( git_dir. join ( "file-with-two-roots.baseline" ) , source_file_name. into ( ) ) ?;
361+
362+ pretty_assertions:: assert_eq!( lines_blamed, baseline) ;
363+
364+ Ok ( ( ) )
365+ }
366+
336367#[ test]
337368fn since ( ) -> gix_testtools:: Result {
338369 let Fixture {
Original file line number Diff line number Diff line change 1+ #! /usr/bin/env bash
2+ set -eu -o pipefail
3+
4+ git init -q
5+ git config --local diff.algorithm histogram
6+
7+ git config merge.ff false
8+
9+ git checkout -q -b main
10+
11+ seq 1 4 > unrelated-file.txt
12+ git add unrelated-file.txt
13+ git commit -q -m c1
14+
15+ seq 1 4 > file-with-two-roots.txt
16+ git add file-with-two-roots.txt
17+ git commit -q -m c2
18+
19+ seq 1 5 > file-with-two-roots.txt
20+ git add file-with-two-roots.txt
21+ git commit -q -m c3
22+
23+ git checkout -b different-branch
24+ git reset --hard HEAD~2
25+
26+ seq 4 6 > file-with-two-roots.txt
27+ git add file-with-two-roots.txt
28+ git commit -q -m c10
29+
30+ seq 4 8 > file-with-two-roots.txt
31+ git add file-with-two-roots.txt
32+ git commit -q -m c11
33+
34+ git checkout main
35+ git merge different-branch || true
36+ seq 1 8 > file-with-two-roots.txt
37+ git add file-with-two-roots.txt
38+ git commit -q -m c20
39+
40+ git blame --porcelain file-with-two-roots.txt > .git/file-with-two-roots.baseline
You can’t perform that action at this time.
0 commit comments