Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The line position after "Move to parent" in tig blame. #973

Closed
akr opened this issue Nov 29, 2019 · 0 comments
Closed

The line position after "Move to parent" in tig blame. #973

akr opened this issue Nov 29, 2019 · 0 comments
Labels

Comments

@akr
Copy link

akr commented Nov 29, 2019

I found that "Move to parent" (',' key) in tig blame doesn't set the line position appropriately.

% git init
Initialized empty Git repository in /tmp/h/.git/
% print -l a a a b foo c d d d d d d d d d d d d d d > file
% cat file
a
a
a
b
foo
c
d
d
d
d
d
d
d
d
d
d
d
d
d
d
% git add file; git commit -m 'initial file'
[master (root-commit) 54a3b91] initial file
 1 file changed, 20 insertions(+)
 create mode 100644 file
% print -l a a a a a a a a a a a b bar c > file
% cat file
a
a
a
a
a
a
a
a
a
a
a
b
bar
c
% git add file ; git commit -m 'modified file'
[master e693734] modified file
 1 file changed, 9 insertions(+), 15 deletions(-)
% strace -s 2000 -f -o log /home/src/tig/bin/tig blame file

Then, tig shows following screen.

54a3b91 Tanaka Akira 2019-11-29 20:59 +0900   1│ a
54a3b91 Tanaka Akira 2019-11-29 20:59 +0900   2│ a
54a3b91 Tanaka Akira 2019-11-29 20:59 +0900   3│ a
e693734 Tanaka Akira 2019-11-29 20:59 +0900   4│ a
e693734 Tanaka Akira 2019-11-29 20:59 +0900   5│ a
e693734 Tanaka Akira 2019-11-29 20:59 +0900   6│ a
e693734 Tanaka Akira 2019-11-29 20:59 +0900   7│ a
e693734 Tanaka Akira 2019-11-29 20:59 +0900   8│ a
e693734 Tanaka Akira 2019-11-29 20:59 +0900   9│ a
e693734 Tanaka Akira 2019-11-29 20:59 +0900  10│ a
e693734 Tanaka Akira 2019-11-29 20:59 +0900  11│ a
54a3b91 Tanaka Akira 2019-11-29 20:59 +0900  12│ b
e693734 Tanaka Akira 2019-11-29 20:59 +0900  13│ bar    <------ press "," here
54a3b91 Tanaka Akira 2019-11-29 20:59 +0900  14│ c

I pressed "," (Move to parent) at "bar" line as I noted as above.
Then tig shows follows.

54a3b91 Tanaka Akira 2019-11-29 20:59 +0900   1│ a
54a3b91 Tanaka Akira 2019-11-29 20:59 +0900   2│ a
54a3b91 Tanaka Akira 2019-11-29 20:59 +0900   3│ a
54a3b91 Tanaka Akira 2019-11-29 20:59 +0900   4│ b
54a3b91 Tanaka Akira 2019-11-29 20:59 +0900   5│ foo
54a3b91 Tanaka Akira 2019-11-29 20:59 +0900   6│ c
54a3b91 Tanaka Akira 2019-11-29 20:59 +0900   7│ d
54a3b91 Tanaka Akira 2019-11-29 20:59 +0900   8│ d
54a3b91 Tanaka Akira 2019-11-29 20:59 +0900   9│ d
54a3b91 Tanaka Akira 2019-11-29 20:59 +0900  10│ d
54a3b91 Tanaka Akira 2019-11-29 20:59 +0900  11│ d
54a3b91 Tanaka Akira 2019-11-29 20:59 +0900  12│ d
54a3b91 Tanaka Akira 2019-11-29 20:59 +0900  13│ d      <------- cursor here
54a3b91 Tanaka Akira 2019-11-29 20:59 +0900  14│ d
54a3b91 Tanaka Akira 2019-11-29 20:59 +0900  15│ d
54a3b91 Tanaka Akira 2019-11-29 20:59 +0900  16│ d
54a3b91 Tanaka Akira 2019-11-29 20:59 +0900  17│ d
54a3b91 Tanaka Akira 2019-11-29 20:59 +0900  18│ d
54a3b91 Tanaka Akira 2019-11-29 20:59 +0900  19│ d
54a3b91 Tanaka Akira 2019-11-29 20:59 +0900  20│ d

The cursor line is set at the line 13 as I noted as above.

I intended to change the line "foo" to "bar",
the cursor should be positioned at the line 5.

It seems tig determine the line position in parent commit using git diff -U0
(The function setup_blame_parent_line in src/blame.c).

I checked git diff command invoked by tig.

% grep '"-U0"' log|tail -1                                                                                                                                           
23134 execve("/bin/git", ["git", "diff", "--encoding=UTF-8", "--no-textconv", "--no-ext-diff", "--no-color", "-U0", "54a3b91240752884232d471fae6db09a879fce29:file", "e693734891968f483446c17a7f5a7ffe1433c0dd:file", "--"], 0x7ffc49783b58 /* 61 vars */) = 0
% git diff --encoding=UTF-8 --no-textconv --no-ext-diff --no-color -U0 54a3b91240752884232d471fae6db09a879fce29:file e693734891968f483446c17a7f5a7ffe1433c0dd:file --|cat
diff --git a/file b/file
index dbb7301..45f4569 100644
--- a/file
+++ b/file
@@ -3,0 +4,8 @@ a
+a
+a
+a
+a
+a
+a
+a
+a
@@ -5 +13 @@ b
-foo
+bar
@@ -7,14 +14,0 @@ c
-d
-d
-d
-d
-d
-d
-d
-d
-d
-d
-d
-d
-d
-d

It seems git diff correctly found my intention, "foo" is changed to "bar".
So, I think the current behavior is not intentional.

I compiled tig today.

% /home/src/tig/bin/tig -v               
tig version 2.5.0-1-g6202c60
ncursesw version 6.1.20181013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants