2008-07-20 05:32:38 +02:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
test_description='git add --all'
|
|
|
|
|
2021-10-31 00:24:20 +02:00
|
|
|
TEST_PASSES_SANITIZE_LEAK=true
|
2008-07-20 05:32:38 +02:00
|
|
|
. ./test-lib.sh
|
|
|
|
|
|
|
|
test_expect_success setup '
|
|
|
|
(
|
2018-07-02 02:23:57 +02:00
|
|
|
echo .gitignore &&
|
2008-07-20 05:32:38 +02:00
|
|
|
echo will-remove
|
|
|
|
) >expect &&
|
|
|
|
(
|
2018-07-02 02:23:57 +02:00
|
|
|
echo actual &&
|
|
|
|
echo expect &&
|
2008-07-20 05:32:38 +02:00
|
|
|
echo ignored
|
|
|
|
) >.gitignore &&
|
add: simplify -u/-A without pathspec
Since Git 2.0, "add -u" and "add -A" run from a subdirectory without
any pathspec mean "everything in the working tree" (before 2.0, they
were limited to the current directory). The limiting to the current
directory was implemented by inserting "." to the command line when
the end user did not give us any pathspec. At 2.0, we updated the
code to insert ":/" (instead of '.') to consider everything from the
top-level, by using a pathspec magic "top".
The call to parse_pathspec() using the command line arguments is,
however, made with PATHSPEC_PREFER_FULL option since 5a76aff1 (add:
convert to use parse_pathspec, 2013-07-14), which predates Git 2.0.
In retrospect, there was no need to turn "adding . to limit to the
directory" into "adding :/ to unlimit to everywhere" in Git 2.0;
instead we could just have done "if there is no pathspec on the
command line, just let it be". The parse_pathspec() then would give
us a pathspec that matches everything and all is well.
Incidentally such a simplification also fixes a corner case bug that
stems from the fact that ":/" does not necessarily mean any magic.
A user would say "git --literal-pathspecs add -u :/" from the
command line when she has a directory ':' and wants to add
everything in it (and she knows that her :/ will be taken as
'everything under the sun' magic pathspec unless she disables the
magic with --literal-pathspecs). The internal use of ':/' would
behave the same way as such an explicitly given ":/" when run with
"--literal-pathspecs", and will not add everything under the sun as
the code originally intended.
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2015-10-25 03:31:11 +01:00
|
|
|
git --literal-pathspecs add --all &&
|
2008-07-20 05:32:38 +02:00
|
|
|
>will-remove &&
|
|
|
|
git add --all &&
|
|
|
|
test_tick &&
|
|
|
|
git commit -m initial &&
|
|
|
|
git ls-files >actual &&
|
|
|
|
test_cmp expect actual
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'git add --all' '
|
|
|
|
(
|
2018-07-02 02:23:57 +02:00
|
|
|
echo .gitignore &&
|
|
|
|
echo not-ignored &&
|
|
|
|
echo "M .gitignore" &&
|
|
|
|
echo "A not-ignored" &&
|
2008-07-20 05:32:38 +02:00
|
|
|
echo "D will-remove"
|
|
|
|
) >expect &&
|
|
|
|
>ignored &&
|
|
|
|
>not-ignored &&
|
|
|
|
echo modification >>.gitignore &&
|
|
|
|
rm -f will-remove &&
|
|
|
|
git add --all &&
|
|
|
|
git update-index --refresh &&
|
|
|
|
git ls-files >actual &&
|
|
|
|
git diff-index --name-status --cached HEAD >>actual &&
|
|
|
|
test_cmp expect actual
|
|
|
|
'
|
|
|
|
|
2013-07-20 05:57:01 +02:00
|
|
|
test_expect_success 'Just "git add" is a no-op' '
|
|
|
|
git reset --hard &&
|
|
|
|
echo >will-remove &&
|
|
|
|
>will-not-be-added &&
|
|
|
|
git add &&
|
|
|
|
git diff-index --name-status --cached HEAD >actual &&
|
2018-07-27 19:48:11 +02:00
|
|
|
test_must_be_empty actual
|
2013-07-20 05:57:01 +02:00
|
|
|
'
|
|
|
|
|
2008-07-20 05:32:38 +02:00
|
|
|
test_done
|