From: Stefan Beller <sbeller@google.com>
To: bmwill@google.com
Cc: git@vger.kernel.org, gitster@pobox.com,
Stefan Beller <sbeller@google.com>
Subject: [PATCH 6/8] builtin/grep.c: respect 'submodule.recurse' option
Date: Fri, 26 May 2017 12:10:15 -0700 [thread overview]
Message-ID: <20170526191017.19155-7-sbeller@google.com> (raw)
In-Reply-To: <20170526191017.19155-1-sbeller@google.com>
In builtin/grep.c we parse the config before evaluating the command line
options. This makes the task of teaching grep to respect the new config
option 'submodule.recurse' very easy by just parsing that option.
As an alternative I had implemented a similar structure to treat
submodules as the fetch/push command have, including
* aligning the meaning of the 'recurse_submodules' to possible submodule
values RECURSE_SUBMODULES_* as defined in submodule.h.
* having a callback to parse the value and
* reacting to the RECURSE_SUBMODULES_DEFAULT state that was the initial
state.
However all this is not needed for a true boolean value, so let's keep
it simple. However this adds another place where "submodule.recurse" is
parsed.
Signed-off-by: Stefan Beller <sbeller@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
builtin/grep.c | 3 +++
t/t7814-grep-recurse-submodules.sh | 18 ++++++++++++++++++
2 files changed, 21 insertions(+)
diff --git a/builtin/grep.c b/builtin/grep.c
index b1095362fb..454e263820 100644
--- a/builtin/grep.c
+++ b/builtin/grep.c
@@ -302,6 +302,9 @@ static int grep_cmd_config(const char *var, const char *value, void *cb)
#endif
}
+ if (!strcmp(var, "submodule.recurse"))
+ recurse_submodules = git_config_bool(var, value);
+
return st;
}
diff --git a/t/t7814-grep-recurse-submodules.sh b/t/t7814-grep-recurse-submodules.sh
index 3a58197f47..7184113b9b 100755
--- a/t/t7814-grep-recurse-submodules.sh
+++ b/t/t7814-grep-recurse-submodules.sh
@@ -33,6 +33,24 @@ test_expect_success 'grep correctly finds patterns in a submodule' '
test_cmp expect actual
'
+test_expect_success 'grep finds patterns in a submodule via config' '
+ test_config submodule.recurse true &&
+ # expect from previous test
+ git grep -e "(3|4)" >actual &&
+ test_cmp expect actual
+'
+
+test_expect_success 'grep --no-recurse-submodules overrides config' '
+ test_config submodule.recurse true &&
+ cat >expect <<-\EOF &&
+ a:(1|2)d(3|4)
+ b/b:(3|4)
+ EOF
+
+ git grep -e "(3|4)" --no-recurse-submodules >actual &&
+ test_cmp expect actual
+'
+
test_expect_success 'grep and basic pathspecs' '
cat >expect <<-\EOF &&
submodule/a:(1|2)d(3|4)
--
2.13.0.17.g582985b1e4
next prev parent reply other threads:[~2017-05-26 19:12 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-05-26 19:10 [PATCHv2 0/8] A reroll of sb/submodule-blanket-recursive Stefan Beller
2017-05-26 19:10 ` [PATCH 1/8] submodule recursing: do not write a config variable twice Stefan Beller
2017-05-26 19:10 ` [PATCH 2/8] submodule test invocation: only pass additional arguments Stefan Beller
2017-05-26 19:10 ` [PATCH 3/8] reset/checkout/read-tree: unify config callback for submodule recursion Stefan Beller
2017-05-26 19:10 ` [PATCH 4/8] submodule loading: separate code path for .gitmodules and config overlay Stefan Beller
2017-05-26 19:10 ` [PATCH 5/8] Introduce 'submodule.recurse' option for worktree manipulators Stefan Beller
2017-05-26 19:10 ` Stefan Beller [this message]
2017-05-26 19:10 ` [PATCH 7/8] builtin/push.c: respect 'submodule.recurse' option Stefan Beller
2017-05-26 19:10 ` [PATCH 8/8] builtin/fetch.c: " Stefan Beller
2017-05-30 5:30 ` [PATCHv2 0/8] A reroll of sb/submodule-blanket-recursive Junio C Hamano
2017-06-01 0:30 ` [PATCHv3 0/4] " Stefan Beller
2017-06-01 0:30 ` [PATCHv3 1/4] Introduce 'submodule.recurse' option for worktree manipulators Stefan Beller
2017-06-01 0:30 ` [PATCHv3 2/4] builtin/grep.c: respect 'submodule.recurse' option Stefan Beller
2017-06-01 0:30 ` [PATCHv3 3/4] builtin/push.c: " Stefan Beller
2017-06-01 0:30 ` [PATCHv3 4/4] builtin/fetch.c: " Stefan Beller
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
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20170526191017.19155-7-sbeller@google.com \
--to=sbeller@google.com \
--cc=bmwill@google.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
/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.
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).