From: David Aguilar <davvid@gmail.com>
To: Junio C Hamano <gitster@pobox.com>
Cc: git@vger.kernel.org
Subject: [PATCH] add: allow users to silence Git 2.0 warnings about "add -u"
Date: Thu, 21 Feb 2013 22:07:04 -0800 [thread overview]
Message-ID: <1361513224-34550-1-git-send-email-davvid@gmail.com> (raw)
When "git add -u" is invoked from a subdirectory it prints a
loud warning message about an upcoming Git 2.0 behavior change.
Some users do not care to be warned. Accomodate them.
The "add.silence-pathless-warnings" configuration variable can
now be used to silence this warning.
Signed-off-by: David Aguilar <davvid@gmail.com>
---
I found the warning a informative but also a little annoying.
I can imagine others might as well.
I would also like to change the warning message to mention what the Git 2.0
behavior will be (which it does not mention), but I realize that the string
has already been translated. That can be a follow-on patch if this is seen as
a worthwhile change, but might not be worth the trouble since it's a problem
which will go away in 2.0.
Documentation/config.txt | 7 +++++++
builtin/add.c | 8 +++++++-
t/t2200-add-update.sh | 11 +++++++++++
3 files changed, 25 insertions(+), 1 deletion(-)
diff --git a/Documentation/config.txt b/Documentation/config.txt
index 3bb53da..b6ed859 100644
--- a/Documentation/config.txt
+++ b/Documentation/config.txt
@@ -648,6 +648,13 @@ core.abbrev::
for abbreviated object names to stay unique for sufficiently long
time.
+add.silence-pathless-warnings::
+ Tells 'git add' to silence warnings when 'git add -u' is used in
+ a subdirectory without specifying a path. Git 2.0 updates the
+ whole tree. Git 1.x updates the current directory only, and warns
+ about the upcoming change unless this variable is set to true.
+ False by default, and ignored by Git 2.0.
+
add.ignore-errors::
add.ignoreErrors::
Tells 'git add' to continue adding files when some files cannot be
diff --git a/builtin/add.c b/builtin/add.c
index 0dd014e..01b9cac 100644
--- a/builtin/add.c
+++ b/builtin/add.c
@@ -272,6 +272,7 @@ N_("The following paths are ignored by one of your .gitignore files:\n");
static int verbose = 0, show_only = 0, ignored_too = 0, refresh_only = 0;
static int ignore_add_errors, addremove, intent_to_add, ignore_missing = 0;
+static int silence_pathless_warnings;
static struct option builtin_add_options[] = {
OPT__DRY_RUN(&show_only, N_("dry run")),
@@ -296,6 +297,8 @@ static int add_config(const char *var, const char *value, void *cb)
!strcmp(var, "add.ignore-errors")) {
ignore_add_errors = git_config_bool(var, value);
return 0;
+ } else if (!strcmp(var, "add.silence-pathless-warnings")) {
+ silence_pathless_warnings = git_config_bool(var, value);
}
return git_default_config(var, value, cb);
}
@@ -321,7 +324,8 @@ static int add_files(struct dir_struct *dir, int flags)
return exit_status;
}
-static void warn_pathless_add(const char *option_name, const char *short_name) {
+static void warn_pathless_add(const char *option_name, const char *short_name)
+{
/*
* To be consistent with "git add -p" and most Git
* commands, we should default to being tree-wide, but
@@ -332,6 +336,8 @@ static void warn_pathless_add(const char *option_name, const char *short_name) {
* turned into a die(...), and eventually we may
* reallow the command with a new behavior.
*/
+ if (silence_pathless_warnings)
+ return;
warning(_("The behavior of 'git add %s (or %s)' with no path argument from a\n"
"subdirectory of the tree will change in Git 2.0 and should not be used anymore.\n"
"To add content for the whole tree, run:\n"
diff --git a/t/t2200-add-update.sh b/t/t2200-add-update.sh
index 4cdebda..779dbe7 100755
--- a/t/t2200-add-update.sh
+++ b/t/t2200-add-update.sh
@@ -171,4 +171,15 @@ test_expect_success '"add -u non-existent" should fail' '
! (git ls-files | grep "non-existent")
'
+test_expect_success 'add.silence-pathless-warnings configuration variable' '
+ : >expect &&
+ test_config add.silence-pathless-warnings true &&
+ (
+ cd dir1 &&
+ echo more >>sub2 &&
+ git add -u
+ ) >actual 2>&1 &&
+ test_cmp expect actual
+'
+
test_done
--
1.8.2.rc0.22.gb3600c3.dirty
next reply other threads:[~2013-02-22 6:07 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-02-22 6:07 David Aguilar [this message]
2013-02-22 6:23 ` [PATCH] add: allow users to silence Git 2.0 warnings about "add -u" Junio C Hamano
2013-02-22 7:12 ` David Aguilar
2013-02-22 9:32 ` Matthieu Moy
2013-02-22 17:30 ` Junio C Hamano
2013-02-23 7:59 ` David Aguilar
2013-02-23 8:44 ` Junio C Hamano
2013-02-22 17:18 ` Junio C Hamano
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=1361513224-34550-1-git-send-email-davvid@gmail.com \
--to=davvid@gmail.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.
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 NNTP newsgroup(s).