Re: How can I search git log with ceratin keyword but without the other keyword?

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

 



Hi, Peff

Thank you for your help.

>I think this is the thing I was mentioning earlier. That negative
>lookahead means the second one wouldn't match "comments", but it would
>still match "2020.04.12" or "ng". So it won't do what you want.
You have good foresight. :)

>The natural thing to me would be the equivalent of:
>  git grep -e 12 --and --not -e comments
Yes, I intend to achieve this goal. Sorry for misleading you.

>I can't think of a way to do what you want just a regex, but maybe
>somebody more clever than me can.
>But none of that is exposed via the command-line of "git log". I think
>it would be possible to do so, but I'm not sure how tricky it would be
>(certainly one complication is that "--not" already means something else
>there, but presumably we could have "--grep-and", "--grep-not", etc).
Thank you for your patience.
Thanks to your help, I have a better understanding of this matter.

Best Regards
sunshilong

On Fri, Jul 17, 2020 at 2:33 PM Jeff King <peff@xxxxxxxx> wrote:
>
> On Fri, Jul 17, 2020 at 09:45:26AM +0800, 孙世龙 sunshilong wrote:
>
> > I wonder why this command doesn't work well.
> > I intend to find the comment with the keyword "12" but without "comments"
> > whereas the output is something like this:
> >
> > git log --perl-regexp --all-match --grep=12 --grep '\b(?!comments\b)\w+'
> > commit f5b6c3e33bd2559d6976b1d589071a5928992601
> > Author: sunshilong <sunshilong369@xxxxxxxxx>
> > Date:   2020-04-12 23:00:29 +0800
> >
> >     comments 2020.04.12 ng
>
> I think this is the thing I was mentioning earlier. That negative
> lookahead means the second one wouldn't match "comments", but it would
> still match "2020.04.12" or "ng". So it won't do what you want.
>
> I can't think of a way to do what you want just a regex, but maybe
> somebody more clever than me can.
>
> The natural thing to me would be the equivalent of:
>
>   git grep -e 12 --and --not -e comments
>
> The underlying grep machinery in Git understands how to compose multiple
> patterns like this, and the command above really does work (though of
> course it is searching for lines in a file and not commit messages).
>
> But none of that is exposed via the command-line of "git log". I think
> it would be possible to do so, but I'm not sure how tricky it would be
> (certainly one complication is that "--not" already means something else
> there, but presumably we could have "--grep-and", "--grep-not", etc).
>
> -Peff




[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