-
Notifications
You must be signed in to change notification settings - Fork 614
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
Blame an unstaged deletion #1008
Comments
What about something like this instead ? diff --git a/src/stage.c b/src/stage.c
index 565c946..28d4060 100644
--- a/src/stage.c
+++ b/src/stage.c
@@ -444,7 +444,10 @@ stage_request(struct view *view, enum request request, struct line *line)
string_ncopy(view->env->file, file, strlen(file));
}
- view->env->ref[0] = 0;
+ if (line->type == LINE_DIFF_DEL)
+ string_copy(view->env->ref, "HEAD");
+ else
+ view->env->ref[0] = 0;
view->env->goto_lineno = diff_get_lineno(view, line);
if (view->env->goto_lineno > 0)
view->env->goto_lineno--; |
krobelus
added a commit
to krobelus/tig
that referenced
this issue
Apr 29, 2020
When starting a blame in the stage view on a deleted line, it seems appropriate to find the commit that added the line. To this end, instead of starting the blame view from the working tree state of a file, use the version at HEAD, which still has the deleted line (unless the line was only just staged). Since we want to visit the line before application of the stage view's diff, diff_get_lineno does not work because it computes the one after diff application. Introduce diff_get_old_lineno to get the correct line number. This works for both staged and unstaged deletions. However, when a file has both staged and unstaged hunks, then blaming an unstaged deletion may jump to the wrong line number because only the unstaged diff is considered. Closes jonas#1008
krobelus
added a commit
to krobelus/tig
that referenced
this issue
Apr 29, 2020
When starting a blame in the stage view on a deleted line, it seems appropriate to find the commit that added the line. To this end, instead of starting the blame view from the working tree state of a file, use the version at HEAD, which still has the deleted line (unless the line was only just staged). Since we want to visit the line before application of the stage view's diff, diff_get_lineno does not work because it computes the one after diff application. Introduce diff_get_old_lineno to get the correct line number. This works for both staged and unstaged deletions. However, when a file has both staged and unstaged hunks, then blaming an unstaged deletion may jump to the wrong line number because only the unstaged diff is considered. Closes jonas#1008
krobelus
added a commit
to krobelus/tig
that referenced
this issue
Apr 29, 2020
When starting a blame in the stage view on a deleted line, it seems appropriate to find the commit that added the line. To this end, instead of starting the blame view from the working tree state of a file, use the version at HEAD, which still has the deleted line (unless the line was only just staged). Since we want to visit the line before application of the stage view's diff, diff_get_lineno does not work because it computes the one after diff application. Introduce diff_get_old_lineno to get the correct line number. This works for both staged and unstaged deletions. However, when a file has both staged and unstaged hunks, then blaming an unstaged deletion may jump to the wrong line number because only the unstaged diff is considered. Closes jonas#1008
krobelus
added a commit
to krobelus/tig
that referenced
this issue
Apr 30, 2020
When starting a blame in the stage view on a deleted line, it seems appropriate to find the commit that added the line. To this end, instead of starting the blame view from the working tree state of a file, use the version at HEAD, which still has the deleted line (unless the line was only just staged). Since we want to visit the line before application of the stage view's diff, diff_get_lineno does not work because it computes the one after diff application. Introduce diff_get_old_lineno to get the correct line number. This works for both staged and unstaged deletions. However, when a file has both staged and unstaged hunks, then blaming an unstaged deletion may jump to the wrong line number because only the unstaged diff is considered. Closes jonas#1008
krobelus
added a commit
to krobelus/tig
that referenced
this issue
May 1, 2020
When starting a blame in the stage view on a deleted line, it seems appropriate to find the commit that added the line. To this end, instead of starting the blame view from the working-tree-state of a file, use the version at HEAD, which still has the deleted line (unless the line was only just staged). Compute the position of the deleted line to start the blame view there. Closes jonas#1008
krobelus
added a commit
to krobelus/tig
that referenced
this issue
May 2, 2020
When starting a blame in the stage view on a deleted line, it seems appropriate to find the commit that added the line. To this end, instead of starting the blame view from the working-tree-state of a file, use the version at HEAD, which still has the deleted line (unless the line was only just staged). Compute the position of the deleted line to start the blame view there. Closes jonas#1008
krobelus
added a commit
to krobelus/tig
that referenced
this issue
May 24, 2020
When starting a blame in the stage view on a deleted line, it seems appropriate to find the commit that added the line. To this end, instead of starting the blame view from the working-tree-state of a file, use the version at HEAD, which still has the deleted line (unless the line was only just staged). Compute the position of the deleted line to start the blame view there. Closes jonas#1008
krobelus
added a commit
to krobelus/tig
that referenced
this issue
May 25, 2020
When starting a blame in the stage view on a deleted line, it seems appropriate to find the commit that added the line. To this end, instead of starting the blame view from the working-tree-state of a file, use the version at HEAD, which still has the deleted line (unless the line was only just staged). Compute the position of the deleted line to start the blame view there. Closes jonas#1008
koutcher
pushed a commit
that referenced
this issue
Dec 13, 2020
When starting a blame in the stage view on a deleted line, it seems appropriate to find the commit that added the line. To this end, instead of starting the blame view from the working-tree-state of a file, use the version at HEAD, which still has the deleted line (unless the line was only just staged). Compute the position of the deleted line to start the blame view there. Closes #1008
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I often want to find the commit that introduced a line which is deleted in the working tree or index.
Mostly for finding the right target for a fixup.
Fugitive has spoiled me in this regard because I can press
o
on a deleted line followed by:Gblame
to see which commit added the line.For Tig, I think it would make sense to press
b
on a not-yet-committed line deletion in the diff view to do the same. Currently those lines will not show up in the blame view becauseview-blame
does a blame with respect to the working tree. I wrote this patch to make the blame start atHEAD
, which still has the lines that I deleted later. The starting cursor position is usually not too far from it, but can't be accurate in general because line numbers don't match the ones in the work tree.I'm wondering if this is a reasonable change, or if there is maybe another way to do this.
I think the proper fix would consist of invokinggit blame
once to find out which commit deleted the line at the cursor, and then showing the blame view with that commit and the correct line number.The text was updated successfully, but these errors were encountered: