git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: git@vger.kernel.org
Cc: Matthieu Moy <Matthieu.Moy@imag.fr>, Jeff King <peff@peff.net>
Subject: [PATCH 2/2] git add: -u/-A now affects the entire working tree
Date: Fri,  8 Mar 2013 15:54:49 -0800	[thread overview]
Message-ID: <1362786889-28688-3-git-send-email-gitster@pobox.com> (raw)
In-Reply-To: <1362786889-28688-1-git-send-email-gitster@pobox.com>

As promised in 0fa2eb530fb7 (add: warn when -u or -A is used without
pathspec, 2013-01-28), in Git 2.0, "git add -u/-A" that is run
without pathspec in a subdirectory updates all updated paths in the
entire working tree, not just the current directory and its
subdirectories.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
 Documentation/git-add.txt | 12 ++++--------
 builtin/add.c             | 47 ++++-------------------------------------------
 2 files changed, 8 insertions(+), 51 deletions(-)

diff --git a/Documentation/git-add.txt b/Documentation/git-add.txt
index 1ea1d39..15a8859 100644
--- a/Documentation/git-add.txt
+++ b/Documentation/git-add.txt
@@ -107,14 +107,10 @@ apply to the index. See EDITING PATCHES below.
 	from the index if the corresponding files in the working tree
 	have been removed.
 +
-If no <pathspec> is given when `-u` or `-A` option is used, Git used
-to update all tracked files in the current directory and its
-subdirectories. We would eventually want to change this to operate
-on the entire working tree, not limiting it to the current
-directory, to make it consistent with `git commit -a` and other
-commands.  In order to avoid harming users who are used to the old
-default, Git *errors out* when no <pathspec> is given to train their
-fingers to explicitly type `git add -u .` when they mean it.
+If no <pathspec> is given when `-u` or `-A` option is used, all
+tracked files in the entire working tree are updated (old versions
+of Git used to limit the update to the current directory and its
+subdirectories).
 
 -A::
 --all::
diff --git a/builtin/add.c b/builtin/add.c
index 4b9d57c..6cd063f 100644
--- a/builtin/add.c
+++ b/builtin/add.c
@@ -321,33 +321,6 @@ static int add_files(struct dir_struct *dir, int flags)
 	return exit_status;
 }
 
-static void die_on_pathless_add(const char *option_name, const char *short_name)
-{
-	/*
-	 * To be consistent with "git add -p" and most Git
-	 * commands, we should default to being tree-wide, but
-	 * this is not the original behavior and can't be
-	 * changed until users trained themselves not to type
-	 * "git add -u" or "git add -A". In the previous release,
-	 * we kept the old behavior but gave a big warning.
-	 */
-	die(_("The behavior of 'git add %s (or %s)' with no path argument from a\n"
-	      "subdirectory of the tree will change in Git 2.0 and should not be "
-	      "used anymore.\n"
-	      "To add content for the whole tree, run:\n"
-	      "\n"
-	      "  git add %s :/\n"
-	      "  (or git add %s :/)\n"
-	      "\n"
-	      "To restrict the command to the current directory, run:\n"
-	      "\n"
-	      "  git add %s .\n"
-	      "  (or git add %s .)"),
-		option_name, short_name,
-		option_name, short_name,
-		option_name, short_name);
-}
-
 int cmd_add(int argc, const char **argv, const char *prefix)
 {
 	int exit_status = 0;
@@ -358,8 +331,6 @@ int cmd_add(int argc, const char **argv, const char *prefix)
 	int add_new_files;
 	int require_pathspec;
 	char *seen = NULL;
-	const char *option_with_implicit_dot = NULL;
-	const char *short_option_with_implicit_dot = NULL;
 
 	git_config(add_config, NULL);
 
@@ -379,21 +350,11 @@ int cmd_add(int argc, const char **argv, const char *prefix)
 		die(_("-A and -u are mutually incompatible"));
 	if (!show_only && ignore_missing)
 		die(_("Option --ignore-missing can only be used together with --dry-run"));
-	if (addremove) {
-		option_with_implicit_dot = "--all";
-		short_option_with_implicit_dot = "-A";
-	}
-	if (take_worktree_changes) {
-		option_with_implicit_dot = "--update";
-		short_option_with_implicit_dot = "-u";
-	}
-	if (option_with_implicit_dot && !argc) {
-		static const char *here[2] = { ".", NULL };
-		if (prefix)
-			die_on_pathless_add(option_with_implicit_dot,
-					    short_option_with_implicit_dot);
+
+	if ((addremove || take_worktree_changes) && !argc) {
+		static const char *whole[2] = { ":/", NULL };
 		argc = 1;
-		argv = here;
+		argv = whole;
 	}
 
 	add_new_files = !take_worktree_changes && !refresh_only;
-- 
1.8.2-rc3-196-gfcda97c

  parent reply	other threads:[~2013-03-08 23:55 UTC|newest]

Thread overview: 51+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-03-08 23:54 [PATCH 0/2] "git add -u/-A" from future Junio C Hamano
2013-03-08 23:54 ` [PATCH 1/2] require pathspec for "git add -u/-A" Junio C Hamano
2013-03-10 15:49   ` Matthieu Moy
2013-03-11  7:04     ` Junio C Hamano
2013-03-11  8:00       ` Matthieu Moy
2013-03-11  8:01         ` [PATCH 1/2] add: update pathless 'add [-u|-A]' warning to reflect change of plan Matthieu Moy
2013-03-11  8:01           ` [PATCH 2/2] add: add a newline at the end of pathless 'add [-u|-A]' warning Matthieu Moy
2013-03-11 16:06             ` Junio C Hamano
2013-04-02 14:43               ` Matthieu Moy
2013-04-02 16:31                 ` Junio C Hamano
2013-04-02 16:57                   ` Matthieu Moy
2013-03-12 11:28     ` [PATCH 1/2] require pathspec for "git add -u/-A" Jeff King
2013-03-12 13:58       ` Matthieu Moy
2013-03-13  4:08         ` Jeff King
2013-03-13  4:10           ` [PATCH 1/2] t2200: check that "add -u" limits itself to subdirectory Jeff King
2013-03-13  8:52             ` Matthieu Moy
2013-03-13 17:44             ` Junio C Hamano
2013-03-14  6:44               ` Jeff King
2013-03-13  4:10           ` [PATCH 2/2] add: respect add.updateroot config option Jeff King
2013-03-13  9:07             ` Matthieu Moy
2013-03-13  9:27               ` Jeff King
2013-03-13 15:51                 ` Junio C Hamano
2013-03-14 12:39                   ` Matthieu Moy
2013-03-19  3:44             ` [PATCH 0/4] make pathless 'add [-u|-A]' warning less noisy Jonathan Nieder
2013-03-19  3:45               ` [PATCH 1/4] add: make pathless 'add [-u|-A]' warning a file-global function Jonathan Nieder
2013-03-19  3:46               ` [PATCH 2/4] add: make warn_pathless_add() a no-op after first call Jonathan Nieder
2013-03-19  3:48               ` [PATCH 3/4] add -u: only show pathless 'add -u' warning when changes exist outside cwd Jonathan Nieder
2013-03-19  4:25                 ` Junio C Hamano
2013-03-19  5:28                   ` Jonathan Nieder
2013-03-19 14:57                     ` Junio C Hamano
2013-03-19  5:34                   ` Jonathan Nieder
2013-03-19  5:37                   ` Duy Nguyen
2013-03-19  5:44                     ` Jonathan Nieder
2013-03-19  6:21                 ` Matthieu Moy
2013-03-19 15:06                   ` Junio C Hamano
2013-03-19 19:06                     ` Jonathan Nieder
2013-03-19 19:47                       ` Junio C Hamano
2013-03-19 20:34                         ` Jonathan Nieder
2013-03-19  3:49               ` [PATCH 4/4] add -A: only show pathless 'add -A' " Jonathan Nieder
2013-03-19  4:25               ` [PATCH 0/4] make pathless 'add [-u|-A]' warning less noisy Jeff King
2013-03-08 23:54 ` Junio C Hamano [this message]
2013-03-19 22:44 ` [PATCH v2 0/6] " Jonathan Nieder
2013-03-19 22:44   ` [PATCH 1/6] t2200: check that "add -u" limits itself to subdirectory Jonathan Nieder
2013-03-19 22:45   ` [PATCH 2/6] add: make pathless 'add [-u|-A]' warning a file-global function Jonathan Nieder
2013-03-19 22:45   ` [PATCH 3/6] add: make warn_pathless_add() a no-op after first call Jonathan Nieder
2013-03-19 22:50   ` [PATCH 4/6] add -u: only show pathless 'add -u' warning when changes exist outside cwd Jonathan Nieder
2013-03-20  5:06     ` Jeff King
2013-03-20 15:10     ` Junio C Hamano
2013-03-19 22:51   ` [PATCH 5/6] add -A: only show pathless 'add -A' " Jonathan Nieder
2013-03-20 15:30     ` Junio C Hamano
2013-03-19 22:53   ` [PATCH 6/6] git add: -u/-A now affects the entire working tree Jonathan Nieder

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=1362786889-28688-3-git-send-email-gitster@pobox.com \
    --to=gitster@pobox.com \
    --cc=Matthieu.Moy@imag.fr \
    --cc=git@vger.kernel.org \
    --cc=peff@peff.net \
    /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).