builtin/commit: error out when passing untracked path with -i
commitac5946e6248eb84458d236099f356e5e09e2482f
authorGhanshyam Thakkar <shyamthakkar001@gmail.com>
Wed, 3 Apr 2024 18:14:50 +0000 (3 23:44 +0530)
committerJunio C Hamano <gitster@pobox.com>
Wed, 3 Apr 2024 21:55:22 +0000 (3 14:55 -0700)
tree59e044dd0b80fa6747958ee1d6707ec803082708
parent86829f3f3ea62853a4a632637ade6de94a1f4c7c
builtin/commit: error out when passing untracked path with -i

When we provide a pathspec which does not match any tracked path
alongside --include, we do not error like without --include. If there
is something staged, it will commit the staged changes and ignore the
pathspec which does not match any tracked path. And if nothing is
staged, it will print the status. Exit code is 0 in both cases (unlike
without --include). This is also described in the TODO comment before
the relevant testcase.

Fix this by passing a character array to add_files_to_cache() to
collect the pathspec matching information and error out if the given
path is untracked. Also, amend the testcase to check for the error
message and remove the TODO comment.

Signed-off-by: Ghanshyam Thakkar <shyamthakkar001@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/commit.c
t/t7501-commit-basic-functionality.sh