{"thread":{"id":"33114","subject":"[PATCH v2 0/2] \"git add -u/-A\" from future","startedAt":"2013-03-09T08:23:09Z","lastAt":"2013-03-09T08:23:11Z","messageCount":3,"participants":["Junio C Hamano"],"isPatch":true,"patchVersion":2,"patchTotal":2},"messages":[{"id":"210879","messageId":"1362817391-24452-1-git-send-email-gitster@pobox.com","threadId":"33114","inReplyTo":null,"subject":"[PATCH v2 0/2] \"git add -u/-A\" from future","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2013-03-09T08:23:09Z","receivedAt":"2013-03-09T08:23:09Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Here are two future steps to update the behaviour of \"add -u/-A\" run\nwithout pathspec towards Git 2.0; the first step may probably be\noptional, but it is included for completeness.\n\nRebased on top of the recent \"git add -u/-A\" documentation updates\n5cae93566027 (add: Clarify documentation of -A and -u, 2013-03-07)\nby Greg Price.\n\nJunio C Hamano (2):\n  require pathspec for \"git add -u/-A\"\n  git add: -u/-A now affects the entire working tree\n\n Documentation/git-add.txt | 16 ++++++++--------\n builtin/add.c             | 49 ++++-------------------------------------------\n 2 files changed, 12 insertions(+), 53 deletions(-)\n\n-- \n1.8.2-rc3-203-gc9aaab5\n"},{"id":"210881","messageId":"1362817391-24452-2-git-send-email-gitster@pobox.com","threadId":"33114","inReplyTo":"1362817391-24452-1-git-send-email-gitster@pobox.com","subject":"[PATCH v2 1/2] require pathspec for \"git add -u/-A\"","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2013-03-09T08:23:10Z","receivedAt":"2013-03-09T08:23:10Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"As promised in 0fa2eb530fb7 (add: warn when -u or -A is used without\npathspec, 2013-01-28), \"git add -u/-A\" that is run without pathspec\nin a subdirectory will stop working sometime before Git 2.0, to wean\nusers off of the old default, in preparation for adopting the new\ndefault in Git 2.0.\n\nSigned-off-by: Junio C Hamano <gitster@pobox.com>\n---\n Documentation/git-add.txt | 24 ++++++++++++++++--------\n builtin/add.c             | 38 ++++++++++++++++++--------------------\n 2 files changed, 34 insertions(+), 28 deletions(-)\n\ndiff --git a/Documentation/git-add.txt b/Documentation/git-add.txt\nindex b0944e5..b849b78 100644\n--- a/Documentation/git-add.txt\n+++ b/Documentation/git-add.txt\n@@ -104,10 +104,14 @@ apply to the index. See EDITING PATCHES below.\n \t<pathspec>.  This removes as well as modifies index entries to\n \tmatch the working tree, but adds no new files.\n +\n-If no <pathspec> is given, the current version of Git defaults to\n-\".\"; in other words, update all tracked files in the current directory\n-and its subdirectories. This default will change in a future version\n-of Git, hence the form without <pathspec> should not be used.\n+If no <pathspec> is given when `-u` option is used, Git used\n+to update all tracked files in the current directory and its\n+subdirectories. We would eventually want to change this to operate\n+on the entire working tree, not limiting it to the current\n+directory, to make it consistent with `git commit -a` and other\n+commands.  In order to avoid harming users who are used to the old\n+default, Git *errors out* when no <pathspec> is given to train their\n+fingers to explicitly type `git add -u .` when they mean it.\n \n -A::\n --all::\n@@ -116,10 +120,14 @@ of Git, hence the form without <pathspec> should not be used.\n \tentry.\tThis adds, modifies, and removes index entries to\n \tmatch the working tree.\n +\n-If no <pathspec> is given, the current version of Git defaults to\n-\".\"; in other words, update all files in the current directory\n-and its subdirectories. This default will change in a future version\n-of Git, hence the form without <pathspec> should not be used.\n+If no <pathspec> is given when `-A` option is used, Git used\n+to update all files in the current directory and its\n+subdirectories. We would eventually want to change this to operate\n+on the entire working tree, not limiting it to the current\n+directory, to make it consistent with `git commit -a` and other\n+commands.  In order to avoid harming users who are used to the old\n+default, Git *errors out* when no <pathspec> is given to train their\n+fingers to explicitly type `git add -A .` when they mean it.\n \n -N::\n --intent-to-add::\ndiff --git a/builtin/add.c b/builtin/add.c\nindex 0dd014e..4b9d57c 100644\n--- a/builtin/add.c\n+++ b/builtin/add.c\n@@ -321,30 +321,28 @@ static int add_files(struct dir_struct *dir, int flags)\n \treturn exit_status;\n }\n \n-static void warn_pathless_add(const char *option_name, const char *short_name) {\n+static void die_on_pathless_add(const char *option_name, const char *short_name)\n+{\n \t/*\n \t * To be consistent with \"git add -p\" and most Git\n \t * commands, we should default to being tree-wide, but\n \t * this is not the original behavior and can't be\n \t * changed until users trained themselves not to type\n-\t * \"git add -u\" or \"git add -A\". For now, we warn and\n-\t * keep the old behavior. Later, this warning can be\n-\t * turned into a die(...), and eventually we may\n-\t * reallow the command with a new behavior.\n+\t * \"git add -u\" or \"git add -A\". In the previous release,\n+\t * we kept the old behavior but gave a big warning.\n \t */\n-\twarning(_(\"The behavior of 'git add %s (or %s)' with no path argument from a\\n\"\n-\t\t  \"subdirectory of the tree will change in Git 2.0 and should not be used anymore.\\n\"\n-\t\t  \"To add content for the whole tree, run:\\n\"\n-\t\t  \"\\n\"\n-\t\t  \"  git add %s :/\\n\"\n-\t\t  \"  (or git add %s :/)\\n\"\n-\t\t  \"\\n\"\n-\t\t  \"To restrict the command to the current directory, run:\\n\"\n-\t\t  \"\\n\"\n-\t\t  \"  git add %s .\\n\"\n-\t\t  \"  (or git add %s .)\\n\"\n-\t\t  \"\\n\"\n-\t\t  \"With the current Git version, the command is restricted to the current directory.\"),\n+\tdie(_(\"The behavior of 'git add %s (or %s)' with no path argument from a\\n\"\n+\t      \"subdirectory of the tree will change in Git 2.0 and should not be \"\n+\t      \"used anymore.\\n\"\n+\t      \"To add content for the whole tree, run:\\n\"\n+\t      \"\\n\"\n+\t      \"  git add %s :/\\n\"\n+\t      \"  (or git add %s :/)\\n\"\n+\t      \"\\n\"\n+\t      \"To restrict the command to the current directory, run:\\n\"\n+\t      \"\\n\"\n+\t      \"  git add %s .\\n\"\n+\t      \"  (or git add %s .)\"),\n \t\toption_name, short_name,\n \t\toption_name, short_name,\n \t\toption_name, short_name);\n@@ -392,8 +390,8 @@ int cmd_add(int argc, const char **argv, const char *prefix)\n \tif (option_with_implicit_dot && !argc) {\n \t\tstatic const char *here[2] = { \".\", NULL };\n \t\tif (prefix)\n-\t\t\twarn_pathless_add(option_with_implicit_dot,\n-\t\t\t\t\t  short_option_with_implicit_dot);\n+\t\t\tdie_on_pathless_add(option_with_implicit_dot,\n+\t\t\t\t\t    short_option_with_implicit_dot);\n \t\targc = 1;\n \t\targv = here;\n \t}\n-- \n1.8.2-rc3-203-gc9aaab5\n"},{"id":"210880","messageId":"1362817391-24452-3-git-send-email-gitster@pobox.com","threadId":"33114","inReplyTo":"1362817391-24452-1-git-send-email-gitster@pobox.com","subject":"[PATCH v2 2/2] git add: -u/-A now affects the entire working tree","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2013-03-09T08:23:11Z","receivedAt":"2013-03-09T08:23:11Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"As promised in 0fa2eb530fb7 (add: warn when -u or -A is used without\npathspec, 2013-01-28), in Git 2.0, \"git add -u/-A\" that is run\nwithout pathspec in a subdirectory updates all updated paths in the\nentire working tree, not just the current directory and its\nsubdirectories.\n\nSigned-off-by: Junio C Hamano <gitster@pobox.com>\n---\n Documentation/git-add.txt | 24 ++++++++----------------\n builtin/add.c             | 47 ++++-------------------------------------------\n 2 files changed, 12 insertions(+), 59 deletions(-)\n\ndiff --git a/Documentation/git-add.txt b/Documentation/git-add.txt\nindex b849b78..02b99cb 100644\n--- a/Documentation/git-add.txt\n+++ b/Documentation/git-add.txt\n@@ -104,14 +104,10 @@ apply to the index. See EDITING PATCHES below.\n \t<pathspec>.  This removes as well as modifies index entries to\n \tmatch the working tree, but adds no new files.\n +\n-If no <pathspec> is given when `-u` option is used, Git used\n-to update all tracked files in the current directory and its\n-subdirectories. We would eventually want to change this to operate\n-on the entire working tree, not limiting it to the current\n-directory, to make it consistent with `git commit -a` and other\n-commands.  In order to avoid harming users who are used to the old\n-default, Git *errors out* when no <pathspec> is given to train their\n-fingers to explicitly type `git add -u .` when they mean it.\n+If no <pathspec> is given when `-u` option is used, all\n+tracked files in the entire working tree are updated (old versions\n+of Git used to limit the update to the current directory and its\n+subdirectories).\n \n -A::\n --all::\n@@ -120,14 +116,10 @@ fingers to explicitly type `git add -u .` when they mean it.\n \tentry.\tThis adds, modifies, and removes index entries to\n \tmatch the working tree.\n +\n-If no <pathspec> is given when `-A` option is used, Git used\n-to update all files in the current directory and its\n-subdirectories. We would eventually want to change this to operate\n-on the entire working tree, not limiting it to the current\n-directory, to make it consistent with `git commit -a` and other\n-commands.  In order to avoid harming users who are used to the old\n-default, Git *errors out* when no <pathspec> is given to train their\n-fingers to explicitly type `git add -A .` when they mean it.\n+If no <pathspec> is given when `-A` option is used, all\n+files in the entire working tree are updated (old versions\n+of Git used to limit the update to the current directory and its\n+subdirectories).\n \n -N::\n --intent-to-add::\ndiff --git a/builtin/add.c b/builtin/add.c\nindex 4b9d57c..6cd063f 100644\n--- a/builtin/add.c\n+++ b/builtin/add.c\n@@ -321,33 +321,6 @@ static int add_files(struct dir_struct *dir, int flags)\n \treturn exit_status;\n }\n \n-static void die_on_pathless_add(const char *option_name, const char *short_name)\n-{\n-\t/*\n-\t * To be consistent with \"git add -p\" and most Git\n-\t * commands, we should default to being tree-wide, but\n-\t * this is not the original behavior and can't be\n-\t * changed until users trained themselves not to type\n-\t * \"git add -u\" or \"git add -A\". In the previous release,\n-\t * we kept the old behavior but gave a big warning.\n-\t */\n-\tdie(_(\"The behavior of 'git add %s (or %s)' with no path argument from a\\n\"\n-\t      \"subdirectory of the tree will change in Git 2.0 and should not be \"\n-\t      \"used anymore.\\n\"\n-\t      \"To add content for the whole tree, run:\\n\"\n-\t      \"\\n\"\n-\t      \"  git add %s :/\\n\"\n-\t      \"  (or git add %s :/)\\n\"\n-\t      \"\\n\"\n-\t      \"To restrict the command to the current directory, run:\\n\"\n-\t      \"\\n\"\n-\t      \"  git add %s .\\n\"\n-\t      \"  (or git add %s .)\"),\n-\t\toption_name, short_name,\n-\t\toption_name, short_name,\n-\t\toption_name, short_name);\n-}\n-\n int cmd_add(int argc, const char **argv, const char *prefix)\n {\n \tint exit_status = 0;\n@@ -358,8 +331,6 @@ int cmd_add(int argc, const char **argv, const char *prefix)\n \tint add_new_files;\n \tint require_pathspec;\n \tchar *seen = NULL;\n-\tconst char *option_with_implicit_dot = NULL;\n-\tconst char *short_option_with_implicit_dot = NULL;\n \n \tgit_config(add_config, NULL);\n \n@@ -379,21 +350,11 @@ int cmd_add(int argc, const char **argv, const char *prefix)\n \t\tdie(_(\"-A and -u are mutually incompatible\"));\n \tif (!show_only && ignore_missing)\n \t\tdie(_(\"Option --ignore-missing can only be used together with --dry-run\"));\n-\tif (addremove) {\n-\t\toption_with_implicit_dot = \"--all\";\n-\t\tshort_option_with_implicit_dot = \"-A\";\n-\t}\n-\tif (take_worktree_changes) {\n-\t\toption_with_implicit_dot = \"--update\";\n-\t\tshort_option_with_implicit_dot = \"-u\";\n-\t}\n-\tif (option_with_implicit_dot && !argc) {\n-\t\tstatic const char *here[2] = { \".\", NULL };\n-\t\tif (prefix)\n-\t\t\tdie_on_pathless_add(option_with_implicit_dot,\n-\t\t\t\t\t    short_option_with_implicit_dot);\n+\n+\tif ((addremove || take_worktree_changes) && !argc) {\n+\t\tstatic const char *whole[2] = { \":/\", NULL };\n \t\targc = 1;\n-\t\targv = here;\n+\t\targv = whole;\n \t}\n \n \tadd_new_files = !take_worktree_changes && !refresh_only;\n-- \n1.8.2-rc3-203-gc9aaab5\n"}]}