git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 2/4] add -u: get rid of "treewideupdate" configuration

From
Junio C Hamano <gitster@pobox.com>
Date
Apr 7, 2011, 01:16 UTC
Message-ID
<1302138996-10006-3-git-send-email-gitster@pobox.com>
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
Previous: Nguyen Thai Ngoc DuyNext: Jeff King
Message 14 of 35 in “Redoing the "add -u" migration plan”
  1. 0/4 Redoing the "add -u" migration planJunio C Hamano, Apr 7, 2011
  2. 1/4 magic pathspec: add tentative ":/path/from/top/level" pathspec supportJunio C Hamano, Apr 7, 2011
  3. Junio C HamanoApr 7, 2011
  4. Nguyen Thai Ngoc DuyApr 7, 2011
  5. Junio C HamanoApr 7, 2011
  6. Nguyen Thai Ngoc DuyApr 8, 2011
  7. Nguyen Thai Ngoc DuyApr 7, 2011
  8. Junio C HamanoApr 7, 2011
  9. Nguyen Thai Ngoc DuyApr 8, 2011
  10. Junio C HamanoApr 8, 2011
  11. Nguyen Thai Ngoc DuyApr 8, 2011
  12. Junio C HamanoApr 8, 2011
  13. Nguyen Thai Ngoc DuyApr 8, 2011
  14. 2/4 add -u: get rid of "treewideupdate" configurationJunio C Hamano, Apr 7, 2011
  15. Jeff KingApr 8, 2011
  16. Junio C HamanoApr 8, 2011
  17. Jeff KingApr 8, 2011
  18. Junio C HamanoApr 8, 2011
  19. Jeff KingApr 8, 2011
  20. Junio C HamanoApr 8, 2011
  21. Junio C HamanoApr 8, 2011
  22. Nguyen Thai Ngoc DuyApr 9, 2011
  23. Junio C HamanoApr 9, 2011
  24. Nguyen Thai Ngoc DuyApr 9, 2011
  25. Junio C HamanoApr 9, 2011
  26. Nguyen Thai Ngoc DuyApr 9, 2011
  27. Junio C HamanoApr 9, 2011
  28. Nguyen Thai Ngoc DuyApr 9, 2011
  29. Nguyen Thai Ngoc DuyApr 9, 2011
  30. Junio C HamanoApr 9, 2011
  31. Nguyen Thai Ngoc DuyMay 3, 2011
  32. Junio C HamanoMay 3, 2011
  33. Nguyen Thai Ngoc DuyMay 3, 2011
  34. 3/4 add: make "add -u/-A" update full tree without pathspec (step 2)Junio C Hamano, Apr 7, 2011
  35. 4/4 add: make "add -u/-A" update full tree without pathspec (step 3)Junio C Hamano, Apr 7, 2011

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.