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

Re: What's cooking in git.git (Mar 2011, #02; Sun, 20)

From
Junio C Hamano <gitster@pobox.com>
Date
Mar 20, 2011, 21:06 UTC
Message-ID
<7vtyexv6wl.fsf@alter.siamese.dyndns.org>
In-Reply-To
<7vy649vah1.fsf@alter.siamese.dyndns.org>
Junio C Hamano <gitster@pobox.com> writes:
Show 15 quoted lines
> * nd/rfc-add-u-full-tree (2011-02-07) 1 commit
>  - add: make "add -u" update full tree without pathspec
>
> A three-phase migration that:
>
>  (1) first only warns when we would deviate from traditional behaviour and
>      suggest adding "." if the user wants to limit it to cwd, but doesn't
>      actually add full-tree, in the next release;
>
>  (2) warn that we have changed the behaviour and suggest adding "." if the
>      user wants to limit it to cwd, and actually do full-tree, in 1.8.0;
>
>  (3) remove the warning, in 1.8.X (for X at least 2 or more).
>
> would be a good way forward.
... and here is how the first step would look like.
-- >8 --
Subject: [PATCH] add -u: warn when ran without pathspec from a subdirectory

We will be changing the behaviour of "add -u" without any pathspec to be tree-wide in future releases; warn the users and train them to say "add -u ." to help smoother migration.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
 builtin/add.c |   18 ++++++++++++++++++
 1 files changed, 18 insertions(+), 0 deletions(-)
diff --git a/builtin/add.c b/builtin/add.c
index e127d5a..443d3bb 100644
--- a/builtin/add.c
+++ b/builtin/add.c
@@ -359,6 +359,21 @@ static int add_files(struct dir_struct *dir, int flags)
 	return exit_status;
 }
 
+static const char *warn_add_u_without_pathspec_msg[] = {
+	"In release 1.8.0, running 'git add -u' from a subdirectory",
+	"without giving any pathspec WILL take effect on the whole",
+	"working tree, not just the part under the current directory.",
+	"Please make it a habit to say 'git add -u .' when you mean",
+	"to only add paths under the current directory."
+};
+
+static void warn_add_u_without_pathspec(void)
+{
+	int i;
+	for (i = 0; i < ARRAY_SIZE(warn_add_u_without_pathspec_msg); i++)
+		warning("%s", warn_add_u_without_pathspec_msg[i]);
+}
+
 int cmd_add(int argc, const char **argv, const char *prefix)
 {
 	int exit_status = 0;
@@ -390,6 +405,9 @@ 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) {
 		static const char *here[2] = { ".", NULL };
+
+		if (take_worktree_changes && prefix)
+			warn_add_u_without_pathspec();
 		argc = 1;
 		argv = here;
 	}
-- 
1.7.4.1.514.ga171c
Previous: Jens LehmannNext: Junio C Hamano
Message 3 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.