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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Junio C Hamano <gitster@xxxxxxxxx> writes:

> * 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@xxxxxxxxx>
---
 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

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]