Commit f9ee2fcd authored by Brandon Williams's avatar Brandon Williams Committed by Junio C Hamano

grep: recurse in-process using 'struct repository'

Convert grep to use 'struct repository' which enables recursing into
submodules to be handled in-process.
Signed-off-by: default avatarBrandon Williams <bmwill@google.com>
Signed-off-by: default avatarJunio C Hamano <gitster@pobox.com>
parent 2184d4ba
......@@ -95,13 +95,6 @@ OPTIONS
<tree> option the prefix of all submodule output will be the name of
the parent project's <tree> object.
--parent-basename <basename>::
For internal use only. In order to produce uniform output with the
--recurse-submodules option, this option can be used to provide the
basename of a parent's <tree> object to a submodule so the submodule
can prefix its output with the parent's name rather than the SHA1 of
the submodule.
-a::
--text::
Process binary files as if they were text.
......
This diff is collapsed.
......@@ -417,7 +417,6 @@ static inline enum object_type object_type(unsigned int mode)
#define GIT_WORK_TREE_ENVIRONMENT "GIT_WORK_TREE"
#define GIT_PREFIX_ENVIRONMENT "GIT_PREFIX"
#define GIT_SUPER_PREFIX_ENVIRONMENT "GIT_INTERNAL_SUPER_PREFIX"
#define GIT_TOPLEVEL_PREFIX_ENVIRONMENT "GIT_INTERNAL_TOPLEVEL_PREFIX"
#define DEFAULT_GIT_DIR_ENVIRONMENT ".git"
#define DB_ENVIRONMENT "GIT_OBJECT_DIRECTORY"
#define INDEX_ENVIRONMENT "GIT_INDEX_FILE"
......
......@@ -392,7 +392,7 @@ static struct cmd_struct commands[] = {
{ "fsck-objects", cmd_fsck, RUN_SETUP },
{ "gc", cmd_gc, RUN_SETUP },
{ "get-tar-commit-id", cmd_get_tar_commit_id },
{ "grep", cmd_grep, RUN_SETUP_GENTLY | SUPPORT_SUPER_PREFIX },
{ "grep", cmd_grep, RUN_SETUP_GENTLY },
{ "hash-object", cmd_hash_object },
{ "help", cmd_help },
{ "index-pack", cmd_index_pack, RUN_SETUP_GENTLY },
......
......@@ -1927,16 +1927,6 @@ void grep_source_init(struct grep_source *gs, enum grep_source_type type,
case GREP_SOURCE_FILE:
gs->identifier = xstrdup(identifier);
break;
case GREP_SOURCE_SUBMODULE:
if (!identifier) {
gs->identifier = NULL;
break;
}
/*
* FALL THROUGH
* If the identifier is non-NULL (in the submodule case) it
* will be a SHA1 that needs to be copied.
*/
case GREP_SOURCE_OID:
gs->identifier = oiddup(identifier);
break;
......@@ -1959,7 +1949,6 @@ void grep_source_clear_data(struct grep_source *gs)
switch (gs->type) {
case GREP_SOURCE_FILE:
case GREP_SOURCE_OID:
case GREP_SOURCE_SUBMODULE:
FREE_AND_NULL(gs->buf);
gs->size = 0;
break;
......@@ -2030,8 +2019,6 @@ static int grep_source_load(struct grep_source *gs)
return grep_source_load_oid(gs);
case GREP_SOURCE_BUF:
return gs->buf ? 0 : -1;
case GREP_SOURCE_SUBMODULE:
break;
}
die("BUG: invalid grep_source type to load");
}
......
......@@ -193,7 +193,6 @@ struct grep_source {
GREP_SOURCE_OID,
GREP_SOURCE_FILE,
GREP_SOURCE_BUF,
GREP_SOURCE_SUBMODULE,
} type;
void *identifier;
......
......@@ -1027,7 +1027,7 @@ const char *setup_git_directory_gently(int *nongit_ok)
{
static struct strbuf cwd = STRBUF_INIT;
struct strbuf dir = STRBUF_INIT, gitdir = STRBUF_INIT;
const char *prefix, *env_prefix;
const char *prefix;
/*
* We may have read an incomplete configuration before
......@@ -1085,16 +1085,6 @@ const char *setup_git_directory_gently(int *nongit_ok)
die("BUG: unhandled setup_git_directory_1() result");
}
/*
* NEEDSWORK: This was a hack in order to get ls-files and grep to have
* properly formated output when recursing submodules. Once ls-files
* and grep have been changed to perform this recursing in-process this
* needs to be removed.
*/
env_prefix = getenv(GIT_TOPLEVEL_PREFIX_ENVIRONMENT);
if (env_prefix)
prefix = env_prefix;
if (prefix)
setenv(GIT_PREFIX_ENVIRONMENT, prefix, 1);
else
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment