Thread (1 message) 1 message, 1 author, 2020-11-23

Re: [PATCH v2 4/7] config: add --fixed-value option, un-implemented

From: Junio C Hamano <hidden>
Date: 2020-11-23 19:38:08

"Derrick Stolee via GitGitGadget" [off-list ref] writes:
+	if (fixed_value) {
+		int allowed_usage = 0;
+
+		switch (actions) {
+		case ACTION_GET:
+		case ACTION_GET_ALL:
+		case ACTION_GET_REGEXP:
+		case ACTION_UNSET:
+		case ACTION_UNSET_ALL:
+			allowed_usage = argc > 1 && !!argv[1];
+			break;
+
+		case ACTION_SET_ALL:
+		case ACTION_REPLACE_ALL:
+			allowed_usage = argc > 2 && !!argv[2];
+			break;
Implicitly all other ops do not want to work with the --fixed-value
option, which makes sense.
+		}
+
+		if (!allowed_usage) {
+			error(_("--fixed-value only applies with 'value_regex'"));
+			usage_builtin_config();
+		}
+	}
I was afraid that abandoning the bitmask based approach of the
previous round may bloat the code but seeing the result here makes
me quite happy ;-)  It is quite clear what is going on.

Nice.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help