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

[PATCH] add: make "add -u/-A" update full tree without pathspec (step 2)

From
Junio C Hamano <gitster@pobox.com>
Date
Mar 23, 2011, 05:17 UTC
Message-ID
<7v7hbqifej.fsf_-_@alter.siamese.dyndns.org>
In-Reply-To
<7vtyeuiu07.fsf@alter.siamese.dyndns.org>

Flip the default behaviour when "git add -u/-A" is run without a pathspec from a subdirectory to tree-wide, and reword the advice message.

We will need to keep the advice message for a while to help people who skipped the 1.8.0 boundary.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
 * This is how 1.8.0 "flip the default" would look like.
 builtin/add.c         |   20 +++++++++-----------
 t/t2200-add-update.sh |    5 ++---
 2 files changed, 11 insertions(+), 14 deletions(-)
diff --git a/builtin/add.c b/builtin/add.c
index 595f5cc..1d76d55 100644
--- a/builtin/add.c
+++ b/builtin/add.c
@@ -365,17 +365,15 @@ static int add_files(struct dir_struct *dir, int flags)
 }
 
 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",
+	"Since release 1.8.0, running 'git add -u' (or 'git add -A')",
+	"from a subdirectory without giving any pathspec takes 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",
+	"directory. If you want to limit the operation to the current",
+	"directory, please add '.' at the end of the command, like",
+	"'git add -u .'",
+	"Alternatively, you can set add.treewideupdate configuration",
+	"variable to 'false' to keep using the old behaviour.",
+	"This warning will be issued until you set the variable",
 	"to either 'true' or 'false'."
 };
 
@@ -384,7 +382,7 @@ static int warn_180_migration(void)
 	int i;
 	for (i = 0; i < ARRAY_SIZE(warn_add_uA_180_migration_msg); i++)
 		warning("%s", warn_add_uA_180_migration_msg[i]);
-	return 0; /* default to "no" (not tree-wide, i.e. local) */
+	return 1; /* default to "true" (tree-wide, i.e. not local) */
 }
 
 int cmd_add(int argc, const char **argv, const char *prefix)
diff --git a/t/t2200-add-update.sh b/t/t2200-add-update.sh
index 7ac8b70..97478cd 100755
--- a/t/t2200-add-update.sh
+++ b/t/t2200-add-update.sh
@@ -81,8 +81,7 @@ test_expect_success 'change gets noticed' '
 '
 
 test_expect_success 'update from a subdirectory without pathspec (no config)' '
-	# This test needs to be updated to expect the whole tree
-	# update after 1.8.0 migration.
+	# This test needs to be adjusted when warning message is removed
 	test_might_fail git config --remove add.treewideupdate &&
 	test_might_fail git reset check dir1 &&
 	echo changed >check &&
@@ -92,7 +91,7 @@ test_expect_success 'update from a subdirectory without pathspec (no config)' '
 		git add -u 2>../expect.warning
 	) &&
 	git diff-files --name-only dir1 check >actual &&
-	echo check >expect &&
+	: >expect &&
 	test_cmp expect actual &&
 	grep warning expect.warning
 '
-- 
1.7.4.1.559.ga7cf60f
Previous: Junio C HamanoNext: Junio C Hamano
Message 10 of 15 in “What's cooking in git.git (Mar 2011, #02; Sun, 20)”
  1. Junio C HamanoMar 20, 2011
  2. Jens LehmannMar 20, 2011
  3. Junio C HamanoMar 20, 2011
  4. Junio C HamanoMar 20, 2011
  5. Matthieu MoyMar 20, 2011
  6. Junio C HamanoMar 21, 2011
  7. Jeff KingMar 21, 2011
  8. Junio C HamanoMar 21, 2011
  9. add: make "add -u/-A" update full tree without pathspecJunio C Hamano, Mar 23, 2011
  10. add: make "add -u/-A" update full tree without pathspec (step 2)Junio C Hamano, Mar 23, 2011
  11. add: make "add -u/-A" update full tree without pathspec (step 3)Junio C Hamano, Mar 23, 2011
  12. Nguyen Thai Ngoc DuyMar 23, 2011
  13. Junio C HamanoMar 23, 2011
  14. Ævar Arnfjörð BjarmasonMar 22, 2011
  15. Junio C HamanoMar 22, 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.