diff options
author | Junio C Hamano <gitster@pobox.com> | 2015-10-24 19:31:11 -0700 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2015-10-24 19:32:47 -0700 |
commit | 29abb33978f713cd0a5cc3687bf61077b0928840 (patch) | |
tree | 029dcef408a996c231799f113e7d4e54348c6efc /t/t2200-add-update.sh | |
parent | 282616c72d1d08a77ca4fe1186cb708c38408d87 (diff) | |
download | git-29abb33978f713cd0a5cc3687bf61077b0928840.tar.gz git-29abb33978f713cd0a5cc3687bf61077b0928840.tar.xz |
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>
Diffstat (limited to 't/t2200-add-update.sh')
-rwxr-xr-x | t/t2200-add-update.sh | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/t/t2200-add-update.sh b/t/t2200-add-update.sh index e16b15d3e..314c73c5a 100755 --- a/t/t2200-add-update.sh +++ b/t/t2200-add-update.sh @@ -84,6 +84,8 @@ test_expect_success 'non-qualified update in subdir updates from the root' ' ( cd dir1 && echo even more >>sub2 && + git --literal-pathspecs add -u && + echo even more >>sub2 && git add -u ) && : >expect && |