]> git.ipfire.org Git - thirdparty/git.git/commitdiff
Merge branch 'es/grep-require-name-when-needed'
authorJunio C Hamano <gitster@pobox.com>
Mon, 17 Jun 2019 17:15:14 +0000 (10:15 -0700)
committerJunio C Hamano <gitster@pobox.com>
Mon, 17 Jun 2019 17:15:14 +0000 (10:15 -0700)
More parameter validation.

* es/grep-require-name-when-needed:
  grep: fail if call could output and name is null

grep.c

diff --git a/grep.c b/grep.c
index 0d50598acda6f1c41951d1d656ea701114473239..f7c3a5803e8ea0bf2c609e9eeec6764217641cfc 100644 (file)
--- a/grep.c
+++ b/grep.c
@@ -1780,6 +1780,10 @@ static int grep_source_1(struct grep_opt *opt, struct grep_source *gs, int colle
        enum grep_context ctx = GREP_CONTEXT_HEAD;
        xdemitconf_t xecfg;
 
+       if (!opt->status_only && gs->name == NULL)
+               BUG("grep call which could print a name requires "
+                   "grep_source.name be non-NULL");
+
        if (!opt->output)
                opt->output = std_output;