]> git.ipfire.org Git - thirdparty/git.git/commit
sparse-checkout: error or warn when given individual files
authorElijah Newren <newren@gmail.com>
Sat, 19 Feb 2022 16:44:44 +0000 (16:44 +0000)
committerJunio C Hamano <gitster@pobox.com>
Sun, 20 Feb 2022 08:01:15 +0000 (00:01 -0800)
commit4ce504360bc3b240e570281fabe00a85027532c3
treee7340456e42b74d9a22cf9a8eb243e092105275f
parentbb8b5e9a90d607ec6144527c5019f56b6a81d862
sparse-checkout: error or warn when given individual files

The set and add subcommands accept multiple positional arguments.
The meaning of these arguments differs slightly in the two modes:

Cone mode only accepts directories.  If given a file, it would
previously treat it as a directory, causing not just the file itself to
be included but all sibling files as well -- likely against users'
expectations.  Throw an error if the specified path is a file in the
index.  Provide a --skip-checks argument to allow users to override
(e.g. for the case when the given path IS a directory on another
branch).

Non-cone mode accepts general gitignore patterns.  There are many
reasons to avoid this mode, but one possible reason to use it instead of
cone mode: to be able to select individual files within a directory.
However, if a file is passed to set/add in non-cone mode, you won't be
selecting a single file, you'll be selecting a file with the same name
in any directory.  Thus users will likely want to prefix any paths they
specify with a leading '/' character; warn users if the patterns they
specify exactly name a file because it means they are likely missing
such a leading slash.

Reviewed-by: Derrick Stolee <derrickstolee@github.com>
Signed-off-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/sparse-checkout.c
t/t1091-sparse-checkout-builtin.sh