add: warn when asked to update SKIP_WORKTREE entries
`git add` already refrains from updating SKIP_WORKTREE entries, but it silently exits with zero code when it is asked to do so. Instead, let's warn the user and display a hint on how to update these entries. Note that we only warn the user whey they give a pathspec item that matches no eligible path for updating, but it does match one or more SKIP_WORKTREE entries. A warning was chosen over erroring out right away to reproduce the same behavior `add` already exhibits with ignored files. This also allow users to continue their workflow without having to invoke `add` again with only the eligible paths (as those will have already been added). Signed-off-by: Matheus Tavares <matheus.bernardino@usp.br> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:

committed by
Junio C Hamano

parent
b243012cb3
commit
a20f70478f
@ -160,6 +160,14 @@ void add_pathspec_matches_against_index(const struct pathspec *pathspec,
|
||||
char *find_pathspecs_matching_against_index(const struct pathspec *pathspec,
|
||||
const struct index_state *istate,
|
||||
enum ps_skip_worktree_action sw_action);
|
||||
char *find_pathspecs_matching_skip_worktree(const struct pathspec *pathspec);
|
||||
static inline int matches_skip_worktree(const struct pathspec *pathspec,
|
||||
int item, char **seen_ptr)
|
||||
{
|
||||
if (!*seen_ptr)
|
||||
*seen_ptr = find_pathspecs_matching_skip_worktree(pathspec);
|
||||
return (*seen_ptr)[item];
|
||||
}
|
||||
int match_pathspec_attrs(const struct index_state *istate,
|
||||
const char *name, int namelen,
|
||||
const struct pathspec_item *item);
|
||||
|
Reference in New Issue
Block a user