git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jeff King <peff@peff.net>
To: Matthew Booth <mbooth@redhat.com>
Cc: git@vger.kernel.org
Subject: Re: [BUG] git log -L ... -s does not suppress diff output
Date: Mon, 25 Feb 2019 12:18:17 -0500	[thread overview]
Message-ID: <20190225171817.GA17524@sigill.intra.peff.net> (raw)
In-Reply-To: <CAEkQehdFu5zM4AY3ihN0pn1aCNEomY0WV07pryfAB45JN-tDDA@mail.gmail.com>

On Mon, Feb 25, 2019 at 05:03:50PM +0000, Matthew Booth wrote:

> Example output:
> 
> =========
> $ git --version
> git version 2.20.1
> 
> $ git log -L 2957,3107:nova/compute/manager.py -s
> commit 35ce77835bb271bad3c18eaf22146edac3a42ea0
> <snip>
> 
> diff --git a/nova/compute/manager.py b/nova/compute/manager.py
> --- a/nova/compute/manager.py
> +++ b/nova/compute/manager.py
> @@ -2937,152 +2921,151 @@
>      def rebuild_instance(self, context, instance, orig_image_ref, image_ref,
>                           injected_files, new_pass, orig_sys_metadata,
> <snip>
> =========

At first I wondered why you would want to do this, since the point of -L
is to walk through that diff. But I suppose you might want to see just
the commits, without the actual patch, and that's what "-s" ought to do.

> git log docs suggest it should not do this:
> 
>        -s, --no-patch
>            Suppress diff output. Useful for commands like git show
> that show the patch by default, or to cancel
>            the effect of --patch.
> 
> Couldn't find anything in a search of the archives of this mailing
> list, although that's obviously far from conclusive. Seems to be
> longstanding, as it was mentioned on StackOverflow back in 2015:

I think the issue is just that "-L" follows a very different code path
than the normal diff generator. Perhaps something like this helps?

diff --git a/line-log.c b/line-log.c
index 63df51a08f..ed46a3a493 100644
--- a/line-log.c
+++ b/line-log.c
@@ -1106,7 +1106,8 @@ int line_log_print(struct rev_info *rev, struct commit *commit)
 	struct line_log_data *range = lookup_line_range(rev, commit);
 
 	show_log(rev);
-	dump_diff_hacky(rev, range);
+	if (!(rev->diffopt.output_format & DIFF_FORMAT_NO_OUTPUT))
+		dump_diff_hacky(rev, range);
 	return 1;
 }
 

-Peff

  reply	other threads:[~2019-02-25 17:18 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-02-25 17:03 [BUG] git log -L ... -s does not suppress diff output Matthew Booth
2019-02-25 17:18 ` Jeff King [this message]
2019-02-25 17:32   ` [PATCH] line-log: suppress diff output with "-s" Jeff King
2019-02-25 17:59     ` SZEDER Gábor
2019-02-25 18:55       ` Jeff King
2019-02-25 18:46   ` [BUG] git log -L ... -s does not suppress diff output Randall S. Becker

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190225171817.GA17524@sigill.intra.peff.net \
    --to=peff@peff.net \
    --cc=git@vger.kernel.org \
    --cc=mbooth@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).