Skip to content

Commit 838f9c1

Browse files
committed
Merge branch 'jc/add-ignore-removal'
Introduce "--ignore-removal" as a synonym to "--no-all" for "git add", and improve the 2.0 migration warning with it. * jc/add-ignore-removal: git add: rephrase -A/--no-all warning git add: --ignore-removal is a better named --no-all
2 parents 877ee9c + 4c71143 commit 838f9c1

File tree

2 files changed

+23
-10
lines changed

2 files changed

+23
-10
lines changed

Documentation/git-add.txt

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ SYNOPSIS
99
--------
1010
[verse]
1111
'git add' [-n] [-v] [--force | -f] [--interactive | -i] [--patch | -p]
12-
[--edit | -e] [--[no-]all | [--update | -u]] [--intent-to-add | -N]
13-
[--refresh] [--ignore-errors] [--ignore-missing] [--]
14-
[<pathspec>...]
12+
[--edit | -e] [--[no-]all | --[no-]ignore-removal | [--update | -u]]
13+
[--intent-to-add | -N] [--refresh] [--ignore-errors] [--ignore-missing]
14+
[--] [<pathspec>...]
1515

1616
DESCRIPTION
1717
-----------
@@ -111,6 +111,7 @@ of Git, hence the form without <pathspec> should not be used.
111111

112112
-A::
113113
--all::
114+
--no-ignore-removal::
114115
Update the index not only where the working tree has a file
115116
matching <pathspec> but also where the index already has an
116117
entry. This adds, modifies, and removes index entries to
@@ -122,6 +123,7 @@ and its subdirectories. This default will change in a future version
122123
of Git, hence the form without <pathspec> should not be used.
123124

124125
--no-all::
126+
--ignore-removal::
125127
Update the index by adding new files that are unknown to the
126128
index and files modified in the working tree, but ignore
127129
files that have been removed from the working tree. This
@@ -130,7 +132,7 @@ of Git, hence the form without <pathspec> should not be used.
130132
This option is primarily to help the current users of Git, whose
131133
"git add <pathspec>..." ignores removed files. In future versions
132134
of Git, "git add <pathspec>..." will be a synonym to "git add -A
133-
<pathspec>..." and "git add --no-all <pathspec>..." will behave like
135+
<pathspec>..." and "git add --ignore-removal <pathspec>..." will behave like
134136
today's "git add <pathspec>...", ignoring removed files.
135137

136138
-N::

builtin/add.c

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -97,13 +97,13 @@ static int fix_unmerged_status(struct diff_filepair *p,
9797
}
9898

9999
static const char *add_would_remove_warning = N_(
100-
"You ran 'git add' with neither '-A (--all)' or '--no-all', whose\n"
101-
"behaviour will change in Git 2.0 with respect to paths you removed from\n"
102-
"your working tree. Paths like '%s' that are\n"
103-
"removed are ignored with this version of Git.\n"
100+
"You ran 'git add' with neither '-A (--all)' or '--ignore-removal',\n"
101+
"whose behaviour will change in Git 2.0 with respect to paths you removed.\n"
102+
"Paths like '%s' that are\n"
103+
"removed from your working tree are ignored with this version of Git.\n"
104104
"\n"
105-
"* 'git add --no-all <pathspec>', which is the current default, ignores\n"
106-
" paths you removed from your working tree.\n"
105+
"* 'git add --ignore-removal <pathspec>', which is the current default,\n"
106+
" ignores paths you removed from your working tree.\n"
107107
"\n"
108108
"* 'git add --all <pathspec>' will let you also record the removals.\n"
109109
"\n"
@@ -382,6 +382,13 @@ static int ignore_add_errors, intent_to_add, ignore_missing;
382382
static int addremove = ADDREMOVE_DEFAULT;
383383
static int addremove_explicit = -1; /* unspecified */
384384

385+
static int ignore_removal_cb(const struct option *opt, const char *arg, int unset)
386+
{
387+
/* if we are told to ignore, we are not adding removals */
388+
*(int *)opt->value = !unset ? 0 : 1;
389+
return 0;
390+
}
391+
385392
static struct option builtin_add_options[] = {
386393
OPT__DRY_RUN(&show_only, N_("dry run")),
387394
OPT__VERBOSE(&verbose, N_("be verbose")),
@@ -393,6 +400,10 @@ static struct option builtin_add_options[] = {
393400
OPT_BOOL('u', "update", &take_worktree_changes, N_("update tracked files")),
394401
OPT_BOOL('N', "intent-to-add", &intent_to_add, N_("record only the fact that the path will be added later")),
395402
OPT_BOOL('A', "all", &addremove_explicit, N_("add changes from all tracked and untracked files")),
403+
{ OPTION_CALLBACK, 0, "ignore-removal", &addremove_explicit,
404+
NULL /* takes no arguments */,
405+
N_("ignore paths removed in the working tree (same as --no-all)"),
406+
PARSE_OPT_NOARG, ignore_removal_cb },
396407
OPT_BOOL( 0 , "refresh", &refresh_only, N_("don't add, only refresh the index")),
397408
OPT_BOOL( 0 , "ignore-errors", &ignore_add_errors, N_("just skip files which cannot be added because of errors")),
398409
OPT_BOOL( 0 , "ignore-missing", &ignore_missing, N_("check if - even missing - files are ignored in dry run")),

0 commit comments

Comments
 (0)