All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dragan Simic <dsimic@manjaro.org>
To: git@vger.kernel.org
Subject: [PATCH 4/5] grep: introduce new config option to include untracked files
Date: Mon, 18 Mar 2024 18:03:24 +0100	[thread overview]
Message-ID: <9f70eeb4f04a874a2036e1d8c61f3b7ec130663a.1710781235.git.dsimic@manjaro.org> (raw)
In-Reply-To: <cover.1710781235.git.dsimic@manjaro.org>

Add new configuration option grep.includeUntracked that enables --untracked
option by default.  This pretty much follows the logic established by the
already existing configuration option grep.fallbackToNoIndex, while also
respecting the dependencies of the --untracked option.

Also add a few automated tests to the t7810, to cover the new configuration
option by replicating the already existing tests for --untracked.

Signed-off-by: Dragan Simic <dsimic@manjaro.org>
---
 builtin/grep.c  | 3 +++
 t/t7810-grep.sh | 9 +++++++++
 2 files changed, 12 insertions(+)

diff --git a/builtin/grep.c b/builtin/grep.c
index af89c8b5cb19..71d94126fb6e 100644
--- a/builtin/grep.c
+++ b/builtin/grep.c
@@ -1041,6 +1041,9 @@ int cmd_grep(int argc, const char **argv, const char *prefix)
 		the_repository->settings.command_requires_full_index = 0;
 	}
 
+	if (use_index && !cached)
+		git_config_get_bool("grep.includeuntracked", &untracked);
+
 	if (use_index && !startup_info->have_repository) {
 		int fallback = 0;
 		git_config_get_bool("grep.fallbacktonoindex", &fallback);
diff --git a/t/t7810-grep.sh b/t/t7810-grep.sh
index 875dcfd98f3a..de93936d585f 100755
--- a/t/t7810-grep.sh
+++ b/t/t7810-grep.sh
@@ -1298,20 +1298,29 @@ test_expect_success 'inside git repository but with --no-index' '
 		git grep --untracked o >../actual.unignored &&
 		test_cmp ../expect.unignored ../actual.unignored &&
 
+		git -c grep.includeUntracked=true grep o >../actual.unignored &&
+		test_cmp ../expect.unignored ../actual.unignored &&
+
 		git grep --no-index o >../actual.full &&
 		test_cmp ../expect.full ../actual.full &&
 
+		git -c grep.includeUntracked=true grep --no-index o >../actual.full &&
+		test_cmp ../expect.full ../actual.full &&
+
 		git grep --no-index --exclude-standard o >../actual.unignored &&
 		test_cmp ../expect.unignored ../actual.unignored &&
 
 		cd sub &&
 		test_must_fail git grep o >../../actual.sub &&
 		test_must_be_empty ../../actual.sub &&
 
 		git grep --no-index o >../../actual.sub &&
 		test_cmp ../../expect.sub ../../actual.sub &&
 
 		git grep --untracked o >../../actual.sub &&
+		test_cmp ../../expect.sub ../../actual.sub &&
+
+		git -c grep.includeUntracked=true grep o >../../actual.sub &&
 		test_cmp ../../expect.sub ../../actual.sub
 	)
 '

  parent reply	other threads:[~2024-03-18 17:03 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-18 17:03 [PATCH 0/5] New config option for git-grep to include untracked files Dragan Simic
2024-03-18 17:03 ` [PATCH 1/5] grep: perform some minor code and comment cleanups Dragan Simic
2024-03-18 19:59   ` Eric Sunshine
2024-03-18 22:03     ` Dragan Simic
2024-03-19  0:32     ` Junio C Hamano
2024-03-19  5:33       ` Dragan Simic
2024-03-18 17:03 ` [PATCH 2/5] grep docs: describe --recurse-submodules further and improve formatting a bit Dragan Simic
2024-03-18 20:02   ` Eric Sunshine
2024-03-18 22:14     ` Dragan Simic
2024-03-18 17:03 ` [PATCH 3/5] grep docs: describe --no-index further Dragan Simic
2024-03-19  0:55   ` Junio C Hamano
2024-03-19  5:37     ` Dragan Simic
2024-03-18 17:03 ` Dragan Simic [this message]
2024-03-19  0:58   ` [PATCH 4/5] grep: introduce new config option to include untracked files Junio C Hamano
2024-03-19  5:47     ` Dragan Simic
2024-03-19 14:32       ` Junio C Hamano
2024-03-19 14:52         ` Dragan Simic
2024-03-18 17:03 ` [PATCH 5/5] grep docs: describe " Dragan Simic
2024-03-19  0:21 ` [PATCH 0/5] New config option for git-grep " Junio C Hamano
2024-03-19  5:09   ` Dragan Simic
2024-03-19 17:43     ` Junio C Hamano
2024-03-19 17:48       ` Dragan Simic

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=9f70eeb4f04a874a2036e1d8c61f3b7ec130663a.1710781235.git.dsimic@manjaro.org \
    --to=dsimic@manjaro.org \
    --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.