]> git.ipfire.org Git - thirdparty/git.git/commit
builtin/add: error out when passing untracked path with -u
authorGhanshyam Thakkar <shyamthakkar001@gmail.com>
Wed, 3 Apr 2024 18:14:52 +0000 (23:44 +0530)
committerJunio C Hamano <gitster@pobox.com>
Wed, 3 Apr 2024 21:55:22 +0000 (14:55 -0700)
commit7de13cfef3042478223012841e07cd91d7234d22
tree6f5b7eafcbe609c1b2cd4c15f47c4972c6b20fc9
parentac5946e6248eb84458d236099f356e5e09e2482f
builtin/add: error out when passing untracked path with -u

When passing untracked path with -u option, it silently succeeds.
There is no error message and the exit code is zero. This is
inconsistent with other instances of git commands where the expected
argument is a known path. In those other instances, we error out when
the path is not known.

Fix this by passing a character array to add_files_to_cache() to
collect the pathspec matching information and report the error if a
pathspec does not match any cache entry. Also add a testcase to cover
this scenario.

Signed-off-by: Ghanshyam Thakkar <shyamthakkar001@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/add.c
t/t2200-add-update.sh