git@vger.kernel.org list mirror (unofficial, one of many)
 help / color / mirror / code / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Jeff King <peff@peff.net>
Cc: "SZEDER Gábor" <szeder.dev@gmail.com>,
	"Sathyajith Bhat" <sathya@sathyasays.com>,
	git@vger.kernel.org
Subject: Re: Segfault in git when using git logs
Date: Tue, 03 Nov 2020 10:34:09 -0800	[thread overview]
Message-ID: <xmqq361qs31a.fsf@gitster.c.googlers.com> (raw)
In-Reply-To: <20201103182102.GA459792@coredump.intra.peff.net> (Jeff King's message of "Tue, 3 Nov 2020 13:21:02 -0500")

Jeff King <peff@peff.net> writes:

> On Tue, Nov 03, 2020 at 11:15:53AM +0100, SZEDER Gábor wrote:
>
>> > > Now, use git log to show commit logs using command
>> > > 
>> > >         git log  --follow -L 1,1:hello.log -- hello.log
>> 
>> While Git should never segfault, no matter what, this is a bogus git
>> invocation to begin with: the second sentence in the description of
>> 'git log -L' clearly states that "You may not give any pathspec
>> limiters", so this command should have errored out from early days,
>> but, unfortunately, it was never enforced.  This also means that '-L'
>> and '--follow' are incompatible, because while the former forbids any
>> pathspecs, the latter requires exactly one; and line-level
>> log does its own rename following anyway.
>
> Thanks for confirming. My "I am not clear how these should interact" was
> really "this does not make any sense to me" in my head, but I was afraid
> that I was missing something. The fact that we document explicitly that
> -L should not be combined with pathspecs makes that much more obvious.
>
>> VS Code should be fixed to call 'git log -L 1,1:hello.log' instead,
>> without '--follow' and without pathspec.
>
> Agreed.
>
> On our side, I don't think it would be _wrong_ to catch and disallow the
> combination. But it may be nicer to them if we continue to quietly
> ignore --follow and the pathspec in that case, for working with older
> versions. (OTOH, if I understand correctly they're segfaulting every
> time VS Code is used with v2.29 now, so they may have to accept it as an
> urgent fix anyway).

So something like this won't harm VS Code more than we currently do,
while telling users what is wrong with their command line?

We may still want the "silently disable follow" at low-level
protection, but that does not give feedback why the end-user option
is silently ignored, so...

 builtin/log.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git c/builtin/log.c w/builtin/log.c
index 9f939e6cdf..8811084f02 100644
--- c/builtin/log.c
+++ w/builtin/log.c
@@ -206,6 +206,13 @@ static void cmd_log_init_finish(int argc, const char **argv, const char *prefix,
 	if (argc > 1)
 		die(_("unrecognized argument: %s"), argv[1]);
 
+	if (rev->line_level_traverse) {
+		if (rev->diffopt.filter)
+			die(_("-L<range>:<file> cannot be used with pathspec"));
+		if (rev->diffopt.flags.follow_renames)
+			die(_("-L<range>:<file> cannot be used with --follow"));
+	}
+
 	memset(&w, 0, sizeof(w));
 	userformat_find_requirements(NULL, &w);
 

  reply	other threads:[~2020-11-03 18:34 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-02 13:59 Sathyajith Bhat
2020-11-02 14:43 ` Jeff King
2020-11-02 18:31   ` Junio C Hamano
2020-11-03 10:15   ` SZEDER Gábor
2020-11-03 11:21     ` Christian Couder
2020-11-03 16:10       ` Elijah Newren
2020-11-03 18:21     ` Jeff King
2020-11-03 18:34       ` Junio C Hamano [this message]
2020-11-03 18:57         ` Jeff King
2020-11-03 20:21           ` Junio C Hamano
2020-11-04 13:31             ` Jeff King
2020-11-04 16:26               ` Junio C Hamano
2020-11-04 17:54             ` Re*: " Junio C Hamano
2020-11-04 19:41               ` Jeff King
2020-11-04 20:16                 ` Junio C Hamano
2020-11-04 20:35                   ` [PATCH] log: diagnose -L used with pathspec as an error Junio C Hamano
2020-11-04 21:03                     ` Jeff King
2020-11-03 18:46 ` Segfault in git when using git logs Derrick Stolee
2020-11-03 18:55   ` Sathyajith Bhat
2020-11-03 19:23     ` Jeff King
2020-11-03 20:07       ` Derrick Stolee
2020-11-03 21:04         ` Derrick Stolee
2020-11-04 15:49           ` Sathyajith Bhat

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

  List information: http://vger.kernel.org/majordomo-info.html

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

  git send-email \
    --in-reply-to=xmqq361qs31a.fsf@gitster.c.googlers.com \
    --to=gitster@pobox.com \
    --cc=git@vger.kernel.org \
    --cc=peff@peff.net \
    --cc=sathya@sathyasays.com \
    --cc=szeder.dev@gmail.com \
    --subject='Re: Segfault in git when using git logs' \
    /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

Code repositories for project(s) associated with this inbox:

	https://80x24.org/mirrors/git.git

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 read-only IMAP folder(s) and NNTP newsgroup(s).