parse-options: convert bitfield values to use binary shift

Because it's easier to read, but also likely to be easier to maintain. I am making this change because I need to add a new flag in a later commit. Also add a trailing comma to the last enum entry to simplify addition of new flags. This change was originally suggested by Peff in: https://public-inbox.org/git/YEZ%2FBWWbpfVwl6nO@coredump.intra.peff.net/ Signed-off-by: Andrzej Hunt <ajrhunt@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Andrzej Hunt committed Mar 21, 2021 at 16:58 UTC 0171dbcb428739e59440ccdf2d9470d8782f51be
1 file changed +17 -17
parse-options.h
+17 -17
@@ -28,26 +28,26 @@ enum parse_opt_type {
28 };
29
30 enum parse_opt_flags {
31 - PARSE_OPT_KEEP_DASHDASH = 1,
32 - PARSE_OPT_STOP_AT_NON_OPTION = 2,
33 - PARSE_OPT_KEEP_ARGV0 = 4,
34 - PARSE_OPT_KEEP_UNKNOWN = 8,
35 - PARSE_OPT_NO_INTERNAL_HELP = 16,
36 - PARSE_OPT_ONE_SHOT = 32
31 + PARSE_OPT_KEEP_DASHDASH = 1 << 0,
32 + PARSE_OPT_STOP_AT_NON_OPTION = 1 << 1,
33 + PARSE_OPT_KEEP_ARGV0 = 1 << 2,
34 + PARSE_OPT_KEEP_UNKNOWN = 1 << 3,
35 + PARSE_OPT_NO_INTERNAL_HELP = 1 << 4,
36 + PARSE_OPT_ONE_SHOT = 1 << 5,
37 };
38
39 enum parse_opt_option_flags {
40 - PARSE_OPT_OPTARG = 1,
41 - PARSE_OPT_NOARG = 2,
42 - PARSE_OPT_NONEG = 4,
43 - PARSE_OPT_HIDDEN = 8,
44 - PARSE_OPT_LASTARG_DEFAULT = 16,
45 - PARSE_OPT_NODASH = 32,
46 - PARSE_OPT_LITERAL_ARGHELP = 64,
47 - PARSE_OPT_SHELL_EVAL = 256,
48 - PARSE_OPT_NOCOMPLETE = 512,
49 - PARSE_OPT_COMP_ARG = 1024,
50 - PARSE_OPT_CMDMODE = 2048
40 + PARSE_OPT_OPTARG = 1 << 0,
41 + PARSE_OPT_NOARG = 1 << 1,
42 + PARSE_OPT_NONEG = 1 << 2,
43 + PARSE_OPT_HIDDEN = 1 << 3,
44 + PARSE_OPT_LASTARG_DEFAULT = 1 << 4,
45 + PARSE_OPT_NODASH = 1 << 5,
46 + PARSE_OPT_LITERAL_ARGHELP = 1 << 6,
47 + PARSE_OPT_SHELL_EVAL = 1 << 8,
48 + PARSE_OPT_NOCOMPLETE = 1 << 9,
49 + PARSE_OPT_COMP_ARG = 1 << 10,
50 + PARSE_OPT_CMDMODE = 1 << 11,
51 };
52
53 enum parse_opt_result {