Thread (7 messages) flat view 7 messages, 7 authors, 2016-06-15

Re: [RFC/PATCH] add: warn when -u or -A is used without filepattern

From: Jonathan Nieder <hidden>
Date: 2016-06-15 22:55:50

Possibly related (same subject, not in this thread)

Hi,

Matthieu Moy wrote:
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.
quoted hunk ↗ jump to hunk
--- a/builtin/add.c
+++ b/builtin/add.c
[...]
+	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
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help