ls-files: mark exclude options as NONEG

Running "git ls-files --no-exclude" will currently segfault, as its option callback does not handle the "unset" parameter. In theory this could be used to clear the exclude list, but it is not clear how that would interact with the other exclude options, nor is the current code capable of clearing the list. Let's just disable the broken option. Note that --no-exclude-from will similarly segfault, but --no-exclude-standard will not. It just silently does the wrong thing (pretending as if --exclude-standard was specified). Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Jeff King committed Nov 5, 2018 at 01:39 UTC ccf659e87c8fdb4edb5d2653c53bc9062c8eee76
1 file changed +4 -3
builtin/ls-files.c
+4 -3
@@ -548,15 +548,16 @@ int cmd_ls_files(int argc, const char **argv, const char *cmd_prefix)
548 N_("show resolve-undo information")),
549 { OPTION_CALLBACK, 'x', "exclude", &exclude_list, N_("pattern"),
550 N_("skip files matching pattern"),
551 - 0, option_parse_exclude },
551 + PARSE_OPT_NONEG, option_parse_exclude },
552 { OPTION_CALLBACK, 'X', "exclude-from", &dir, N_("file"),
553 N_("exclude patterns are read from <file>"),
554 - 0, option_parse_exclude_from },
554 + PARSE_OPT_NONEG, option_parse_exclude_from },
555 OPT_STRING(0, "exclude-per-directory", &dir.exclude_per_dir, N_("file"),
556 N_("read additional per-directory exclude patterns in <file>")),
557 { OPTION_CALLBACK, 0, "exclude-standard", &dir, NULL,
558 N_("add the standard git exclusions"),
559 - PARSE_OPT_NOARG, option_parse_exclude_standard },
559 + PARSE_OPT_NOARG | PARSE_OPT_NONEG,
560 + option_parse_exclude_standard },
561 OPT_SET_INT_F(0, "full-name", &prefix_len,
562 N_("make the output relative to the project top directory"),
563 0, PARSE_OPT_NONEG),