All of lore.kernel.org
 help / color / mirror / Atom feed
From: Clemens Buchacher <drizzd@aon.at>
To: Junio C Hamano <gitster@pobox.com>
Cc: "Jeff King" <peff@peff.net>, "SZEDER Gábor" <szeder@ira.uka.de>,
	git@vger.kernel.org
Subject: [PATCH 2/2] add 'scope' config option
Date: Sat, 5 Sep 2009 14:33:04 +0200	[thread overview]
Message-ID: <20090905123304.GB3099@darc.dnsalias.org> (raw)
In-Reply-To: <20090905123117.GA3099@darc.dnsalias.org>

Documentation/config.txt says it all.

Signed-off-by: Clemens Buchacher <drizzd@aon.at>
---
 Documentation/config.txt |    6 ++++++
 builtin-add.c            |    2 +-
 builtin-grep.c           |    2 +-
 cache.h                  |    1 +
 config.c                 |    8 ++++++++
 environment.c            |    1 +
 6 files changed, 18 insertions(+), 2 deletions(-)

diff --git a/Documentation/config.txt b/Documentation/config.txt
index 5256c7f..f587cf1 100644
--- a/Documentation/config.txt
+++ b/Documentation/config.txt
@@ -439,6 +439,12 @@ On some file system/operating system combinations, this is unreliable.
 Set this config setting to 'rename' there; However, This will remove the
 check that makes sure that existing object files will not get overwritten.
 
+core.scope::
+	By default, the commands 'git add -u', 'git add -A' and 'git grep'
+	are limited to files below the current working directory
+	(scope='workdir'). Set this variable to scope='global' to make these
+	commands act on the whole tree instead.
+
 add.ignore-errors::
 	Tells 'git-add' to continue adding files when some files cannot be
 	added due to indexing errors. Equivalent to the '--ignore-errors'
diff --git a/builtin-add.c b/builtin-add.c
index 006fd08..33ea3e4 100644
--- a/builtin-add.c
+++ b/builtin-add.c
@@ -285,7 +285,7 @@ int cmd_add(int argc, const char **argv, const char *prefix)
 
 	if (addremove && take_worktree_changes)
 		die("-A and -u are mutually incompatible");
-	if ((addremove || take_worktree_changes) && !argc) {
+	if (!scope_global && (addremove || take_worktree_changes) && !argc) {
 		static const char *here[2] = { ".", NULL };
 		argc = 1;
 		argv = here;
diff --git a/builtin-grep.c b/builtin-grep.c
index f6af3d4..447b195 100644
--- a/builtin-grep.c
+++ b/builtin-grep.c
@@ -861,7 +861,7 @@ int cmd_grep(int argc, const char **argv, const char *prefix)
 
 	if (i < argc)
 		paths = get_pathspec(prefix, argv + i);
-	else if (prefix) {
+	else if (!scope_global && prefix) {
 		paths = xcalloc(2, sizeof(const char *));
 		paths[0] = prefix;
 		paths[1] = NULL;
diff --git a/cache.h b/cache.h
index 5fad24c..85c5fee 100644
--- a/cache.h
+++ b/cache.h
@@ -523,6 +523,7 @@ extern int auto_crlf;
 extern int read_replace_refs;
 extern int fsync_object_files;
 extern int core_preload_index;
+extern int scope_global;
 
 enum safe_crlf {
 	SAFE_CRLF_FALSE = 0,
diff --git a/config.c b/config.c
index e87edea..8dec019 100644
--- a/config.c
+++ b/config.c
@@ -503,6 +503,14 @@ static int git_default_core_config(const char *var, const char *value)
 		return 0;
 	}
 
+	if (!strcmp(var, "core.scope")) {
+		if (!strcasecmp(value, "global"))
+			scope_global = 1;
+		if (!strcasecmp(value, "worktree"))
+			scope_global = 0;
+		return 0;
+	}
+
 	/* Add other config variables here and to Documentation/config.txt. */
 	return 0;
 }
diff --git a/environment.c b/environment.c
index 5de6837..4d1c6e1 100644
--- a/environment.c
+++ b/environment.c
@@ -50,6 +50,7 @@ enum push_default_type push_default = PUSH_DEFAULT_MATCHING;
 #endif
 enum object_creation_mode object_creation_mode = OBJECT_CREATION_MODE;
 int grafts_replace_parents = 1;
+int scope_global = 0;
 
 /* Parallel index stat data preload? */
 int core_preload_index = 0;
-- 
1.6.4.2.264.g79b4f

  reply	other threads:[~2009-09-05 12:33 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-09-02  8:03 [BUG] 'add -u' doesn't work from untracked subdir SZEDER Gábor
2009-09-02  8:19 ` Jeff King
2009-09-04  7:02   ` Clemens Buchacher
2009-09-05  6:18     ` Jeff King
2009-09-05  7:02       ` Junio C Hamano
2009-09-05  7:20         ` Jeff King
2009-09-05  7:58           ` Junio C Hamano
2009-09-05  8:02             ` Jeff King
2009-09-05  8:23               ` Junio C Hamano
2009-09-06 18:28                 ` Clemens Buchacher
2009-09-09 23:46                 ` Nanako Shiraishi
2009-09-10 19:53                   ` Junio C Hamano
2009-09-10 20:32                     ` Clemens Buchacher
2009-09-05 12:31             ` [PATCH 1/2] grep: accept relative paths outside current working directory Clemens Buchacher
2009-09-05 12:33               ` Clemens Buchacher [this message]
2009-09-05 13:10                 ` [PATCH 2/2 v2] add 'scope' config option Clemens Buchacher
2009-09-06 22:58               ` [PATCH 1/2] grep: accept relative paths outside current working directory Junio C Hamano
2009-09-07  8:48                 ` [PATCH] grep: fix exit status if external_grep() returns error Clemens Buchacher
2009-09-07 18:13                   ` Junio C Hamano
2009-09-05  8:19           ` [BUG] 'add -u' doesn't work from untracked subdir Jeff King
2009-09-05  7:25         ` Junio C Hamano
2009-09-05  8:46         ` Clemens Buchacher
2009-09-05 17:28           ` Junio C Hamano
2009-09-05 17:58             ` Jakub Narebski
2009-09-05 18:45             ` Clemens Buchacher
2009-09-05 21:46               ` 'add -u' without path is relative to cwd Junio C Hamano
2009-09-06 12:32           ` [BUG] 'add -u' doesn't work from untracked subdir Matthieu Moy
2009-09-06 18:16             ` Clemens Buchacher
2009-09-07  6:23               ` Matthieu Moy
2009-09-07  7:33                 ` SZEDER Gábor
2009-09-07  8:06                   ` Matthieu Moy
2009-09-07  0:07           ` Nanako Shiraishi
2009-09-07  5:07             ` Junio C Hamano
2009-09-07  7:50             ` Clemens Buchacher
2009-09-04  8:32   ` SZEDER Gábor

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=20090905123304.GB3099@darc.dnsalias.org \
    --to=drizzd@aon.at \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=peff@peff.net \
    --cc=szeder@ira.uka.de \
    /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.