Re: [PATCH] style: indent multiline "if" conditions by 4 spaces

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

 



Jeff King <peff@xxxxxxxx> writes:

> Commit 6dc905d974 (config: split repo scope to local and worktree,
> 2020-02-10) made some "if" statements multiline, but didn't indent the
> second lines in our usual way.
>
> Signed-off-by: Jeff King <peff@xxxxxxxx>
> ---
> I just happened to be reading nearby code and saw this.

Can we rephrase "by 4 spaces" to avoid misleading new developers,
though?  It's not like our rule is to indent continued expression by
4 spaces---it happens to be 4 in this case only because the second
line is aligned with the column inside "if (".

If the expression were

	if ((A == X && B == Y &&
	     boolean_expression_on_the_second_line()) ||
	    C == Z)

we would have indented the second line to align with the inside of
the opening parenthesis, which may end up with "by 5 spaces", but
four vs five is not the important part of the equation.

Thanks.  

> diff --git a/remote.c b/remote.c
> index 8a6dbbb903..8b9d090ae5 100644
> --- a/remote.c
> +++ b/remote.c
> @@ -355,7 +355,7 @@ static int handle_config(const char *key, const char *value, void *cb)
>  	remote = make_remote(name, namelen);
>  	remote->origin = REMOTE_CONFIG;
>  	if (current_config_scope() == CONFIG_SCOPE_LOCAL ||
> -	current_config_scope() == CONFIG_SCOPE_WORKTREE)
> +	    current_config_scope() == CONFIG_SCOPE_WORKTREE)
>  		remote->configured_in_repo = 1;
>  	if (!strcmp(subkey, "mirror"))
>  		remote->mirror = git_config_bool(key, value);
> diff --git a/upload-pack.c b/upload-pack.c
> index 5dc8e1f844..a85d4ec502 100644
> --- a/upload-pack.c
> +++ b/upload-pack.c
> @@ -1302,7 +1302,7 @@ static int upload_pack_config(const char *var, const char *value, void *cb_data)
>  	}
>  
>  	if (current_config_scope() != CONFIG_SCOPE_LOCAL &&
> -	current_config_scope() != CONFIG_SCOPE_WORKTREE) {
> +	    current_config_scope() != CONFIG_SCOPE_WORKTREE) {
>  		if (!strcmp("uploadpack.packobjectshook", var))
>  			return git_config_string(&data->pack_objects_hook, var, value);
>  	}



[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