git-grep: fix for initial dashes in expressions
There is no reason to reject initial dashes in git-grep expressions... other than the code not supporting it previously. A new method is introduced to relax the security checks.
This commit is contained in:
@@ -61,3 +61,10 @@ func TestCommandString(t *testing.T) {
|
||||
cmd = NewCommandContextNoGlobals(context.Background(), "url: https://a:b@c/")
|
||||
assert.EqualValues(t, cmd.prog+` "url: https://sanitized-credential@c/"`, cmd.toString(true))
|
||||
}
|
||||
|
||||
func TestGrepOnlyFunction(t *testing.T) {
|
||||
cmd := NewCommand(context.Background(), "anything-but-grep")
|
||||
assert.Panics(t, func() {
|
||||
cmd.AddGitGrepExpression("whatever")
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user