34
static struct config_options config_options;
35
static int show_origin;
36
static int show_scope;
37
+static int fixed_value;
38
39
#define ACTION_GET (1<<0)
40
#define ACTION_GET_ALL (1<<1)
145
OPT_BIT(0, "rename-section", &actions, N_("rename section: old-name new-name"), ACTION_RENAME_SECTION),
146
OPT_BIT(0, "remove-section", &actions, N_("remove a section: name"), ACTION_REMOVE_SECTION),
147
OPT_BIT('l', "list", &actions, N_("list all"), ACTION_LIST),
148
+ OPT_BOOL(0, "fixed-value", &fixed_value, N_("use string equality when comparing values to 'value-pattern'")),
149
OPT_BIT('e', "edit", &actions, N_("open an editor"), ACTION_EDIT),
150
OPT_BIT(0, "get-color", &actions, N_("find the color configured: slot [default]"), ACTION_GET_COLOR),
151
OPT_BIT(0, "get-colorbool", &actions, N_("find the color setting: slot [stdout-is-tty]"), ACTION_GET_COLORBOOL),
768
usage_builtin_config();
769
}
770
771
+ /* check usage of --fixed-value */
772
+ if (fixed_value) {
773
+ int allowed_usage = 0;
774
+
775
+ switch (actions) {
776
+ /* git config --get <name> <value-pattern> */
777
+ case ACTION_GET:
778
+ /* git config --get-all <name> <value-pattern> */
779
+ case ACTION_GET_ALL:
780
+ /* git config --get-regexp <name-pattern> <value-pattern> */
781
+ case ACTION_GET_REGEXP:
782
+ /* git config --unset <name> <value-pattern> */
783
+ case ACTION_UNSET:
784
+ /* git config --unset-all <name> <value-pattern> */
785
+ case ACTION_UNSET_ALL:
786
+ allowed_usage = argc > 1 && !!argv[1];
787
+ break;
788
+
789
+ /* git config <name> <value> <value-pattern> */
790
+ case ACTION_SET_ALL:
791
+ /* git config --replace-all <name> <value> <value-pattern> */
792
+ case ACTION_REPLACE_ALL:
793
+ allowed_usage = argc > 2 && !!argv[2];
794
+ break;
795
+
796
+ /* other options don't allow --fixed-value */
797
+ }
798
+
799
+ if (!allowed_usage) {
800
+ error(_("--fixed-value only applies with 'value-pattern'"));
801
+ usage_builtin_config();
802
+ }
803
+ }
804
+
805
if (actions & PAGING_ACTIONS)
806
setup_auto_pager("config", 1);
807