From: Junio C Hamano <gitster@pobox.com>
To: git@vger.kernel.org
Subject: [PATCH 2/4] add -u: get rid of "treewideupdate" configuration
Date: Wed, 6 Apr 2011 18:16:34 -0700 [thread overview]
Message-ID: <1302138996-10006-3-git-send-email-gitster@pobox.com> (raw)
In-Reply-To: <1302138996-10006-1-git-send-email-gitster@pobox.com>
Thanks to the magic ":/" pathspec, it is much easier to invoke both
tree-wide operation and limited-to-cwd operation on demand from the
command line. What remains is the downside of the configuration variable,
namely, that it makes git behave differently depending on who you are and
in which repository you are using it, hence making it harder to help
and/or teach others.
Remove the configuration variable, and adjust the warning message.
Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
builtin/add.c | 26 ++++++--------------------
t/t2200-add-update.sh | 29 +++++++++++++++++++----------
2 files changed, 25 insertions(+), 30 deletions(-)
diff --git a/builtin/add.c b/builtin/add.c
index 595f5cc..f58d1cf 100644
--- a/builtin/add.c
+++ b/builtin/add.c
@@ -310,7 +310,6 @@ static const char ignore_error[] =
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 default_tree_wide_update = -1;
static struct option builtin_add_options[] = {
OPT__DRY_RUN(&show_only, "dry run"),
@@ -336,10 +335,6 @@ static int add_config(const char *var, const char *value, void *cb)
ignore_add_errors = git_config_bool(var, value);
return 0;
}
- if (!strcasecmp(var, "add.treewideupdate")) {
- default_tree_wide_update = git_config_bool(var, value);
- return 0;
- }
return git_default_config(var, value, cb);
}
@@ -368,15 +363,10 @@ static const char *warn_add_uA_180_migration_msg[] = {
"In release 1.8.0, running 'git add -u' (or 'git add -A') from",
"a subdirectory without giving any pathspec WILL take effect",
"on the whole working tree, not just the part under the current",
- "directory. You can set add.treewideupdate configuration variable",
- "to 'false' to keep the current behaviour.",
- "You can set the configuration variable to 'true' to make the",
- "'git add -u/-A' command without pathspec take effect on the whole",
- "working tree now. If you do so, you can use '.' at the end of",
- "the command, e.g. 'git add -u .' when you want to limit the",
- "operation to the current directory.",
- "This warning will be issued until you set the configuration variable",
- "to either 'true' or 'false'."
+ "directory. Please make it a habit to add '.' when you want to",
+ "limit the operation to the current directory and below.",
+ "You can use ':/' at the end of the command to affect the operation",
+ "on the whole working tree.",
};
static int warn_180_migration(void)
@@ -419,12 +409,8 @@ int cmd_add(int argc, const char **argv, const char *prefix)
die("Option --ignore-missing can only be used together with --dry-run");
if ((addremove || take_worktree_changes) && !argc) {
whole_tree_add = 1;
- if (prefix) {
- if (default_tree_wide_update < 0)
- default_tree_wide_update = warn_180_migration();
- if (!default_tree_wide_update)
- whole_tree_add = 0;
- }
+ if (prefix)
+ whole_tree_add = warn_180_migration();
}
add_new_files = !take_worktree_changes && !refresh_only;
diff --git a/t/t2200-add-update.sh b/t/t2200-add-update.sh
index 7ac8b70..f7711ba 100755
--- a/t/t2200-add-update.sh
+++ b/t/t2200-add-update.sh
@@ -80,10 +80,9 @@ test_expect_success 'change gets noticed' '
'
-test_expect_success 'update from a subdirectory without pathspec (no config)' '
+test_expect_success 'update from a subdirectory without pathspec' '
# This test needs to be updated to expect the whole tree
# update after 1.8.0 migration.
- test_might_fail git config --remove add.treewideupdate &&
test_might_fail git reset check dir1 &&
echo changed >check &&
(
@@ -97,15 +96,13 @@ test_expect_success 'update from a subdirectory without pathspec (no config)' '
grep warning expect.warning
'
-test_expect_success 'update from a subdirectory without pathspec (local)' '
- test_when_finished "git config --remove add.treewideupdate; :" &&
- git config add.treewideupdate false &&
+test_expect_success 'update from a subdirectory with local pathspec' '
test_might_fail git reset check dir1 &&
echo changed >check &&
(
cd dir1 &&
echo even more >sub2 &&
- git add -u 2>../expect.warning
+ git add -u . 2>../expect.warning
) &&
git diff-files --name-only dir1 check >actual &&
echo check >expect &&
@@ -113,15 +110,27 @@ test_expect_success 'update from a subdirectory without pathspec (local)' '
! grep warning expect.warning
'
-test_expect_success 'update from a subdirectory without pathspec (global)' '
- test_when_finished "git config --remove add.treewideupdate; :" &&
- git config add.treewideupdate true &&
+test_expect_success 'update from a subdirectory with magic pathspec (mnemonic)' '
test_might_fail git reset check dir1 &&
echo changed >check &&
(
cd dir1 &&
echo even more >sub2 &&
- git add -u 2>../expect.warning
+ git add -u :/ 2>../expect.warning
+ ) &&
+ git diff-files --name-only dir1 check >actual &&
+ : >expect &&
+ test_cmp expect actual &&
+ ! grep warning expect.warning
+'
+
+test_expect_success 'update from a subdirectory with magic pathspec (longhand)' '
+ test_might_fail git reset check dir1 &&
+ echo changed >check &&
+ (
+ cd dir1 &&
+ echo even more >sub2 &&
+ git add -u ":(top)" 2>../expect.warning
) &&
git diff-files --name-only dir1 check >actual &&
: >expect &&
--
1.7.5.rc1
next prev parent reply other threads:[~2011-04-07 1:17 UTC|newest]
Thread overview: 35+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-04-07 1:16 [PATCH 0/4] Redoing the "add -u" migration plan Junio C Hamano
2011-04-07 1:16 ` [PATCH 1/4] magic pathspec: add tentative ":/path/from/top/level" pathspec support Junio C Hamano
2011-04-07 1:40 ` Junio C Hamano
2011-04-07 13:09 ` Nguyen Thai Ngoc Duy
2011-04-07 18:28 ` Junio C Hamano
2011-04-08 11:39 ` Nguyen Thai Ngoc Duy
2011-04-07 13:23 ` Nguyen Thai Ngoc Duy
2011-04-07 16:18 ` Junio C Hamano
2011-04-08 12:00 ` Nguyen Thai Ngoc Duy
2011-04-08 15:05 ` Junio C Hamano
2011-04-08 15:39 ` Nguyen Thai Ngoc Duy
2011-04-08 16:37 ` Junio C Hamano
2011-04-08 17:02 ` Nguyen Thai Ngoc Duy
2011-04-07 1:16 ` Junio C Hamano [this message]
2011-04-08 17:54 ` [PATCH 2/4] add -u: get rid of "treewideupdate" configuration Jeff King
2011-04-08 19:27 ` Junio C Hamano
2011-04-08 20:24 ` Jeff King
2011-04-08 22:22 ` Junio C Hamano
2011-04-08 22:32 ` Jeff King
2011-04-08 22:37 ` Junio C Hamano
2011-04-08 23:18 ` Junio C Hamano
2011-04-09 4:38 ` Nguyen Thai Ngoc Duy
2011-04-09 4:56 ` Junio C Hamano
2011-04-09 5:05 ` Nguyen Thai Ngoc Duy
2011-04-09 21:34 ` Junio C Hamano
2011-04-09 4:58 ` Nguyen Thai Ngoc Duy
2011-04-09 5:20 ` Junio C Hamano
2011-04-09 10:15 ` Nguyen Thai Ngoc Duy
2011-04-09 11:24 ` Nguyen Thai Ngoc Duy
2011-04-09 21:38 ` Junio C Hamano
2011-05-03 7:52 ` Nguyen Thai Ngoc Duy
2011-05-03 15:01 ` Junio C Hamano
2011-05-03 16:17 ` Nguyen Thai Ngoc Duy
2011-04-07 1:16 ` [PATCH 3/4] add: make "add -u/-A" update full tree without pathspec (step 2) Junio C Hamano
2011-04-07 1:16 ` [PATCH 4/4] add: make "add -u/-A" update full tree without pathspec (step 3) 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=1302138996-10006-3-git-send-email-gitster@pobox.com \
--to=gitster@pobox.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 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).