aboutsummaryrefslogtreecommitdiff
path: root/builtin/add.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2013-04-22 14:30:22 -0700
committerJunio C Hamano <gitster@pobox.com>2013-04-22 21:06:06 -0700
commitfdc97abd4a8b04781356dc561b4ba5a634f9854f (patch)
tree9935522fd27a8962b2567bca42997504408529fb /builtin/add.c
parent4c7114308ea12de7b69a3b282881398212dec8dd (diff)
downloadgit-fdc97abd4a8b04781356dc561b4ba5a634f9854f.tar.gz
git-fdc97abd4a8b04781356dc561b4ba5a634f9854f.tar.xz
git add <pathspec>... defaults to "-A"
Make "git add <pathspec>..." notice paths that have been removed from the working tree, i.e. the same as "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. As promised, this merges the temporary update_files_in_cache() helper function back to add_files_to_cache() function. Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin/add.c')
-rw-r--r--builtin/add.c43
1 files changed, 4 insertions, 39 deletions
diff --git a/builtin/add.c b/builtin/add.c
index c55615be4..22c5ff579 100644
--- a/builtin/add.c
+++ b/builtin/add.c
@@ -28,9 +28,6 @@ struct update_callback_data {
int add_errors;
const char *implicit_dot;
size_t implicit_dot_len;
-
- /* only needed for 2.0 transition preparation */
- int warn_add_would_remove;
};
static const char *option_with_implicit_dot;
@@ -96,24 +93,6 @@ static int fix_unmerged_status(struct diff_filepair *p,
return DIFF_STATUS_MODIFIED;
}
-static const char *add_would_remove_warning = N_(
- "You ran 'git add' with neither '-A (--all)' or '--ignore-removal',\n"
-"whose behaviour will change in Git 2.0 with respect to paths you removed.\n"
-"Paths like '%s' that are\n"
-"removed from your working tree are ignored with this version of Git.\n"
-"\n"
-"* 'git add --ignore-removal <pathspec>', which is the current default,\n"
-" ignores paths you removed from your working tree.\n"
-"\n"
-"* 'git add --all <pathspec>' will let you also record the removals.\n"
-"\n"
-"Run 'git status' to check the paths you removed from your working tree.\n");
-
-static void warn_add_would_remove(const char *path)
-{
- warning(_(add_would_remove_warning), path);
-}
-
static void update_callback(struct diff_queue_struct *q,
struct diff_options *opt, void *cbdata)
{
@@ -151,10 +130,6 @@ static void update_callback(struct diff_queue_struct *q,
}
break;
case DIFF_STATUS_DELETED:
- if (data->warn_add_would_remove) {
- warn_add_would_remove(path);
- data->warn_add_would_remove = 0;
- }
if (data->flags & ADD_CACHE_IGNORE_REMOVAL)
break;
if (!(data->flags & ADD_CACHE_PRETEND))
@@ -378,7 +353,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 */
@@ -476,20 +451,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... covers a removed path.
- */
- memset(&update_data, 0, sizeof(update_data));
- if (!take_worktree_changes && addremove_explicit < 0)
- update_data.warn_add_would_remove = 1;
-
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"));
@@ -579,6 +543,7 @@ int cmd_add(int argc, const char **argv, const char *prefix)
plug_bulk_checkin();
+ memset(&update_data, 0, sizeof(update_data));
if ((flags & ADD_CACHE_IMPLICIT_DOT) && prefix) {
/*
* Check for modified files throughout the worktree so