Re: [PATCH v8 3/3] rev-parse: short-circuit superproject worktree when config unset

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Emily Shaffer <emilyshaffer@xxxxxxxxxx> writes:

> diff --git a/submodule.c b/submodule.c
> index 741104af8a..463e7f0c48 100644
> --- a/submodule.c
> +++ b/submodule.c
> @@ -2237,6 +2237,7 @@ int get_superproject_working_tree(struct strbuf *buf)
>  	struct strbuf sb = STRBUF_INIT;
>  	struct strbuf one_up = STRBUF_INIT;
>  	const char *cwd = xgetcwd();
> +	int has_superproject_cfg = 0;
>  	int ret = 0;
>  	const char *subpath;
>  	int code;
> @@ -2250,6 +2251,17 @@ int get_superproject_working_tree(struct strbuf *buf)
>  		 */
>  		return 0;
>  
> +	if (git_config_get_bool("submodule.hassuperproject", &has_superproject_cfg)
> +	    || !has_superproject_cfg) {

git_config_get_bool() returns 0 when it successfully finds the
variable, so the above says "If submodule.hasSuperproject is not set
at all, or if it is set to false, then..."

> +		/*
> +		 * If we don't have a superproject, then we're probably not a
> +		 * submodule. If this is failing and shouldn't be, investigate
> +		 * why the config was never set.
> +		 */
> +		error(_("Asked to find a superproject, but submodule.hasSuperproject != true"));
> +		return 0;

But given that this thing is new, I am not sure if that is a
sensible guard to use here.  Shouldn't we say 

 - If submodule.hasSuperproject is EXPLICITLY set to false then ...

instead?  I.e.

	if (!git_config_get_bool("submodule.hassuperproject", &value) &&
	    !value) {
		error(_("asked to ..."));
		return 0;
	}




[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux