summaryrefslogtreecommitdiff
path: root/blame.c
diff options
context:
space:
mode:
authorBarret Rhoden <brho@google.com>2019-05-15 17:45:00 -0400
committerJunio C Hamano <gitster@pobox.com>2019-05-16 11:36:23 +0900
commit8934ac8c92a1dc805f7bbd86cbc251ade66e1161 (patch)
tree47df762fd15df5c043f9adf498984a167c306765 /blame.c
parentae3f36dea16e51041c56ba9ed6b38380c8421816 (diff)
downloadgit-8934ac8c92a1dc805f7bbd86cbc251ade66e1161.tar.gz
blame: add config options for the output of ignored or unblamable lines
When ignoring commits, the commit that is blamed might not be responsible for the change, due to the inaccuracy of our heuristic. Users might want to know when a particular line has a potentially inaccurate blame. Furthermore, guess_line_blames() may fail to find any parent commit for a given line touched by an ignored commit. Those 'unblamable' lines remain blamed on an ignored commit. Users might want to know if a line is unblamable so that they do not spend time investigating a commit they know is uninteresting. This patch adds two config options to mark these two types of lines in the output of blame. The first option can identify ignored lines by specifying blame.markIgnoredLines. When this option is set, each blame line that was blamed on a commit other than the ignored commit is marked with a '?'. For example: 278b6158d6fdb (Barret Rhoden 2016-04-11 13:57:54 -0400 26) appears as: ?278b6158d6fd (Barret Rhoden 2016-04-11 13:57:54 -0400 26) where the '?' is placed before the commit, and the hash has one fewer characters. Sometimes we are unable to even guess at what ancestor commit touched a line. These lines are 'unblamable.' The second option, blame.markUnblamableLines, will mark the line with '*'. For example, say we ignore e5e8d36d04cbe, yet we are unable to blame this line on another commit: e5e8d36d04cbe (Barret Rhoden 2016-04-11 13:57:54 -0400 26) appears as: *e5e8d36d04cb (Barret Rhoden 2016-04-11 13:57:54 -0400 26) When these config options are used together, every line touched by an ignored commit will be marked with either a '?' or a '*'. Signed-off-by: Barret Rhoden <brho@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'blame.c')
-rw-r--r--blame.c14
1 files changed, 13 insertions, 1 deletions
diff --git a/blame.c b/blame.c
index c57d7a3632..472ee67ae2 100644
--- a/blame.c
+++ b/blame.c
@@ -479,7 +479,9 @@ void blame_coalesce(struct blame_scoreboard *sb)
for (ent = sb->ent; ent && (next = ent->next); ent = next) {
if (ent->suspect == next->suspect &&
- ent->s_lno + ent->num_lines == next->s_lno) {
+ ent->s_lno + ent->num_lines == next->s_lno &&
+ ent->ignored == next->ignored &&
+ ent->unblamable == next->unblamable) {
ent->num_lines += next->num_lines;
ent->next = next->next;
blame_origin_decref(next->suspect);
@@ -729,8 +731,14 @@ static void split_overlap(struct blame_entry *split,
struct blame_origin *parent)
{
int chunk_end_lno;
+ int i;
memset(split, 0, sizeof(struct blame_entry [3]));
+ for (i = 0; i < 3; i++) {
+ split[i].ignored = e->ignored;
+ split[i].unblamable = e->unblamable;
+ }
+
if (e->s_lno < tlno) {
/* there is a pre-chunk part not blamed on parent */
split[0].suspect = blame_origin_incref(e->suspect);
@@ -851,6 +859,8 @@ static struct blame_entry *split_blame_at(struct blame_entry *e, int len,
struct blame_entry *n = xcalloc(1, sizeof(struct blame_entry));
n->suspect = new_suspect;
+ n->ignored = e->ignored;
+ n->unblamable = e->unblamable;
n->lno = e->lno + len;
n->s_lno = e->s_lno + len;
n->num_lines = e->num_lines - len;
@@ -939,12 +949,14 @@ static void ignore_blame_entry(struct blame_entry *e,
blame_origin_incref(e->suspect));
}
if (line_blames[i].is_parent) {
+ e->ignored = 1;
blame_origin_decref(e->suspect);
e->suspect = blame_origin_incref(parent);
e->s_lno = line_blames[i - entry_len + 1].s_lno;
e->next = *ignoredp;
*ignoredp = e;
} else {
+ e->unblamable = 1;
/* e->s_lno is already in the target's address space. */
e->next = *diffp;
*diffp = e;