Brandon Williams <bmwill@xxxxxxxxxx> writes: > @@ -300,6 +311,10 @@ static int grep_sha1(struct grep_opt *opt, const unsigned char *sha1, > if (opt->relative && opt->prefix_length) { > quote_path_relative(filename + tree_name_len, opt->prefix, &pathbuf); > strbuf_insert(&pathbuf, 0, filename, tree_name_len); > + } else if (super_prefix) { > + strbuf_add(&pathbuf, filename, tree_name_len); > + strbuf_addstr(&pathbuf, super_prefix); > + strbuf_addstr(&pathbuf, filename + tree_name_len); > } else { > strbuf_addstr(&pathbuf, filename); > } > @@ -328,10 +343,13 @@ static int grep_file(struct grep_opt *opt, const char *filename) > { > struct strbuf buf = STRBUF_INIT; > > - if (opt->relative && opt->prefix_length) > + if (opt->relative && opt->prefix_length) { > quote_path_relative(filename, opt->prefix, &buf); > - else > + } else { > + if (super_prefix) > + strbuf_addstr(&buf, super_prefix); > strbuf_addstr(&buf, filename); > + } The above two hunks both assume that the super_prefix option is usable only from the top-level (i.e. opt->prefix_length == 0) and also "--no-full-name" (which is the default) cannot be used. The only invoker that runs "grep" with "--super-prefix" is the "grep" that runs in the superproject, and it will only run us from the top-level of the working tree, so the former assumption is OK. It is a bit unclear to me how the "relative" and "--recurse-submodules" would interact with each other, though.