diff options
| author | Junio C Hamano <gitster@pobox.com> | 2017-01-18 15:12:11 -0800 |
|---|---|---|
| committer | Junio C Hamano <gitster@pobox.com> | 2017-01-18 15:12:11 -0800 |
| commit | 55d128ae06b7b82f867961b677984620612a201c (patch) | |
| tree | 5628d92c5a897c1738ae99b360d303a2ac62409e /grep.c | |
| parent | ffac48d093d4b518a0cc0e8bf1b7cb53e0c3d7a2 (diff) | |
| parent | e6fac7f3d3e313a93fe9b1243917669267b33153 (diff) | |
| download | git-55d128ae06b7b82f867961b677984620612a201c.tar.gz | |
Merge branch 'bw/grep-recurse-submodules'
"git grep" has been taught to optionally recurse into submodules.
* bw/grep-recurse-submodules:
grep: search history of moved submodules
grep: enable recurse-submodules to work on <tree> objects
grep: optionally recurse into submodules
grep: add submodules as a grep source type
submodules: load gitmodules file from commit sha1
submodules: add helper to determine if a submodule is initialized
submodules: add helper to determine if a submodule is populated
real_path: canonicalize directory separators in root parts
real_path: have callers use real_pathdup and strbuf_realpath
real_path: create real_pathdup
real_path: convert real_path_internal to strbuf_realpath
real_path: resolve symlinks by hand
Diffstat (limited to 'grep.c')
| -rw-r--r-- | grep.c | 16 |
1 files changed, 15 insertions, 1 deletions
@@ -1735,12 +1735,23 @@ 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_SHA1: gs->identifier = xmalloc(20); hashcpy(gs->identifier, identifier); break; case GREP_SOURCE_BUF: gs->identifier = NULL; + break; } } @@ -1760,6 +1771,7 @@ void grep_source_clear_data(struct grep_source *gs) switch (gs->type) { case GREP_SOURCE_FILE: case GREP_SOURCE_SHA1: + case GREP_SOURCE_SUBMODULE: free(gs->buf); gs->buf = NULL; gs->size = 0; @@ -1831,8 +1843,10 @@ static int grep_source_load(struct grep_source *gs) return grep_source_load_sha1(gs); case GREP_SOURCE_BUF: return gs->buf ? 0 : -1; + case GREP_SOURCE_SUBMODULE: + break; } - die("BUG: invalid grep_source type"); + die("BUG: invalid grep_source type to load"); } void grep_source_load_driver(struct grep_source *gs) |
