Subject: bug#64140: 29.0.91; C-u M-x grep doesn't work correctly after M-x vc-git-grep

From: Daniel Martín <[email-masked]>
Date: Sun, 18 Jun 2023 15:20:45 +0200

Eli Zaretskii <[email-masked]> writes:

>> Date: Sun, 18 Jun 2023 02:32:28 +0200
>> From:  Daniel Martín via "Bug reports for GNU Emacs,
>>  the Swiss army knife of text editors" <[email-masked]>
>> 
>> Steps to reproduce:
>> 
>> emacs -Q
>> C-x C-f emacs/src/xdisp.c RET
>> M-x vc-git-grep RET
>> Perform any search.
>> Place the point over any symbol, for example, char_can_wrap_before.
>> C-u M-x grep
>> 
>> The suggested grep command to confirm is
>> 
>> git --no-pager char_can_wrap_before *.c
>> 
>> which is incorrect, it should be
>> 
>> grep --color=auto -nH --null -e char_can_wrap_before *.c
>
> You are saying that vc-git-grep should use a separate history
> variable?

Yes, that's one possible solution, but it's probably too late to change
that.  Perhaps there should be a configuration option in the vc package
so users can choose to have a separate history variable for git grep.

grep-default-command already tries to extract different parts of the
command using regular expressions.  We could adapt grep-default-command
so that it handles git grep well, but I don't think that'd be a very
clean or future-proof solution.