Merge branch 'tg/maint-cache-name-compare' into maint
[gitweb.git] / builtin / grep.c
index 643938d905fb134a1e65e3684e8e5feb06b01a59..29adb0ac9399002b07942711863fa3b353926468 100644 (file)
@@ -600,15 +600,12 @@ static int file_callback(const struct option *opt, const char *arg, int unset)
        if (!patterns)
                die_errno(_("cannot open '%s'"), arg);
        while (strbuf_getline(&sb, patterns, '\n') == 0) {
-               char *s;
-               size_t len;
-
                /* ignore empty line like grep does */
                if (sb.len == 0)
                        continue;
 
-               s = strbuf_detach(&sb, &len);
-               append_grep_pat(grep_opt, s, len, arg, ++lno, GREP_PATTERN);
+               append_grep_pat(grep_opt, sb.buf, sb.len, arg, ++lno,
+                               GREP_PATTERN);
        }
        if (!from_stdin)
                fclose(patterns);
@@ -931,7 +928,7 @@ int cmd_grep(int argc, const char **argv, const char *prefix)
        if (!seen_dashdash) {
                int j;
                for (j = i; j < argc; j++)
-                       verify_filename(prefix, argv[j]);
+                       verify_filename(prefix, argv[j], j == i);
        }
 
        paths = get_pathspec(prefix, argv + i);