git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: git@vger.kernel.org
Cc: "Nguyễn Thái Ngọc Duy" <pclouds@gmail.com>
Subject: Re: What's cooking in git.git (Mar 2011, #02; Sun, 20)
Date: Sun, 20 Mar 2011 14:06:18 -0700	[thread overview]
Message-ID: <7vtyexv6wl.fsf@alter.siamese.dyndns.org> (raw)
In-Reply-To: <7vy649vah1.fsf@alter.siamese.dyndns.org> (Junio C. Hamano's message of "Sun, 20 Mar 2011 12:49:14 -0700")

Junio C Hamano <gitster@pobox.com> 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@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

  parent reply	other threads:[~2011-03-20 21:06 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-03-20 19:49 What's cooking in git.git (Mar 2011, #02; Sun, 20) Junio C Hamano
2011-03-20 20:43 ` Jens Lehmann
2011-03-20 21:06 ` Junio C Hamano [this message]
2011-03-20 21:22   ` Junio C Hamano
2011-03-20 21:36     ` Matthieu Moy
2011-03-21  0:06       ` Junio C Hamano
2011-03-21 11:16         ` Jeff King
2011-03-21 14:28           ` Junio C Hamano
2011-03-23  0:02           ` [PATCH] add: make "add -u/-A" update full tree without pathspec Junio C Hamano
2011-03-23  5:17             ` [PATCH] add: make "add -u/-A" update full tree without pathspec (step 2) Junio C Hamano
2011-03-23  5:19               ` [PATCH] add: make "add -u/-A" update full tree without pathspec (step 3) Junio C Hamano
2011-03-23 14:02                 ` Nguyen Thai Ngoc Duy
2011-03-23 15:54                   ` Junio C Hamano
2011-03-22 10:57 ` What's cooking in git.git (Mar 2011, #02; Sun, 20) Ævar Arnfjörð Bjarmason
2011-03-22 18:00   ` 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=7vtyexv6wl.fsf@alter.siamese.dyndns.org \
    --to=gitster@pobox.com \
    --cc=git@vger.kernel.org \
    --cc=pclouds@gmail.com \
    /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).