* [PATCH v2 0/2] "git add -u/-A" from future
@ 2013-03-09 8:23 Junio C Hamano
2013-03-09 8:23 ` [PATCH v2 1/2] require pathspec for "git add -u/-A" Junio C Hamano
2013-03-09 8:23 ` [PATCH v2 2/2] git add: -u/-A now affects the entire working tree Junio C Hamano
0 siblings, 2 replies; 3+ messages in thread
From: Junio C Hamano @ 2013-03-09 8:23 UTC (permalink / raw)
To: git
Here are two future steps to update the behaviour of "add -u/-A" run
without pathspec towards Git 2.0; the first step may probably be
optional, but it is included for completeness.
Rebased on top of the recent "git add -u/-A" documentation updates
5cae93566027 (add: Clarify documentation of -A and -u, 2013-03-07)
by Greg Price.
Junio C Hamano (2):
require pathspec for "git add -u/-A"
git add: -u/-A now affects the entire working tree
Documentation/git-add.txt | 16 ++++++++--------
builtin/add.c | 49 ++++-------------------------------------------
2 files changed, 12 insertions(+), 53 deletions(-)
--
1.8.2-rc3-203-gc9aaab5
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH v2 1/2] require pathspec for "git add -u/-A"
2013-03-09 8:23 [PATCH v2 0/2] "git add -u/-A" from future Junio C Hamano
@ 2013-03-09 8:23 ` Junio C Hamano
2013-03-09 8:23 ` [PATCH v2 2/2] git add: -u/-A now affects the entire working tree Junio C Hamano
1 sibling, 0 replies; 3+ messages in thread
From: Junio C Hamano @ 2013-03-09 8:23 UTC (permalink / raw)
To: git
As promised in 0fa2eb530fb7 (add: warn when -u or -A is used without
pathspec, 2013-01-28), "git add -u/-A" that is run without pathspec
in a subdirectory will stop working sometime before Git 2.0, to wean
users off of the old default, in preparation for adopting the new
default in Git 2.0.
Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
Documentation/git-add.txt | 24 ++++++++++++++++--------
builtin/add.c | 38 ++++++++++++++++++--------------------
2 files changed, 34 insertions(+), 28 deletions(-)
diff --git a/Documentation/git-add.txt b/Documentation/git-add.txt
index b0944e5..b849b78 100644
--- a/Documentation/git-add.txt
+++ b/Documentation/git-add.txt
@@ -104,10 +104,14 @@ apply to the index. See EDITING PATCHES below.
<pathspec>. This removes as well as modifies index entries to
match the working tree, but adds no new files.
+
-If no <pathspec> is given, the current version of Git defaults to
-"."; in other words, update all tracked files in the current directory
-and its subdirectories. This default will change in a future version
-of Git, hence the form without <pathspec> should not be used.
+If no <pathspec> is given when `-u` 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.
-A::
--all::
@@ -116,10 +120,14 @@ of Git, hence the form without <pathspec> should not be used.
entry. This adds, modifies, and removes index entries to
match the working tree.
+
-If no <pathspec> is given, the current version of Git defaults to
-"."; in other words, update all files in the current directory
-and its subdirectories. This default will change in a future version
-of Git, hence the form without <pathspec> should not be used.
+If no <pathspec> is given when `-A` option is used, Git used
+to update all 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 -A .` when they mean it.
-N::
--intent-to-add::
diff --git a/builtin/add.c b/builtin/add.c
index 0dd014e..4b9d57c 100644
--- a/builtin/add.c
+++ b/builtin/add.c
@@ -321,30 +321,28 @@ static int add_files(struct dir_struct *dir, int flags)
return exit_status;
}
-static void warn_pathless_add(const char *option_name, const char *short_name) {
+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". For now, we warn and
- * keep the old behavior. Later, this warning can be
- * turned into a die(...), and eventually we may
- * reallow the command with a new behavior.
+ * "git add -u" or "git add -A". In the previous release,
+ * we kept the old behavior but gave a big warning.
*/
- warning(_("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 .)\n"
- "\n"
- "With the current Git version, the command is restricted to the current directory."),
+ 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);
@@ -392,8 +390,8 @@ int cmd_add(int argc, const char **argv, const char *prefix)
if (option_with_implicit_dot && !argc) {
static const char *here[2] = { ".", NULL };
if (prefix)
- warn_pathless_add(option_with_implicit_dot,
- short_option_with_implicit_dot);
+ die_on_pathless_add(option_with_implicit_dot,
+ short_option_with_implicit_dot);
argc = 1;
argv = here;
}
--
1.8.2-rc3-203-gc9aaab5
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [PATCH v2 2/2] git add: -u/-A now affects the entire working tree
2013-03-09 8:23 [PATCH v2 0/2] "git add -u/-A" from future Junio C Hamano
2013-03-09 8:23 ` [PATCH v2 1/2] require pathspec for "git add -u/-A" Junio C Hamano
@ 2013-03-09 8:23 ` Junio C Hamano
1 sibling, 0 replies; 3+ messages in thread
From: Junio C Hamano @ 2013-03-09 8:23 UTC (permalink / raw)
To: git
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 | 24 ++++++++----------------
builtin/add.c | 47 ++++-------------------------------------------
2 files changed, 12 insertions(+), 59 deletions(-)
diff --git a/Documentation/git-add.txt b/Documentation/git-add.txt
index b849b78..02b99cb 100644
--- a/Documentation/git-add.txt
+++ b/Documentation/git-add.txt
@@ -104,14 +104,10 @@ apply to the index. See EDITING PATCHES below.
<pathspec>. This removes as well as modifies index entries to
match the working tree, but adds no new files.
+
-If no <pathspec> is given when `-u` 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` 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::
@@ -120,14 +116,10 @@ fingers to explicitly type `git add -u .` when they mean it.
entry. This adds, modifies, and removes index entries to
match the working tree.
+
-If no <pathspec> is given when `-A` option is used, Git used
-to update all 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 -A .` when they mean it.
+If no <pathspec> is given when `-A` option is used, all
+files in the entire working tree are updated (old versions
+of Git used to limit the update to the current directory and its
+subdirectories).
-N::
--intent-to-add::
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-203-gc9aaab5
^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2013-03-09 8:23 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-03-09 8:23 [PATCH v2 0/2] "git add -u/-A" from future Junio C Hamano
2013-03-09 8:23 ` [PATCH v2 1/2] require pathspec for "git add -u/-A" Junio C Hamano
2013-03-09 8:23 ` [PATCH v2 2/2] git add: -u/-A now affects the entire working tree Junio C Hamano
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).