diff options
author | Brandon Williams <bmwill@google.com> | 2016-10-07 11:18:50 -0700 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2016-10-10 12:14:58 -0700 |
commit | 07c01b9fd927b35375bd3a7d4d9dbf7bb8509f09 (patch) | |
tree | 9b2ecd0acd4dea48b3a04925ff6a463975a25d24 /builtin | |
parent | ls-files: optionally recurse into submodules (diff) | |
download | tgif-07c01b9fd927b35375bd3a7d4d9dbf7bb8509f09.tar.xz |
ls-files: pass through safe options for --recurse-submodules
Pass through some known-safe options when recursing into submodules.
(--cached, -v, -t, -z, --debug, --eol)
Signed-off-by: Brandon Williams <bmwill@google.com>
Reviewed-by: Stefan Beller <sbeller@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin')
-rw-r--r-- | builtin/ls-files.c | 30 |
1 files changed, 27 insertions, 3 deletions
diff --git a/builtin/ls-files.c b/builtin/ls-files.c index 63befed9ea..b6144a56d3 100644 --- a/builtin/ls-files.c +++ b/builtin/ls-files.c @@ -30,6 +30,7 @@ static int line_terminator = '\n'; static int debug_mode; static int show_eol; static int recurse_submodules; +static struct argv_array submodules_options = ARGV_ARRAY_INIT; static const char *prefix; static const char *super_prefix; @@ -168,6 +169,25 @@ static void show_killed_files(struct dir_struct *dir) } } +/* + * Compile an argv_array with all of the options supported by --recurse_submodules + */ +static void compile_submodule_options(const struct dir_struct *dir, int show_tag) +{ + if (line_terminator == '\0') + argv_array_push(&submodules_options, "-z"); + if (show_tag) + argv_array_push(&submodules_options, "-t"); + if (show_valid_bit) + argv_array_push(&submodules_options, "-v"); + if (show_cached) + argv_array_push(&submodules_options, "--cached"); + if (show_eol) + argv_array_push(&submodules_options, "--eol"); + if (debug_mode) + argv_array_push(&submodules_options, "--debug"); +} + /** * Recursively call ls-files on a submodule */ @@ -182,6 +202,9 @@ static void show_gitlink(const struct cache_entry *ce) argv_array_push(&cp.args, "ls-files"); argv_array_push(&cp.args, "--recurse-submodules"); + /* add supported options */ + argv_array_pushv(&cp.args, submodules_options.argv); + cp.git_cmd = 1; cp.dir = ce->name; status = run_command(&cp); @@ -567,11 +590,12 @@ int cmd_ls_files(int argc, const char **argv, const char *cmd_prefix) if (require_work_tree && !is_inside_work_tree()) setup_work_tree(); + if (recurse_submodules) + compile_submodule_options(&dir, show_tag); + if (recurse_submodules && (show_stage || show_deleted || show_others || show_unmerged || - show_killed || show_modified || show_resolve_undo || - show_valid_bit || show_tag || show_eol || with_tree || - (line_terminator == '\0'))) + show_killed || show_modified || show_resolve_undo || with_tree)) die("ls-files --recurse-submodules unsupported mode"); if (recurse_submodules && error_unmatch) |