aboutsummaryrefslogtreecommitdiff
path: root/builtin/ls-files.c
diff options
context:
space:
mode:
authorJeff King <peff@peff.net>2016-01-31 06:35:46 -0500
committerJunio C Hamano <gitster@pobox.com>2016-02-01 14:14:20 -0800
commit1f3c79a9d6c3278753e7fb63b48569a9ff8632df (patch)
tree904b918bc2dd1aa8f62ca578e36384f61662926c /builtin/ls-files.c
parent22396175267b7bcef97a02036831152539429bec (diff)
downloadgit-1f3c79a9d6c3278753e7fb63b48569a9ff8632df.tar.gz
git-1f3c79a9d6c3278753e7fb63b48569a9ff8632df.tar.xz
apply, ls-files: simplify "-z" parsing
As a short option, we cannot handle negation. Thus a callback handling "unset" is overkill, and we can just use OPT_SET_INT instead to handle setting the option. Anybody who adds "--nul" synonym to this later would need to be careful not to break "--no-nul", which should mean that lines are terminated with LF at the end. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin/ls-files.c')
-rw-r--r--builtin/ls-files.c14
1 files changed, 3 insertions, 11 deletions
diff --git a/builtin/ls-files.c b/builtin/ls-files.c
index b6a7cb0c7..467699bcf 100644
--- a/builtin/ls-files.c
+++ b/builtin/ls-files.c
@@ -359,14 +359,6 @@ static const char * const ls_files_usage[] = {
NULL
};
-static int option_parse_z(const struct option *opt,
- const char *arg, int unset)
-{
- line_terminator = unset ? '\n' : '\0';
-
- return 0;
-}
-
static int option_parse_exclude(const struct option *opt,
const char *arg, int unset)
{
@@ -408,9 +400,9 @@ int cmd_ls_files(int argc, const char **argv, const char *cmd_prefix)
struct exclude_list *el;
struct string_list exclude_list = STRING_LIST_INIT_NODUP;
struct option builtin_ls_files_options[] = {
- { OPTION_CALLBACK, 'z', NULL, NULL, NULL,
- N_("paths are separated with NUL character"),
- PARSE_OPT_NOARG, option_parse_z },
+ /* Think twice before adding "--nul" synonym to this */
+ OPT_SET_INT('z', NULL, &line_terminator,
+ N_("paths are separated with NUL character"), '\0'),
OPT_BOOL('t', NULL, &show_tag,
N_("identify the file status with tags")),
OPT_BOOL('v', NULL, &show_valid_bit,