Skip to content

Conversation

koutcher
Copy link
Collaborator

@koutcher koutcher commented May 26, 2022

Fixes #978
Fixes #1189

@koutcher koutcher force-pushed the blame-porcelain branch 2 times, most recently from ee41e0c to db4a6b4 Compare May 26, 2022 14:41
NEWS.adoc Outdated
@@ -15,6 +15,7 @@ Bug fixes:
- Fix cursor behaviour during staging. (#842, #1028)
- Fix navigation in split tree view.
- Enable textconv in the stage view.
- Change the blame view to use porcelain. (#978, #1189)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure if porcelain vs. incremental is relevant for users. I'd probably say something like

The blame view now honors the textconv option and blame flags like -L.

{
if (!buf) {
const char *blame_argv[] = {
"git", "blame", encoding_arg, "%(blameargs)", "--incremental",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The implementation looks solid. I'm wondering though, is it really necessary to drop --incremental to support -L and --textconv?

Probably not a huge loss although incremental mode can be nice.
In theory git blame --incremental -C +123 could try to find the commit that introduced line 123 first, but that's not what happens today.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your review @krobelus. The --incremental and -p (--porcelain) outputs are actually much closer than their names let us presage. With --incremental, only the blame information is present, with --porcelain you have also the lines from the blamed file. The original 2-pass processing doesn't allow to support textconv as Git does not provide any facility to process a random file with textconv. Supporting -L would also be much more difficult.
Despite me breaking it once already, I completely overlooked the blame -C case. Hopefully this time, tig blame -C still works as before. It could be worth adding a test case for it one day.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's fine as-is but if anyone cares about blame annotations
appearing incrementally (maybe we should ask on the Git list), we could
keep the --incremental code path for cases when neither textconv nor -L
is used. Doesn't seem worth the complexity.

With a hypothetical --incremental --porcelain we could get both features but Git doesn't support that combination of options.

@koutcher koutcher force-pushed the blame-porcelain branch 2 times, most recently from eba74f1 to d0eb570 Compare June 1, 2022 18:32
Change the blame view to use the porcelain output rather than loading
the file and adding blame information based on the incremental output.

Fixes jonas#978
Fixes jonas#1189

Reviewed-by: Johannes Altmanninger <aclopte@gmail.com>
@koutcher koutcher merged commit 2280734 into jonas:master Jun 3, 2022
@krobelus
Copy link
Contributor

krobelus commented Jun 5, 2022

I just realized this introduced a regression: we no longer jump to the blamed line

To reproduce run

tig show 2280734104fd362a1188b0678109e01cdb9322cf +46

and type b.

@koutcher
Copy link
Collaborator Author

koutcher commented Jun 5, 2022

Good catch, the goto_lineno has gone with the bathwater, I'll put it back.

koutcher added a commit that referenced this pull request Jun 5, 2022
Regression introduced by #1190 in 2280734.

Reported-by: Johannes Altmanninger <aclopte@gmail.com>
@koutcher koutcher deleted the blame-porcelain branch February 6, 2025 18:18
@koutcher koutcher restored the blame-porcelain branch February 6, 2025 18:32
krobelus added a commit to krobelus/tig that referenced this pull request Mar 21, 2025
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).

Commit ca0809d was only about "," (":back" or ":parent").  When we press
"b" (":view-blame"), we want to use the old behavior (originally added in
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 (jonas#1190), 2022-06-03).  I have
not yet figured out what's going on, but this patch shouldn't make that worse.)

Fixes jonas#1369
krobelus added a commit to krobelus/tig that referenced this pull request Mar 22, 2025
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 (jonas#1190), 2022-06-03).  I have
not yet figured out what's going on, but this patch shouldn't make that worse.)

Fixes jonas#1369
krobelus added a commit to krobelus/tig that referenced this pull request Mar 22, 2025
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 (jonas#1190), 2022-06-03).  I have
not yet figured out what's going on, but this patch shouldn't make that worse.)

Fixes jonas#1369
koutcher pushed a commit that referenced this pull request Apr 11, 2025
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

blame does not honor textconv (but diff does) Display only the specified range when blaming
2 participants