submodule-config: keep shallow recommendation around

The shallow field will be used in a later patch by `submodule update`. To differentiate between the actual depth (which may be different), we name it `recommend_shallow` as the field in the .gitmodules file is only a recommendation by the project. Signed-off-by: Stefan Beller <sbeller@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Stefan Beller committed May 26, 2016 at 14:59 UTC 37f52e93441e1da00c9c9824ed03cd074d77f43a
2 files changed +10
submodule-config.c
+9
@@ -199,6 +199,7 @@ static struct submodule *lookup_or_create_by_name(struct submodule_cache *cache,
199 submodule->update_strategy.command = NULL;
200 submodule->fetch_recurse = RECURSE_SUBMODULES_NONE;
201 submodule->ignore = NULL;
202 + submodule->recommend_shallow = -1;
203
204 hashcpy(submodule->gitmodules_sha1, gitmodules_sha1);
205
@@ -353,6 +354,14 @@ static int parse_config(const char *var, const char *value, void *data)
354 else if (parse_submodule_update_strategy(value,
355 &submodule->update_strategy) < 0)
356 die(_("invalid value for %s"), var);
357 + } else if (!strcmp(item.buf, "shallow")) {
358 + if (!me->overwrite && submodule->recommend_shallow != -1)
359 + warn_multiple_config(me->commit_sha1, submodule->name,
360 + "shallow");
361 + else {
362 + submodule->recommend_shallow =
363 + git_config_bool(var, value);
364 + }
365 }
366
367 strbuf_release(&name);
submodule-config.h
+1
@@ -18,6 +18,7 @@ struct submodule {
18 struct submodule_update_strategy update_strategy;
19 /* the sha1 blob id of the responsible .gitmodules file */
20 unsigned char gitmodules_sha1[20];
21 + int recommend_shallow;
22 };
23
24 int parse_fetch_recurse_submodules_arg(const char *opt, const char *arg);