All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Nguyễn Thái Ngọc Duy" <pclouds@gmail.com>
To: git@vger.kernel.org, "Junio C Hamano" <gitster@pobox.com>,
	"Sebastian Pipping" <webmaster@hartwork.org>,
	"SZEDER Gábor" <szeder@ira.uka.de>,
	"Matthieu Moy" <Matthieu.Moy@gr>
Cc: "Nguyễn Thái Ngọc Duy" <pclouds@gmail.com>
Subject: [PATCH 1.8.0] add: make "add -u" update full tree without pathspec
Date: Mon,  7 Feb 2011 09:27:23 +0700	[thread overview]
Message-ID: <1297045643-26697-1-git-send-email-pclouds@gmail.com> (raw)

When -u was introduced in dfdac5d (git-add -u: match the index with
working tree., 2007-04-20), "add -u" (without pathspec) added
everything. Shortly after, 2ed2c22 (git-add -u paths... now works from
subdirectory, 2007-08-16) broke it while fixing something related.

This makes -u (and -A) inconsistent with some other options, namely -p.
It's been four years since the unintentional breakage and people are
probably used to "git add -u" updating only current directory. Perhaps
it's time to bring the original behavior back? Current behavior can
always be achieved with "git add -u ."

Migration plan:

I'm bad at this. Can we start with a patch that warns users to do "git
add -u ." when they do "git add -u"? Hopefully they would have their
fingers retraied by the time the behavior is changed in 1.8.0.

PS. What about -A?

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 2011/2/7 Sebastian Pipping <webmaster@hartwork.org>:
 >> git add -u was tree-wide when it was introduced in dfdac5d (git-add
 >> -u: match the index with working tree., 2007-04-20), but 2ed2c22
 >> (git-add -u paths... now works from subdirectory, 2007-08-16) broke it
 >> while fixing something related.
 >
 > So my memory didn't fool me.  Thanks for digging this out.
 >
 > Can we have tree-wide "git add -u" back, please?

 Yup yup I like it too (and wanted the original behavior sometimes, even
 though I didn't know it was original behavior).

 Pulling Junio in for -A. It seems closely related to -u. In fact I revert
 one line from 1e5f764 (builtin-add.c: optimize -A option and "git add ."
 - 2008-07-22) but not fully understand why it was changed.

 builtin/add.c         |    7 +++++--
 t/t2200-add-update.sh |   13 +++++++------
 2 files changed, 12 insertions(+), 8 deletions(-)

diff --git a/builtin/add.c b/builtin/add.c
index 12b964e..f1f8b5a 100644
--- a/builtin/add.c
+++ b/builtin/add.c
@@ -389,7 +389,7 @@ int cmd_add(int argc, const char **argv, const char *prefix)
 		die("-A and -u are mutually incompatible");
 	if (!show_only && ignore_missing)
 		die("Option --ignore-missing can only be used together with --dry-run");
-	if ((addremove || take_worktree_changes) && !argc) {
+	if (addremove && !argc) {
 		static const char *here[2] = { ".", NULL };
 		argc = 1;
 		argv = here;
@@ -412,7 +412,10 @@ int cmd_add(int argc, const char **argv, const char *prefix)
 		fprintf(stderr, "Maybe you wanted to say 'git add .'?\n");
 		return 0;
 	}
-	pathspec = validate_pathspec(argc, argv, prefix);
+	if (take_worktree_changes && !argc)
+		pathspec = NULL;
+	else
+		pathspec = validate_pathspec(argc, argv, prefix);
 
 	if (read_cache() < 0)
 		die("index file corrupt");
diff --git a/t/t2200-add-update.sh b/t/t2200-add-update.sh
index 0692427..2201242 100755
--- a/t/t2200-add-update.sh
+++ b/t/t2200-add-update.sh
@@ -69,15 +69,16 @@ test_expect_success 'cache tree has not been corrupted' '
 test_expect_success 'update from a subdirectory' '
 	(
 		cd dir1 &&
-		echo more >sub2 &&
+		echo more >>sub2 &&
 		git add -u sub2
-	)
-'
-
-test_expect_success 'change gets noticed' '
-
+	) &&
 	test "$(git diff-files --name-status dir1)" = ""
+'
 
+test_expect_success 'update without args from subdir' '
+	echo more >>top &&
+	( cd dir1 && git add -u ) &&
+	test "$(git diff-files --name-status top)" = ""
 '
 
 test_expect_success SYMLINKS 'replace a file with a symlink' '
-- 
1.7.3.4.878.g439c7

             reply	other threads:[~2011-02-07  2:29 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-02-07  2:27 Nguyễn Thái Ngọc Duy [this message]
2011-02-07  5:58 ` [PATCH 1.8.0] add: make "add -u" update full tree without pathspec Junio C Hamano
2011-02-07  6:14   ` Nguyen Thai Ngoc Duy
2011-02-07  6:26     ` Miles Bader
2011-02-09 10:58     ` Joshua Juran
2011-02-07 12:09   ` Matthieu Moy
2011-02-27 10:46 ` Junio C Hamano
2011-02-27 11:43   ` Matthieu Moy
2011-02-27 17:04     ` Nguyen Thai Ngoc Duy
2011-02-27 13:35   ` Sverre Rabbelier
2011-02-27 17:01     ` Nguyen Thai Ngoc Duy
2011-02-27 16:52   ` Nguyen Thai Ngoc Duy
2011-02-27 19:39     ` Junio C Hamano
2011-02-28  6:37       ` Nguyen Thai Ngoc Duy
2011-02-28  6:56         ` Junio C Hamano
2011-03-01 11:22           ` Nguyen Thai Ngoc Duy
2011-03-01 13:46             ` Junio C Hamano
2011-03-01 14:15               ` Nguyen Thai Ngoc Duy
2011-03-01 14:53           ` Matthieu Moy
2011-03-01 18:40             ` Junio C Hamano
2011-03-01 18:51               ` Matthieu Moy
2011-03-01 19:36                 ` Jakub Narebski
2011-03-01 20:00                 ` Jeff King
2011-03-01 20:12                 ` Junio C Hamano
2011-03-01 20:25                   ` Matthieu Moy

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=1297045643-26697-1-git-send-email-pclouds@gmail.com \
    --to=pclouds@gmail.com \
    --cc=Matthieu.Moy@gr \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=szeder@ira.uka.de \
    --cc=webmaster@hartwork.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.