From: Brandon Williams <bmwill@google.com>
To: git@vger.kernel.org
Cc: Brandon Williams <bmwill@google.com>
Subject: [PATCH 3/4 v4] ls-files: pass through safe options for --recurse-submodules
Date: Mon, 26 Sep 2016 15:46:42 -0700 [thread overview]
Message-ID: <1474930003-83750-4-git-send-email-bmwill@google.com> (raw)
In-Reply-To: <1474930003-83750-1-git-send-email-bmwill@google.com>
Pass through some known-safe options when recursing into submodules.
(--cached, --stage, -v, -t, -z, --debug, --eol)
Signed-off-by: Brandon Williams <bmwill@google.com>
---
builtin/ls-files.c | 34 ++++++++++++++++++++++++++++++----
t/t3007-ls-files-recurse-submodules.sh | 17 ++++++++++++-----
2 files changed, 42 insertions(+), 9 deletions(-)
diff --git a/builtin/ls-files.c b/builtin/ls-files.c
index d4bfc60..a39367f 100644
--- a/builtin/ls-files.c
+++ b/builtin/ls-files.c
@@ -31,6 +31,7 @@ static int debug_mode;
static int show_eol;
static int recurse_submodules;
static const char *submodule_prefix;
+static struct argv_array recurse_submodules_opts = ARGV_ARRAY_INIT;
static const char *prefix;
static int max_prefix_len;
@@ -170,6 +171,27 @@ 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(int show_tag)
+{
+ if (show_cached)
+ argv_array_push(&recurse_submodules_opts, "--cached");
+ if (show_stage)
+ argv_array_push(&recurse_submodules_opts, "--stage");
+ if (show_valid_bit)
+ argv_array_push(&recurse_submodules_opts, "-v");
+ if (show_tag)
+ argv_array_push(&recurse_submodules_opts, "-t");
+ if (line_terminator == '\0')
+ argv_array_push(&recurse_submodules_opts, "-z");
+ if (debug_mode)
+ argv_array_push(&recurse_submodules_opts, "--debug");
+ if (show_eol)
+ argv_array_push(&recurse_submodules_opts, "--eol");
+}
+
/**
* Recursively call ls-files on a submodule
*/
@@ -184,6 +206,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, recurse_submodules_opts.argv);
+
cp.git_cmd = 1;
cp.dir = ce->name;
status = run_command(&cp);
@@ -568,14 +593,15 @@ 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)
+ if (recurse_submodules) {
submodule_prefix = getenv(GIT_SUBMODULE_PREFIX_ENVIRONMENT);
+ compile_submodule_options(show_tag);
+ }
if (recurse_submodules &&
- (show_stage || show_deleted || show_others || show_unmerged ||
+ (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')))
+ with_tree))
die("ls-files --recurse-submodules unsupported mode");
if (recurse_submodules && error_unmatch)
diff --git a/t/t3007-ls-files-recurse-submodules.sh b/t/t3007-ls-files-recurse-submodules.sh
index 7d225ac..40767da 100755
--- a/t/t3007-ls-files-recurse-submodules.sh
+++ b/t/t3007-ls-files-recurse-submodules.sh
@@ -34,6 +34,18 @@ test_expect_success 'ls-files correctly outputs files in submodule' '
test_cmp expect actual
'
+test_expect_success 'ls-files correctly outputs files in submodule with -z' '
+ cat | tr "\n" "\0" >expect <<-\EOF &&
+ .gitmodules
+ a
+ b/b
+ submodule/c
+ EOF
+
+ git ls-files --recurse-submodules -z >actual &&
+ test_cmp expect actual
+'
+
test_expect_success 'ls-files does not output files not added to a repo' '
cat >expect <<-\EOF &&
.gitmodules
@@ -86,15 +98,10 @@ test_incompatible_with_recurse_submodules () {
"
}
-test_incompatible_with_recurse_submodules -z
-test_incompatible_with_recurse_submodules -v
-test_incompatible_with_recurse_submodules -t
test_incompatible_with_recurse_submodules --deleted
test_incompatible_with_recurse_submodules --modified
test_incompatible_with_recurse_submodules --others
-test_incompatible_with_recurse_submodules --stage
test_incompatible_with_recurse_submodules --killed
test_incompatible_with_recurse_submodules --unmerged
-test_incompatible_with_recurse_submodules --eol
test_done
--
2.8.0.rc3.226.g39d4020
next prev parent reply other threads:[~2016-09-26 22:47 UTC|newest]
Thread overview: 67+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-09-24 0:13 [PATCH 0/3] recursive support for ls-files Brandon Williams
2016-09-24 0:13 ` [PATCH 1/3 v3] submodules: make submodule-prefix option an envvar Brandon Williams
2016-09-25 23:34 ` Junio C Hamano
2016-09-24 0:13 ` [PATCH 2/3 v3] ls-files: optionally recurse into submodules Brandon Williams
2016-09-24 0:13 ` [PATCH 3/3 v3] ls-files: add pathspec matching for submodules Brandon Williams
2016-09-25 7:17 ` [PATCH 0/3] recursive support for ls-files Jeff King
2016-09-25 16:32 ` Brandon Williams
2016-09-25 18:38 ` Junio C Hamano
2016-09-26 17:04 ` Brandon Williams
2016-09-26 18:17 ` Junio C Hamano
2016-09-26 18:38 ` Brandon Williams
2016-09-26 18:48 ` Junio C Hamano
2016-09-26 22:46 ` [PATCH 0/4 v4] " Brandon Williams
2016-09-26 22:46 ` [PATCH 1/4 v4] submodules: make submodule-prefix option Brandon Williams
2016-09-27 18:17 ` Junio C Hamano
2016-09-27 20:29 ` Brandon Williams
2016-09-27 20:35 ` Junio C Hamano
2016-09-27 20:43 ` Brandon Williams
2016-09-26 22:46 ` [PATCH 2/4 v4] ls-files: optionally recurse into submodules Brandon Williams
2016-09-27 18:29 ` Junio C Hamano
2016-09-27 20:33 ` Brandon Williams
2016-09-26 22:46 ` Brandon Williams [this message]
2016-09-27 18:40 ` [PATCH 3/4 v4] ls-files: pass through safe options for --recurse-submodules Junio C Hamano
2016-09-27 20:11 ` Junio C Hamano
2016-09-27 20:52 ` Brandon Williams
2016-09-27 20:58 ` Junio C Hamano
2016-09-27 20:59 ` Stefan Beller
2016-09-28 17:24 ` Brandon Williams
2016-09-28 18:59 ` Junio C Hamano
2016-09-27 20:49 ` Brandon Williams
2016-09-27 18:43 ` Junio C Hamano
2016-09-27 20:44 ` Brandon Williams
2016-09-27 20:59 ` Junio C Hamano
2016-09-26 22:46 ` [PATCH 4/4 v4] ls-files: add pathspec matching for submodules Brandon Williams
2016-09-27 20:01 ` Junio C Hamano
2016-09-27 20:40 ` Brandon Williams
2016-09-28 21:50 ` [PATCH v5 0/4] recursive support for ls-files Brandon Williams
2016-09-28 21:50 ` [PATCH v5 1/4] git: make super-prefix option Brandon Williams
2016-09-28 22:01 ` Stefan Beller
2016-09-28 22:19 ` Junio C Hamano
2016-09-29 18:39 ` Jeff King
2016-09-29 18:44 ` Brandon Williams
2016-09-28 21:50 ` [PATCH v5 2/4] ls-files: optionally recurse into submodules Brandon Williams
2016-09-28 22:11 ` Stefan Beller
2016-09-28 22:22 ` Junio C Hamano
2016-09-28 21:50 ` [PATCH v5 3/4] ls-files: pass through safe options for --recurse-submodules Brandon Williams
2016-09-28 21:50 ` [PATCH v5 4/4] ls-files: add pathspec matching for submodules Brandon Williams
2016-09-29 21:48 ` [PATCH v6 0/4] recursive support for ls-files Brandon Williams
2016-09-29 21:48 ` [PATCH v6 1/4] git: make super-prefix option Brandon Williams
2016-10-04 17:31 ` Stefan Beller
2016-10-04 17:35 ` Junio C Hamano
2016-10-04 17:39 ` Jeff King
2016-09-29 21:48 ` [PATCH v6 2/4] ls-files: optionally recurse into submodules Brandon Williams
2016-09-29 21:48 ` [PATCH v6 3/4] ls-files: pass through safe options for --recurse-submodules Brandon Williams
2016-09-30 0:14 ` Junio C Hamano
2016-09-30 16:33 ` Brandon Williams
2016-09-30 17:01 ` Brandon Williams
2016-09-29 21:48 ` [PATCH v6 4/4] ls-files: add pathspec matching for submodules Brandon Williams
2016-10-04 17:56 ` Stefan Beller
2016-10-07 18:18 ` [PATCH v7 0/4] recursive support for ls-files Brandon Williams
2016-10-07 18:18 ` [PATCH v7 1/4] git: make super-prefix option Brandon Williams
2016-10-07 18:18 ` [PATCH v7 2/4] ls-files: optionally recurse into submodules Brandon Williams
2016-10-07 18:18 ` [PATCH v7 3/4] ls-files: pass through safe options for --recurse-submodules Brandon Williams
2016-10-07 18:18 ` [PATCH v7 4/4] ls-files: add pathspec matching for submodules Brandon Williams
2016-10-07 18:34 ` [PATCH v7 0/4] recursive support for ls-files Stefan Beller
2016-10-07 18:35 ` Stefan Beller
2016-10-07 18:45 ` Brandon Williams
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1474930003-83750-4-git-send-email-bmwill@google.com \
--to=bmwill@google.com \
--cc=git@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.