Re: Segfault in git when using git logs

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Jeff King <peff@xxxxxxxx> 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);
 




[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux