Re: [PATCH] Add two grep config options
flat view
From: Michael J Gruber <hidden>
Date: 2016-06-15 22:50:55
Junio C Hamano venit, vidit, dixit 26.03.2011 00:25:
Joe Ratterman [off-list ref] writes:quoted
grep.extended-regexp: Enabling this boolean option has the same effect as adding "-E" to all "git grep " instantiations. This can be disabled by specifying "--no-extended-regexp" on a particular call. grep.line-numbers: Enabling this boolean option has the same effect as adding "-n" to all "git grep " instantiations. Signed-off-by: Joe Ratterman <redacted>Thanks. Things to consider: - Apply this patch on top of "master",run "git shortlog v1.7.4..HEAD", store the output somewhere, and imagine reading that 2 months from now. Does a single line in the output about this patch sufficiently tell you what it was about? - Configuration variables are spelled without hyphens between words (you can see "gui.commitmsgwidth" in the context of the patch you sent and notice that it is not "gui.commit-msg-width"). - This will break scripts people have written, knowing that they can rely on "grep" they wrote without giving "-E" from their command line will use BRE, and force them to update the script with --no-extended-regexp for no good reason. Worse yet, there isn't even --no-line-numbers supported to defeat grep.linenumbers configuration to protect such scripts. I understand that some people would feel that the convenience would outweigh the risk of script breakage in this particular case, and I am sympathetic to the cause, but I still have to point it out. Is there anything we can do to mitigate the risk somehow?
This comes up again and again, and I feel that rather than adding config options one by one, we should either allow aliases for standard commands and/or setting default options depending on the mode (ui use vs. scripting use), so to say a companion to "git -c n=v" which allows git config ui.grep "-E -n" I.e. just like "git -c n=v <cmd>" sets up pseudo config before running cmd, our wrapper could augment argv from "ui.<cmd>". We could safeguard scripts from this by - checking istty and - checking env for GIT_PLUMBING and setting the latter in git-sh-setup.sh. After a long migration phase, we could skip the first (fragile) check. Michael