Re: [RFC/PATCH] add: warn when -u or -A is used without filepattern
- From
Jonathan Nieder <jrnieder@gmail.com>
- Date
- Jan 21, 2013, 22:22 UTC
- Message-ID
- <20130121222248.GA3586@elie.Belkin>
- In-Reply-To
- <1358769611-3625-1-git-send-email-Matthieu.Moy@imag.fr>
Hi,
Matthieu Moy wrote:
Show 7 quoted lines
> The inconsistancy of 'git add -u' and 'git add -A' are particularly > problematic since other 'git add' subcommands (namely 'git add -p' and > 'git add -e') are tree-wide by default. > > Flipping the default now is unacceptable, so this patch starts training > users to type explicitely 'git add -u|-A :/' or 'git add -u|-A .', to prepare > for the next steps:
Thanks for tackling this.
> --- a/builtin/add.c > +++ b/builtin/add.c
[...]
Show 12 quoted lines
> + if (option_with_implicit_dot && !argc) {
> + /*
> + * To be consistant 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.
> + */
> + warning(_("The behavior of 'git add %s' with no path argument will change in a future\n"Would it be possible to make this conditional on cwd not being at the toplevel (the case where "git add -u :/" and "git add -u ." have different behavior)? E.g.,
static const char *here[2] = { ".", NULL };
if (prefix)
warning(...);Thanks, Jonathan