From 45c45e300bcbe493a39533bb04f6bd548e8a3f19 Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Tue, 19 Apr 2011 12:18:20 -0700 Subject: git add: start preparing for "git add ..." to default to "-A" When "git add subdir/" is run without "-u" or "-A" option, e.g. $ edit subdir/x $ create subdir/y $ rm subdir/z $ git add subdir/ the command does not notice removal of paths (e.g. subdir/z) from the working tree. This sometimes confuses new people, as arguably "git add" is told to record the current state of "subdir/" as a whole, not the current state of the paths that exist in the working tree that matches that pathspec (the latter by definition excludes the state of "subdir/z" because it does not exist in the working tree). Plan to eventually make "git add" pretend as if "-A" is given when there is a pathspec on the command line. When resolving a conflict to remove a path, the current code tells you to "git rm $path", but with such a change, you will be able to say "git add $path" (of course you can do "git add -A $path" today). That means that we can simplify the advice messages given by "git status". That all will be in Git 2.0 or later, if we are going to do so. For that transition to work, people need to learn either to say "git add --no-all subdir/" when they want to ignore the removed paths like "subdir/z", or to say "git add -A subdir/" when they want to take the state of the directory as a whole. "git add" without any argument will continue to be a no-op. Signed-off-by: Junio C Hamano --- t/t2200-add-update.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 't/t2200-add-update.sh') diff --git a/t/t2200-add-update.sh b/t/t2200-add-update.sh index 4cdebda6a5..32f932a4ce 100755 --- a/t/t2200-add-update.sh +++ b/t/t2200-add-update.sh @@ -150,9 +150,9 @@ test_expect_success 'add -u resolves unmerged paths' ' echo 2 >path3 && echo 2 >path5 && - # Explicit resolving by adding removed paths should fail - test_must_fail git add path4 && - test_must_fail git add path6 && + # Fail to explicitly resolve removed paths with "git add" + test_must_fail git add --no-all path4 && + test_must_fail git add --no-all path6 && # "add -u" should notice removals no matter what stages # the index entries are in. -- cgit v1.2.1 From 7bf7a92f69f8b0af7169af390e53397698fcfa95 Mon Sep 17 00:00:00 2001 From: Jeff King Date: Thu, 14 Mar 2013 02:44:04 -0400 Subject: t2200: check that "add -u" limits itself to subdirectory This behavior is due to change in the future, but let's test it anyway. That helps make sure we do not accidentally switch the behavior too soon while we are working in the area, and it means that we can easily verify the change when we do make it. Signed-off-by: Jeff King Signed-off-by: Junio C Hamano --- t/t2200-add-update.sh | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 't/t2200-add-update.sh') diff --git a/t/t2200-add-update.sh b/t/t2200-add-update.sh index 4cdebda6a5..c317254b9a 100755 --- a/t/t2200-add-update.sh +++ b/t/t2200-add-update.sh @@ -80,6 +80,22 @@ test_expect_success 'change gets noticed' ' ' +# Note that this is scheduled to change in Git 2.0, when +# "git add -u" will become full-tree by default. +test_expect_success 'non-limited update in subdir leaves root alone' ' + ( + cd dir1 && + echo even more >>sub2 && + git add -u + ) && + cat >expect <<-\EOF && + check + top + EOF + git diff-files --name-only >actual && + test_cmp expect actual +' + test_expect_success SYMLINKS 'replace a file with a symlink' ' rm foo && -- cgit v1.2.1 From 889c6f0e4d637223e0517d000eedad39b173d8a2 Mon Sep 17 00:00:00 2001 From: Johannes Sixt Date: Fri, 7 Jun 2013 22:53:28 +0200 Subject: tests: use test_ln_s_add to remove SYMLINKS prerequisite (trivial cases) There are many instances where the treatment of symbolic links in the object model and the algorithms are tested, but where it is not necessary to actually have a symbolic link in the worktree. Make adjustments to the tests and remove the SYMLINKS prerequisite when appropriate in trivial cases, where "trivial" means: - merely a replacement of 'ln -s a b && git add b' by test_ln_s_add is needed; - a test for symbolic link on the file system can be split off (and remains protected by SYMLINKS); - existing code is equivalent to test_ln_s_add. Signed-off-by: Johannes Sixt Signed-off-by: Junio C Hamano --- t/t2200-add-update.sh | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 't/t2200-add-update.sh') diff --git a/t/t2200-add-update.sh b/t/t2200-add-update.sh index b2bd41918e..9bf2bdffd2 100755 --- a/t/t2200-add-update.sh +++ b/t/t2200-add-update.sh @@ -96,11 +96,10 @@ test_expect_success 'non-limited update in subdir leaves root alone' ' test_cmp expect actual ' -test_expect_success SYMLINKS 'replace a file with a symlink' ' +test_expect_success 'replace a file with a symlink' ' rm foo && - ln -s top foo && - git add -u -- foo + test_ln_s_add top foo ' -- cgit v1.2.1