111
return 0;
112
}
113
114
+static int cmd__submodule_config_list(int argc, const char **argv)
115
+{
116
+ struct option options[] = {
117
+ OPT_END()
118
+ };
119
+ const char *const usage[] = {
120
+ "test-tool submodule config-list <key>",
121
+ NULL
122
+ };
123
+ argc = parse_options(argc, argv, "test-tools", options, usage,
124
+ PARSE_OPT_KEEP_ARGV0);
125
+
126
+ setup_git_directory();
127
+
128
+ if (argc == 2)
129
+ return print_config_from_gitmodules(the_repository, argv[1]);
130
+ usage_with_options(usage, options);
131
+}
132
+
133
+static int cmd__submodule_config_set(int argc, const char **argv)
134
+{
135
+ struct option options[] = {
136
+ OPT_END()
137
+ };
138
+ const char *const usage[] = {
139
+ "test-tool submodule config-set <key> <value>",
140
+ NULL
141
+ };
142
+ argc = parse_options(argc, argv, "test-tools", options, usage,
143
+ PARSE_OPT_KEEP_ARGV0);
144
+
145
+ setup_git_directory();
146
+
147
+ /* Equivalent to ACTION_SET in builtin/config.c */
148
+ if (argc == 3) {
149
+ if (!is_writing_gitmodules_ok())
150
+ die("please make sure that the .gitmodules file is in the working tree");
151
+
152
+ return config_set_in_gitmodules_file_gently(argv[1], argv[2]);
153
+ }
154
+ usage_with_options(usage, options);
155
+}
156
+
157
+static int cmd__submodule_config_unset(int argc, const char **argv)
158
+{
159
+ struct option options[] = {
160
+ OPT_END()
161
+ };
162
+ const char *const usage[] = {
163
+ "test-tool submodule config-unset <key>",
164
+ NULL
165
+ };
166
+
167
+ setup_git_directory();
168
+
169
+ if (argc == 2) {
170
+ if (!is_writing_gitmodules_ok())
171
+ die("please make sure that the .gitmodules file is in the working tree");
172
+ return config_set_in_gitmodules_file_gently(argv[1], NULL);
173
+ }
174
+ usage_with_options(usage, options);
175
+}
176
+
177
+static int cmd__submodule_config_writeable(int argc, const char **argv)
178
+{
179
+ struct option options[] = {
180
+ OPT_END()
181
+ };
182
+ const char *const usage[] = {
183
+ "test-tool submodule config-writeable",
184
+ NULL
185
+ };
186
+ setup_git_directory();
187
+
188
+ if (argc == 1)
189
+ return is_writing_gitmodules_ok() ? 0 : -1;
190
+
191
+ usage_with_options(usage, options);
192
+}
193
+
194
static struct test_cmd cmds[] = {
195
{ "check-name", cmd__submodule_check_name },
196
{ "is-active", cmd__submodule_is_active },
197
{ "resolve-relative-url", cmd__submodule_resolve_relative_url},
198
+ { "config-list", cmd__submodule_config_list },
199
+ { "config-set", cmd__submodule_config_set },
200
+ { "config-unset", cmd__submodule_config_unset },
201
+ { "config-writeable", cmd__submodule_config_writeable },
202
};
203
204
int cmd__submodule(int argc, const char **argv)