From: Junio C Hamano <gitster@pobox.com>
To: git@vger.kernel.org
Subject: [PATCH 3/3] git add <pathspec>... defaults to "-A"
Date: Sat, 9 Mar 2013 00:22:38 -0800 [thread overview]
Message-ID: <1362817358-24356-4-git-send-email-gitster@pobox.com> (raw)
In-Reply-To: <1362817358-24356-1-git-send-email-gitster@pobox.com>
Make "git add <pathspec>..." notice paths that have been removed
from the working tree, i.e. a synonym to "git add -A <pathspec>...".
Given that "git add <pathspec>" is to update the index with the
state of the named part of the working tree as a whole, it makes it
more intuitive, and also makes it possible to simplify the advice we
give while marking the paths the user finished resolving conflicts
with. We used to say "to record removal as a resolution, remove the
path from the working tree and say 'git rm'; for all other cases,
edit the path in the working tree and say 'git add'", but we can now
say "update the path in the working tree and say 'git add'" instead.
Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
Documentation/git-add.txt | 18 +++++++++++-------
builtin/add.c | 33 +++------------------------------
2 files changed, 14 insertions(+), 37 deletions(-)
diff --git a/Documentation/git-add.txt b/Documentation/git-add.txt
index 5c501a2..e96fa84 100644
--- a/Documentation/git-add.txt
+++ b/Documentation/git-add.txt
@@ -53,8 +53,14 @@ OPTIONS
Files to add content from. Fileglobs (e.g. `*.c`) can
be given to add all matching files. Also a
leading directory name (e.g. `dir` to add `dir/file1`
- and `dir/file2`) can be given to add all files in the
- directory, recursively.
+ and `dir/file2`) can be given to update the index to
+ match the current state of the directory as a whole (e.g.
+ specifying `dir` will record not just a file `dir/file1`
+ modified in the working tree, a file `dir/file2` added to
+ the working tree, but also a file `dir/file3` removed from
+ the working tree. Note that older versions of Git used
+ to ignore removed files; use `--no-all` option if you want
+ to add modified or new files but ignore removed ones.
-n::
--dry-run::
@@ -127,11 +133,9 @@ of Git, hence the form without <pathspec> should not be used.
files that have been removed from the working tree. This
option is a no-op when no <pathspec> is used.
+
-This option is primarily to help the current users of Git, whose
-"git add <pathspec>..." ignores removed files. In future versions
-of Git, "git add <pathspec>..." will be a synonym to "git add -A
-<pathspec>..." and "git add --no-all <pathspec>..." will behave like
-today's "git add <pathspec>...", ignoring removed files.
+This option is primarily to help users who are used to older
+versions of Git, whose "git add <pathspec>..." was a synonym
+to "git add --no-all <pathspec...", i.e. ignored removed files.
-N::
--intent-to-add::
diff --git a/builtin/add.c b/builtin/add.c
index f8f6c9e..21c685f 100644
--- a/builtin/add.c
+++ b/builtin/add.c
@@ -273,7 +273,7 @@ N_("The following paths are ignored by one of your .gitignore files:\n");
static int verbose, show_only, ignored_too, refresh_only;
static int ignore_add_errors, intent_to_add, ignore_missing;
-#define ADDREMOVE_DEFAULT 0 /* Change to 1 in Git 2.0 */
+#define ADDREMOVE_DEFAULT 1
static int addremove = ADDREMOVE_DEFAULT;
static int addremove_explicit = -1; /* unspecified */
@@ -354,18 +354,6 @@ static void warn_pathless_add(const char *option_name, const char *short_name) {
option_name, short_name);
}
-static int directory_given(int argc, const char **argv)
-{
- struct stat st;
-
- while (argc--) {
- if (!lstat(*argv, &st) && S_ISDIR(st.st_mode))
- return 1;
- argv++;
- }
- return 0;
-}
-
int cmd_add(int argc, const char **argv, const char *prefix)
{
int exit_status = 0;
@@ -401,24 +389,9 @@ int cmd_add(int argc, const char **argv, const char *prefix)
if (addremove && take_worktree_changes)
die(_("-A and -u are mutually incompatible"));
- /*
- * Warn when "git add pathspec..." was given without "-u" or "-A"
- * and pathspec... contains a directory name.
- */
- if (!take_worktree_changes && addremove_explicit < 0 &&
- directory_given(argc, argv))
- warning(_("In Git 2.0, 'git add <pathspec>...' will also update the\n"
- "index for paths removed from the working tree that match\n"
- "the given pathspec. If you want to 'add' only changed\n"
- "or newly created paths, say 'git add --no-all <pathspec>...'"
- " instead."));
-
if (!take_worktree_changes && addremove_explicit < 0 && argc)
- /*
- * Turn "git add pathspec..." to "git add -A pathspec..."
- * in Git 2.0 but not yet
- */
- ; /* addremove = 1; */
+ /* Turn "git add pathspec..." to "git add -A pathspec..." */
+ addremove = 1;
if (!show_only && ignore_missing)
die(_("Option --ignore-missing can only be used together with --dry-run"));
--
1.8.2-rc3-203-gc9aaab5
prev parent reply other threads:[~2013-03-09 8:23 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-03-09 8:22 [PATCH 0/3] Make "git add dir/" notice removed "dir/file" Junio C Hamano
2013-03-09 8:22 ` [PATCH 1/3] builtin/add.c: simplify boolean variables Junio C Hamano
2013-03-09 8:22 ` [PATCH 2/3] git add: start preparing for "git add <pathspec>..." to default to "-A" Junio C Hamano
2013-03-09 8:22 ` Junio C Hamano [this message]
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=1362817358-24356-4-git-send-email-gitster@pobox.com \
--to=gitster@pobox.com \
--cc=git@vger.kernel.org \
/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).