Skip to content

Commit 9909d55

Browse files
authored
Use correct line from recursively blamed commit (#1370)
Running tig blame +28 tig-2.5.12 -- src/diff.c and pressing "b" should keep the line containing "const char *diff_argv[] = }" selected. It actually moves the selection somewhere else. This regressed in ca0809d (Fix cursor position after "Move to parent" in blame view, 2019-11-29). That commit only meant to change "," (":back" or ":parent"). When we press "b" (":view-blame"), we want to use the original behavior from ba7c7d3 (Use file and line number information when loading blame for commit, 2009-02-07). Do that. (Note that the behavior fixed by ca0809d regressed in 2280734 (Enable textconv in the blame view and fix blame -L (#1190), 2022-06-03). I have not yet figured out what's going on, but this patch shouldn't make that worse.) Fixes #1369
1 parent 395272f commit 9909d55

File tree

2 files changed

+60
-2
lines changed

2 files changed

+60
-2
lines changed

src/blame.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -373,9 +373,12 @@ blame_go_forward(struct view *view, struct blame *blame, bool parent)
373373

374374
string_ncopy(view->env->ref, id, sizeof(commit->id));
375375
string_ncopy(view->env->file, filename, strlen(filename));
376-
if (parent)
376+
if (parent) {
377377
setup_blame_parent_line(view, blame);
378-
view->env->goto_lineno = view->pos.lineno;
378+
view->env->goto_lineno = view->pos.lineno;
379+
} else {
380+
view->env->goto_lineno = blame->lineno - 1;
381+
}
379382
reload_view(view);
380383
}
381384

test/blame/blob-blame-test

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
#!/bin/sh
2+
3+
. libtest.sh
4+
. libgit.sh
5+
6+
export COLUMNS=200
7+
8+
in_work_dir create_repo_from_tgz "$base_dir/files/scala-js-benchmarks.tgz"
9+
10+
tigrc <<EOF
11+
set line-graphics = ascii
12+
EOF
13+
14+
steps '
15+
# Go to the "clean in deltablue" line.
16+
:36
17+
# Find the commit that added that line.
18+
:view-blame
19+
# Assert that we still select that line.
20+
:save-display recursive-blame.screen
21+
'
22+
23+
test_tig blame project/Build.scala
24+
25+
assert_equals 'recursive-blame.screen' <<EOF
26+
90286e0 Jonas Fonseca 2013-10-14 14:56 -0400 22| "-feature",
27+
90286e0 Jonas Fonseca 2013-10-14 14:56 -0400 23| "-encoding", "utf8"
28+
90286e0 Jonas Fonseca 2013-10-14 14:56 -0400 24| )
29+
90286e0 Jonas Fonseca 2013-10-14 14:56 -0400 25| )
30+
90286e0 Jonas Fonseca 2013-10-14 14:56 -0400 26|
31+
90286e0 Jonas Fonseca 2013-10-14 14:56 -0400 27| lazy val benchmarkSettings = defaultSettings ++ Seq(
32+
90286e0 Jonas Fonseca 2013-10-14 14:56 -0400 28| unmanagedSources in (Compile, packageJS) +=
33+
90286e0 Jonas Fonseca 2013-10-14 14:56 -0400 29| baseDirectory.value / "exports.js"
34+
90286e0 Jonas Fonseca 2013-10-14 14:56 -0400 30| )
35+
90286e0 Jonas Fonseca 2013-10-14 14:56 -0400 31|
36+
90286e0 Jonas Fonseca 2013-10-14 14:56 -0400 32| lazy val parent: Project = Project(
37+
90286e0 Jonas Fonseca 2013-10-14 14:56 -0400 33| id = "parent",
38+
90286e0 Jonas Fonseca 2013-10-14 14:56 -0400 34| base = file("."),
39+
90286e0 Jonas Fonseca 2013-10-14 14:56 -0400 35| settings = projectSettings ++ Seq(
40+
90286e0 Jonas Fonseca 2013-10-14 14:56 -0400 36| name := "Scala.js Benchmarks",
41+
90286e0 Jonas Fonseca 2013-10-14 14:56 -0400 37| publishArtifact in Compile := false,
42+
90286e0 Jonas Fonseca 2013-10-14 14:56 -0400 38|
43+
90286e0 Jonas Fonseca 2013-10-14 14:56 -0400 39| clean := clean.dependsOn(
44+
90286e0 Jonas Fonseca 2013-10-14 14:56 -0400 40| clean in common,
45+
b103989 Jonas Fonseca 2013-10-20 00:23 -0700 41| clean in deltablue,
46+
4edd069 Jonas Fonseca 2013-10-17 20:34 -0400 42| clean in richards,
47+
90286e0 Jonas Fonseca 2013-10-14 14:56 -0400 43| clean in tracer
48+
90286e0 Jonas Fonseca 2013-10-14 14:56 -0400 44| ).value
49+
90286e0 Jonas Fonseca 2013-10-14 14:56 -0400 45| )
50+
90286e0 Jonas Fonseca 2013-10-14 14:56 -0400 46| ).aggregate(
51+
90286e0 Jonas Fonseca 2013-10-14 14:56 -0400 47| common,
52+
b103989 Jonas Fonseca 2013-10-20 00:23 -0700 48| deltablue,
53+
4edd069 Jonas Fonseca 2013-10-17 20:34 -0400 49| richards,
54+
[blame] b103989d59edab3adc312ff5408fa3d344ea0201 changed project/Build.scala - line 41 of 66 74%
55+
EOF

0 commit comments

Comments
 (0)