From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: AS31976 209.132.180.0/23 X-Spam-Status: No, score=-3.8 required=3.0 tests=AWL,BAYES_00, FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by dcvr.yhbt.net (Postfix) with ESMTP id 853691F453 for ; Fri, 18 Jan 2019 10:03:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726448AbfARKDl (ORCPT ); Fri, 18 Jan 2019 05:03:41 -0500 Received: from mout.gmx.net ([212.227.15.19]:59717 "EHLO mout.gmx.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725898AbfARKDl (ORCPT ); Fri, 18 Jan 2019 05:03:41 -0500 Received: from [10.49.182.9] ([95.208.59.217]) by mail.gmx.com (mrgmx001 [212.227.17.190]) with ESMTPSA (Nemesis) id 0MFcg9-1gyRDW3Uv7-00Ei79; Fri, 18 Jan 2019 11:03:19 +0100 Date: Fri, 18 Jan 2019 11:03:02 +0100 (STD) From: Johannes Schindelin X-X-Sender: virtualbox@gitforwindows.org To: Barret Rhoden cc: git@vger.kernel.org, =?UTF-8?Q?=C3=86var_Arnfj=C3=B6r=C3=B0_Bjarmason?= , David Kastrup , Jeff King , Jeff Smith , Junio C Hamano , =?UTF-8?Q?Ren=C3=A9_Scharfe?= , Stefan Beller Subject: Re: [PATCH v2 3/3] blame: add a config option to mark ignored lines In-Reply-To: <20190117202919.157326-4-brho@google.com> Message-ID: References: <20190107213013.231514-1-brho@google.com> <20190117202919.157326-1-brho@google.com> <20190117202919.157326-4-brho@google.com> User-Agent: Alpine 2.21.1 (DEB 209 2017-03-23) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII X-Provags-ID: V03:K1:BlrXY14GKCpLdD95tZqDJX9e8bpmK8xzS0SDR09F1JEeYOmZhvA w/weJ+N2YRJmomLl1cE9kjq0AP4zuh3L81QU/oxt25h71pI2M8hhRzTk+iwiFmumfpB26Pn lWEMuNFjHd/IF62xaTgkcEgjztzZ3HgsuzlVZnvt7ftG0Nk35eqaf0b4R1VKydC7j+IpC5B ukhTmj/RFaCs1fmODJoHQ== X-UI-Out-Filterresults: notjunk:1;V03:K0:8TaXYWuYk0w=:8HD0Jbzaozb/G6GVPKWWsj BDE2tAWoRBkqzPp1Faw4eiQIli+RgThZEg0+xzQOsISK7UxAspeMV9XXUt9nfKOGZaF/OQ+E6 UzozLg3EHv1Sscn6PRswUoKv7X4fBGBS96VW+FxumULqaloeDpWap4z7HpeK0vB2kbYKlaZqc 1lTkctYgfXdHOZOTGHE0EmzAu8yUL5V+zebTr77wE8RrcM2qkMeoHYSIt9Iamnlvmnh7qZj/F kl1ISg16cWAdlPlCBJ0d9FSWBWJrtxRRApI0yly9v7Yo6YZqWWfU+3g8y5OdGdvoJCcVsZD7g VH8zgeA/51XkjE40g+0QhqDbJc21/y0Ia2+w2J+5bcVMNMlX5Iu9gAMF9r4w6CdSZbSHLFu33 cRB0VIXjrsTmZLEMzjwQbGgeM1JTd7tC7nquekSJTxSfAWVKq8PbtA96dIyYiUNKkZkx4ADIc 2Jr9zqsCkEjcxb3T5fPtTDhnZDggDqpNrzWQaiLbPmZ40vk/D7rLXbdvMai5Y9RyJLKgM7Wbs rJsNeJbXneJdu70Wbz4ftdkR6sEBD2qCReAjjKiK+QrHS7hh3iWNTY2p6fDzvo01Ocfs4CjNP coFpWdIMxpZobSQW9w2peU65Z5CWXPiN6b7sKjU+IuvQ5mRwcsmytBHxaD2004I2mgEAShi93 fnboNGmDa4UwHCK0y+UPF62t8n7v00oWvR1YoAr+fK5Uryb+gpiL359JLuli11FNBJEvfdv21 xztSosrs0IOIy4lwod4vZMpI/HnbYuMyJFecj4H5bG5Chl/kPaKBQan7SZ8VpraC0tmMNkgMZ 3gd/qtc6n1OGsTO2ymeE1u2rTx7JV3i3HZSXJYyA4EQMc/dFoM2NW6L5fyyM9nppe4GO40KvB gQo2Z1L2qIYvRurRT0FEhvFDpS4fea2JIdnn5vOz3udGsqXS0SOauQ4ilkgsm+WOjIRqS5/Jx hE0z62/V5jA== Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Hi Barret, On Thu, 17 Jan 2019, Barret Rhoden wrote: > When ignoring commits, the commit that is blamed might not be > responsible for the change. Users might want to know when a particular > line has a potentially inaccurate blame. > > By specifying blame.markIgnoredFiles, each blame line is marked with an > '*'. 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. > > Signed-off-by: Barret Rhoden Again, I cannot comment on blame.c, there are more competent people Cc:ed. But I do have to point out that Git prefers commit messages in the imperative form rather than the present tense (reading the commit message could leave the inclined reader wondering what the patch changes, if Git already does all that). Ciao, Johannes > --- > Documentation/blame-options.txt | 4 +++- > blame.c | 8 +++++++- > blame.h | 1 + > builtin/blame.c | 9 +++++++++ > 4 files changed, 20 insertions(+), 2 deletions(-) > > diff --git a/Documentation/blame-options.txt b/Documentation/blame-options.txt > index 424a63f0b45c..92787ae951ac 100644 > --- a/Documentation/blame-options.txt > +++ b/Documentation/blame-options.txt > @@ -115,7 +115,9 @@ take effect. > change never happened. Lines that were changed or added by an ignored > commit will be blamed on the previous commit that changed that line or > nearby lines. This option may be specified multiple times to ignore > - more than one revision. > + more than one revision. If the `blame.markIgnoredLines` config option > + is set, then lines that were changed by an ignored commit will be > + marked with a `*` in the blame output. > > --ignore-revs-file :: > Ignore revisions listed in `file`, one full SHA-1 hash per line. > diff --git a/blame.c b/blame.c > index 0b91fba2d04c..b1805633fb23 100644 > --- a/blame.c > +++ b/blame.c > @@ -474,7 +474,8 @@ 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->num_lines += next->num_lines; > ent->next = next->next; > blame_origin_decref(next->suspect); > @@ -726,6 +727,8 @@ static void split_overlap(struct blame_entry *split, > int chunk_end_lno; > memset(split, 0, sizeof(struct blame_entry [3])); > > + split[0].ignored = split[1].ignored = split[2].ignored = e->ignored; > + > if (e->s_lno < tlno) { > /* there is a pre-chunk part not blamed on parent */ > split[0].suspect = blame_origin_incref(e->suspect); > @@ -862,6 +865,7 @@ static void blame_chunk(struct blame_entry ***dstq, struct blame_entry ***srcq, > int len = tlno - e->s_lno; > struct blame_entry *n = xcalloc(1, sizeof (struct blame_entry)); > n->suspect = e->suspect; > + n->ignored = e->ignored; > n->lno = e->lno + len; > n->s_lno = e->s_lno + len; > n->num_lines = e->num_lines - len; > @@ -916,6 +920,7 @@ static void blame_chunk(struct blame_entry ***dstq, struct blame_entry ***srcq, > int len = same - e->s_lno; > struct blame_entry *n = xcalloc(1, sizeof (struct blame_entry)); > n->suspect = blame_origin_incref(e->suspect); > + n->ignored = e->ignored; > n->lno = e->lno + len; > n->s_lno = e->s_lno + len; > n->num_lines = e->num_lines - len; > @@ -930,6 +935,7 @@ static void blame_chunk(struct blame_entry ***dstq, struct blame_entry ***srcq, > blame_origin_decref(e->suspect); > e->suspect = blame_origin_incref(parent); > e->s_lno += offset; > + e->ignored = 1; > e->next = ignoredp; > ignoredp = e; > } else { > diff --git a/blame.h b/blame.h > index 086b92915e4b..56aeff582b01 100644 > --- a/blame.h > +++ b/blame.h > @@ -92,6 +92,7 @@ struct blame_entry { > * scanning the lines over and over. > */ > unsigned score; > + int ignored; > }; > > /* > diff --git a/builtin/blame.c b/builtin/blame.c > index 2f9183fb5fbd..8c3c5e435c9c 100644 > --- a/builtin/blame.c > +++ b/builtin/blame.c > @@ -53,6 +53,7 @@ static int show_progress; > static char repeated_meta_color[COLOR_MAXLEN]; > static int coloring_mode; > static const char *ignore_revs_file; > +static int mark_ignored_lines; > > static struct date_mode blame_date_mode = { DATE_ISO8601 }; > static size_t blame_date_width; > @@ -480,6 +481,10 @@ static void emit_other(struct blame_scoreboard *sb, struct blame_entry *ent, int > } > } > > + if (mark_ignored_lines && ent->ignored) { > + length--; > + putchar('*'); > + } > printf("%.*s", length, hex); > if (opt & OUTPUT_ANNOTATE_COMPAT) { > const char *name; > @@ -698,6 +703,10 @@ static int git_blame_config(const char *var, const char *value, void *cb) > } > if (!strcmp(var, "blame.ignorerevsfile")) > return git_config_pathname(&ignore_revs_file, var, value); > + if (!strcmp(var, "blame.markignoredlines")) { > + mark_ignored_lines = git_config_bool(var, value); > + return 0; > + } > if (!strcmp(var, "color.blame.repeatedlines")) { > if (color_parse_mem(value, strlen(value), repeated_meta_color)) > warning(_("invalid color '%s' in color.blame.repeatedLines"), > -- > 2.20.1.321.g9e740568ce-goog > >