git/list[1] front-page[2] threads[3] people[4] search[5] about
 

RE: [BUG] git log -L ... -s does not suppress diff output

From
Randall S. Becker <rsbecker@nexbridge.com>
Date
Feb 25, 2019, 18:46 UTC
Message-ID
<001701d4cd3a$6441d420$2cc57c60$@nexbridge.com>
In-Reply-To
<20190225171817.GA17524@sigill.intra.peff.net>
On February 25, 2019 12:18, Jeff King wrote:
Show 56 quoted lines
> To: Matthew Booth <mbooth@redhat.com>
> Cc: git@vger.kernel.org
> Subject: Re: [BUG] git log -L ... -s does not suppress diff output
> 
> 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;
>  }

I hit this about 6 months ago while trying to show off git to some colleagues - it was on 2.8.5. Sadly I forgot about it. Glad it came back. Thanks.

Previous: Jeff King
Message 6 of 6 in “[BUG] git log -L ... -s does not suppress diff output”
  1. Matthew BoothFeb 25, 2019
  2. Jeff KingFeb 25, 2019
  3. line-log: suppress diff output with "-s"Jeff King, Feb 25, 2019
  4. SZEDER GáborFeb 25, 2019
  5. Jeff KingFeb 25, 2019
  6. Randall S. BeckerFeb 25, 2019

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.