Subject: Re: [PATCH v9 2/3] introduce submodule.hasSuperproject record

From: Junio C Hamano <[email-masked]>
Date: Wed, 09 Mar 2022 18:09:01 -0800

Emily Shaffer <[email-masked]> 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?

builtin/submodule--helper.c::run_update_procedure() takes sm_path to
the path to the submodule, presumably from superproject's point of
view, and the callchain leads to a call to run_update_command()
eventually, which uses run_command_v_opt_cd_env() to go in to the
submodule repository and run an external git command (like
"checkout"), so it looks like what git_config_set() updates is the
superprojects' configuration, not the configuration of a particular
submodule being updated.

The other one, where cmd_clone() sets the variable in submodule's
configuration file, looks good, but I am not sure about this one.