git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/2] blame: Make --show-name negatable
@ 2022-09-12  5:45 Rene Kita
  2022-09-12  5:45 ` [PATCH 1/2] " Rene Kita
  2022-09-12  5:45 ` [PATCH 2/2] blame: Document that --show-name is negatable Rene Kita
  0 siblings, 2 replies; 7+ messages in thread
From: Rene Kita @ 2022-09-12  5:45 UTC (permalink / raw)
  To: git; +Cc: Rene Kita

With -s git blame does not show author and date, but will show the file name
if the file was renamed some time in the past. With -c git blame will
not show the name, even if the file was renamed, but will show author
and date.

Working with a code base that already uses long lines and has a deep
nested directory structure the output of git blame gets hard to read due
to line wrapping.

While looking for a solution on IRC a user was so nice to gave me a
patch (and permission to submit it) that allows to disable showing of
the file name even if the file was renamed. This allows to show only the
commit id with `git blame -s --no-show-name`.

The second patch only adds this informations to the man page.


Rene Kita (1):
  blame: Document that --show-name is negatable

Øystein Walle (1):
  blame: Make --show-name negatable

 Documentation/git-blame.txt | 2 +-
 builtin/blame.c             | 9 +++++++--
 2 files changed, 8 insertions(+), 3 deletions(-)

-- 
2.37.3.544.g5c9b9c0a4e


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH 1/2] blame: Make --show-name negatable
  2022-09-12  5:45 [PATCH 0/2] blame: Make --show-name negatable Rene Kita
@ 2022-09-12  5:45 ` Rene Kita
  2022-09-12 13:25   ` Øystein Walle
  2022-09-12  5:45 ` [PATCH 2/2] blame: Document that --show-name is negatable Rene Kita
  1 sibling, 1 reply; 7+ messages in thread
From: Rene Kita @ 2022-09-12  5:45 UTC (permalink / raw)
  To: git; +Cc: Øystein Walle

From: Øystein Walle <oystwa@gmail.com>

Signed-off-by: Øystein Walle <oystwa@gmail.com>
---
 builtin/blame.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/builtin/blame.c b/builtin/blame.c
index a9fe8cf7a6..cbaae91a8f 100644
--- a/builtin/blame.c
+++ b/builtin/blame.c
@@ -49,6 +49,7 @@ static int blank_boundary;
 static int incremental;
 static int xdl_opts;
 static int abbrev = -1;
+static int show_name = -1;
 static int no_whole_file_rename;
 static int show_progress;
 static char repeated_meta_color[COLOR_MAXLEN];
@@ -621,7 +622,8 @@ static void find_alignment(struct blame_scoreboard *sb, int *option)
 		if (compute_auto_abbrev)
 			auto_abbrev = update_auto_abbrev(auto_abbrev, suspect);
 		if (strcmp(suspect->path, sb->path))
-			*option |= OUTPUT_SHOW_NAME;
+			if (show_name == -1)
+				*option |= OUTPUT_SHOW_NAME;
 		num = strlen(suspect->path);
 		if (longest_file < num)
 			longest_file = num;
@@ -867,7 +869,7 @@ int cmd_blame(int argc, const char **argv, const char *prefix)
 		OPT_BOOL(0, "show-stats", &show_stats, N_("show work cost statistics")),
 		OPT_BOOL(0, "progress", &show_progress, N_("force progress reporting")),
 		OPT_BIT(0, "score-debug", &output_option, N_("show output score for blame entries"), OUTPUT_SHOW_SCORE),
-		OPT_BIT('f', "show-name", &output_option, N_("show original filename (Default: auto)"), OUTPUT_SHOW_NAME),
+		OPT_BOOL('f', "show-name", &show_name, N_("show original filename (Default: auto)")),
 		OPT_BIT('n', "show-number", &output_option, N_("show original linenumber (Default: off)"), OUTPUT_SHOW_NUMBER),
 		OPT_BIT('p', "porcelain", &output_option, N_("show in a format designed for machine consumption"), OUTPUT_PORCELAIN),
 		OPT_BIT(0, "line-porcelain", &output_option, N_("show porcelain format with per-line commit information"), OUTPUT_PORCELAIN|OUTPUT_LINE_PORCELAIN),
@@ -943,6 +945,9 @@ int cmd_blame(int argc, const char **argv, const char *prefix)
 	revs.diffopt.flags.follow_renames = 0;
 	argc = parse_options_end(&ctx);
 
+	if (show_name == 1)
+		output_option |= OUTPUT_SHOW_NAME;
+
 	prepare_repo_settings(the_repository);
 	the_repository->settings.command_requires_full_index = 0;
 
-- 
2.37.3.544.g5c9b9c0a4e


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH 2/2] blame: Document that --show-name is negatable
  2022-09-12  5:45 [PATCH 0/2] blame: Make --show-name negatable Rene Kita
  2022-09-12  5:45 ` [PATCH 1/2] " Rene Kita
@ 2022-09-12  5:45 ` Rene Kita
  1 sibling, 0 replies; 7+ messages in thread
From: Rene Kita @ 2022-09-12  5:45 UTC (permalink / raw)
  To: git; +Cc: Rene Kita

Signed-off-by: Rene Kita <mail@rkta.de>
---
 Documentation/git-blame.txt | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/Documentation/git-blame.txt b/Documentation/git-blame.txt
index d7a46cc674..75e115f97e 100644
--- a/Documentation/git-blame.txt
+++ b/Documentation/git-blame.txt
@@ -63,7 +63,7 @@ include::blame-options.txt[]
 	of code to have been moved.
 
 -f::
---show-name::
+--[no-]show-name::
 	Show the filename in the original commit.  By default
 	the filename is shown if there is any line that came from a
 	file with a different name, due to rename detection.
-- 
2.37.3.544.g5c9b9c0a4e


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH 1/2] blame: Make --show-name negatable
  2022-09-12  5:45 ` [PATCH 1/2] " Rene Kita
@ 2022-09-12 13:25   ` Øystein Walle
  2022-09-12 16:30     ` Junio C Hamano
  0 siblings, 1 reply; 7+ messages in thread
From: Øystein Walle @ 2022-09-12 13:25 UTC (permalink / raw)
  To: Rene Kita; +Cc: git

That was me! :-)

Not long after I sent you a new link with the patch below, but I suppose
you missed it. My first rough attempt was incomplete, changing the
behavior from on/auto on to auto/off instead of the intended
on/auto/off.

The docs changes look good to me (but should perhaps be squashed into the impl
patch?). Not sure how many of the negatable long options that exist are
actually documented as such, but imho. they should be.

There are no added tests, but there are no tests for -f/--show-name in the
first place and I just didn't get around to writing one...

Øsse

---
 builtin/blame.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/builtin/blame.c b/builtin/blame.c
index a9fe8cf7a6..cbaae91a8f 100644
--- a/builtin/blame.c
+++ b/builtin/blame.c
@@ -49,6 +49,7 @@ static int blank_boundary;
 static int incremental;
 static int xdl_opts;
 static int abbrev = -1;
+static int show_name = -1;
 static int no_whole_file_rename;
 static int show_progress;
 static char repeated_meta_color[COLOR_MAXLEN];
@@ -621,7 +622,8 @@ static void find_alignment(struct blame_scoreboard
*sb, int *option)
         if (compute_auto_abbrev)
             auto_abbrev = update_auto_abbrev(auto_abbrev, suspect);
         if (strcmp(suspect->path, sb->path))
-            *option |= OUTPUT_SHOW_NAME;
+            if (show_name == -1)
+                *option |= OUTPUT_SHOW_NAME;
         num = strlen(suspect->path);
         if (longest_file < num)
             longest_file = num;
@@ -867,7 +869,7 @@ int cmd_blame(int argc, const char **argv, const
char *prefix)
         OPT_BOOL(0, "show-stats", &show_stats, N_("show work cost
statistics")),
         OPT_BOOL(0, "progress", &show_progress, N_("force progress
reporting")),
         OPT_BIT(0, "score-debug", &output_option, N_("show output
score for blame entries"), OUTPUT_SHOW_SCORE),
-        OPT_BIT('f', "show-name", &output_option, N_("show original
filename (Default: auto)"), OUTPUT_SHOW_NAME),
+        OPT_BOOL('f', "show-name", &show_name, N_("show original
filename (Default: auto)")),
         OPT_BIT('n', "show-number", &output_option, N_("show original
linenumber (Default: off)"), OUTPUT_SHOW_NUMBER),
         OPT_BIT('p', "porcelain", &output_option, N_("show in a
format designed for machine consumption"), OUTPUT_PORCELAIN),
         OPT_BIT(0, "line-porcelain", &output_option, N_("show
porcelain format with per-line commit information"),
OUTPUT_PORCELAIN|OUTPUT_LINE_PORCELAIN),
@@ -943,6 +945,9 @@ int cmd_blame(int argc, const char **argv, const
char *prefix)
     revs.diffopt.flags.follow_renames = 0;
     argc = parse_options_end(&ctx);

+    if (show_name == 1)
+        output_option |= OUTPUT_SHOW_NAME;
+
     prepare_repo_settings(the_repository);
     the_repository->settings.command_requires_full_index = 0;

-- 
2.34.1

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH 1/2] blame: Make --show-name negatable
  2022-09-12 13:25   ` Øystein Walle
@ 2022-09-12 16:30     ` Junio C Hamano
  2022-09-13  8:56       ` Øystein Walle
  0 siblings, 1 reply; 7+ messages in thread
From: Junio C Hamano @ 2022-09-12 16:30 UTC (permalink / raw)
  To: Øystein Walle; +Cc: Rene Kita, git

Øystein Walle <oystwa@gmail.com> writes:

> That was me! :-)
>
> Not long after I sent you a new link with the patch below, but I suppose
> you missed it. My first rough attempt was incomplete, changing the
> behavior from on/auto on to auto/off instead of the intended
> on/auto/off.

Not clear to this bystander what exactly is going on.  Is the patch
Rene relayed is your rough attempt that was incomplete?

> The docs changes look good to me (but should perhaps be squashed into the impl
> patch?). Not sure how many of the negatable long options that exist are
> actually documented as such, but imho. they should be.
>
> There are no added tests, but there are no tests for -f/--show-name in the
> first place and I just didn't get around to writing one...

Thanks.  Let's see if we can have an cleaned-up version with tests,
then.



>
> Øsse
>
> ---
>  builtin/blame.c | 9 +++++++--
>  1 file changed, 7 insertions(+), 2 deletions(-)
>
> diff --git a/builtin/blame.c b/builtin/blame.c
> index a9fe8cf7a6..cbaae91a8f 100644
> --- a/builtin/blame.c
> +++ b/builtin/blame.c
> @@ -49,6 +49,7 @@ static int blank_boundary;
>  static int incremental;
>  static int xdl_opts;
>  static int abbrev = -1;
> +static int show_name = -1;
>  static int no_whole_file_rename;
>  static int show_progress;
>  static char repeated_meta_color[COLOR_MAXLEN];
> @@ -621,7 +622,8 @@ static void find_alignment(struct blame_scoreboard
> *sb, int *option)
>          if (compute_auto_abbrev)
>              auto_abbrev = update_auto_abbrev(auto_abbrev, suspect);
>          if (strcmp(suspect->path, sb->path))
> -            *option |= OUTPUT_SHOW_NAME;
> +            if (show_name == -1)
> +                *option |= OUTPUT_SHOW_NAME;
>          num = strlen(suspect->path);
>          if (longest_file < num)
>              longest_file = num;
> @@ -867,7 +869,7 @@ int cmd_blame(int argc, const char **argv, const
> char *prefix)
>          OPT_BOOL(0, "show-stats", &show_stats, N_("show work cost
> statistics")),
>          OPT_BOOL(0, "progress", &show_progress, N_("force progress
> reporting")),
>          OPT_BIT(0, "score-debug", &output_option, N_("show output
> score for blame entries"), OUTPUT_SHOW_SCORE),
> -        OPT_BIT('f', "show-name", &output_option, N_("show original
> filename (Default: auto)"), OUTPUT_SHOW_NAME),
> +        OPT_BOOL('f', "show-name", &show_name, N_("show original
> filename (Default: auto)")),
>          OPT_BIT('n', "show-number", &output_option, N_("show original
> linenumber (Default: off)"), OUTPUT_SHOW_NUMBER),
>          OPT_BIT('p', "porcelain", &output_option, N_("show in a
> format designed for machine consumption"), OUTPUT_PORCELAIN),
>          OPT_BIT(0, "line-porcelain", &output_option, N_("show
> porcelain format with per-line commit information"),
> OUTPUT_PORCELAIN|OUTPUT_LINE_PORCELAIN),
> @@ -943,6 +945,9 @@ int cmd_blame(int argc, const char **argv, const
> char *prefix)
>      revs.diffopt.flags.follow_renames = 0;
>      argc = parse_options_end(&ctx);
>
> +    if (show_name == 1)
> +        output_option |= OUTPUT_SHOW_NAME;
> +
>      prepare_repo_settings(the_repository);
>      the_repository->settings.command_requires_full_index = 0;

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 1/2] blame: Make --show-name negatable
  2022-09-12 16:30     ` Junio C Hamano
@ 2022-09-13  8:56       ` Øystein Walle
  2022-09-13  9:08         ` Rene Kita
  0 siblings, 1 reply; 7+ messages in thread
From: Øystein Walle @ 2022-09-13  8:56 UTC (permalink / raw)
  To: gitster; +Cc: git, mail, oystwa

Hi, Junio

> Not clear to this bystander what exactly is going on.  Is the patch
> Rene relayed is your rough attempt that was incomplete?

Correct! I am the nice IRC that was mentioned in the cover letter. My
improved patch is the one in the e-mail you responded to, apart from
GMail's text wrapping that was unaware of until now.

> Thanks.  Let's see if we can have an cleaned-up version with tests,
> then.

I can send a corrected (and correctly formatted patch) for review,
optionally with the docs squashed in with Rene's permission. Maybe Rene
would like to take a stab at writing tests? I am in the process of
moving house and my usual workstation is not exactly online, so it'll be
a while.

Øsse

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 1/2] blame: Make --show-name negatable
  2022-09-13  8:56       ` Øystein Walle
@ 2022-09-13  9:08         ` Rene Kita
  0 siblings, 0 replies; 7+ messages in thread
From: Rene Kita @ 2022-09-13  9:08 UTC (permalink / raw)
  To: Øystein Walle; +Cc: gitster, git

On Tue, Sep 13, 2022 at 10:56:31AM +0200, Øystein Walle wrote:
> Hi, Junio
> 
> > Not clear to this bystander what exactly is going on.  Is the patch
> > Rene relayed is your rough attempt that was incomplete?
> 
> Correct! I am the nice IRC that was mentioned in the cover letter. My
> improved patch is the one in the e-mail you responded to, apart from
> GMail's text wrapping that was unaware of until now.

That's my fault. I saw the corrected patch, but somehow used the old
one. Sorry!


> > Thanks.  Let's see if we can have an cleaned-up version with tests,
> > then.
> 
> I can send a corrected (and correctly formatted patch) for review,
> optionally with the docs squashed in with Rene's permission.

Of course.

> Maybe Rene would like to take a stab at writing tests? I am in the
> process of moving house and my usual workstation is not exactly
> online, so it'll be a while.

Yes, I can write a test. Will need to investigate, never worked with the
code base.

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2022-09-13  9:08 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-09-12  5:45 [PATCH 0/2] blame: Make --show-name negatable Rene Kita
2022-09-12  5:45 ` [PATCH 1/2] " Rene Kita
2022-09-12 13:25   ` Øystein Walle
2022-09-12 16:30     ` Junio C Hamano
2022-09-13  8:56       ` Øystein Walle
2022-09-13  9:08         ` Rene Kita
2022-09-12  5:45 ` [PATCH 2/2] blame: Document that --show-name is negatable Rene Kita

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).