Re: [PATCH v9 2/3] introduce submodule.hasSuperproject record
- From
Glen Choo <chooglen@google.com>
- Date
- Mar 10, 2022, 21:40 UTC
- Message-ID
- <kl6la6dxsczx.fsf@chooglen-macbookpro.roam.corp.google.com>
- In-Reply-To
- <xmqqtuc6h83m.fsf@gitster.g>
Junio C Hamano <gitster@pobox.com> writes:
Show 19 quoted lines
> Emily Shaffer <emilyshaffer@google.com> writes:
>
>> @@ -2617,6 +2622,12 @@ static int run_update_procedure(int argc, const char **argv, const char *prefix)
>>
>> free(prefixed_path);
>>
>> + /*
>> + * This entry point is always called from a submodule, so this is a
>> + * good place to set a hint that this repo is a submodule.
>> + */
>> + git_config_set("submodule.hasSuperproject", "true");
>> +
>> if (!oideq(&update_data.oid, &update_data.suboid) || update_data.force)
>> return do_run_update_procedure(&update_data);
>
> In Glen's update to rewrite "submodule update" in C, this part is
> replaced with a call to update_submodule2(). I am not sure what the
> current repository is at this point of the code with and without
> Glen's topic, but are we sure we are in a submodule we discovered?Rereading this, I realize you probably meant that this conflicts with part1, not part2...
At the end of part1, update_submodule2() is called from inside the submodule (specifically from run_update_procedure()). So a good merge conflict resolution would be to set the config _before_ calling update_submodule2(). e.g.
----- >8 --------- >8 --------- >8 --------- >8 --------- >8 ----
diff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c index bef9ab22d4..f53808d995 100644 --- a/builtin/submodule--helper.c +++ b/builtin/submodule--helper.c @@ -2672,6 +2677,11 @@ static int run_update_procedure(int argc, const char **argv, const char *prefix) &update_data.update_strategy); free(prefixed_path); + /* + * This entry point is always called from a submodule, so this is a + * good place to set a hint that this repo is a submodule. + */ + git_config_set("submodule.hasSuperproject", "true"); return update_submodule2(&update_data); }