status: unify parsing of --untracked= and status.showUntrackedFiles

There are two code paths that take a string and parse it to enum
untracked_status_type.  Introduce a helper function and use it.

As these two places handle an error differently, add an additional
invalid value to the enum, and have the caller of the helper handle
the error condition, instead of dying or emitting error message from
the helper.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Junio C Hamano
2024-03-13 10:32:13 -07:00
parent 945115026a
commit 63acdc4827
2 changed files with 29 additions and 18 deletions

View File

@@ -23,7 +23,8 @@ enum color_wt_status {
};
enum untracked_status_type {
SHOW_NO_UNTRACKED_FILES,
SHOW_UNTRACKED_FILES_ERROR = -1,
SHOW_NO_UNTRACKED_FILES = 0,
SHOW_NORMAL_UNTRACKED_FILES,
SHOW_ALL_UNTRACKED_FILES
};