git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Jeff King <peff@peff.net>
To: Junio C Hamano <gitster@pobox.com>
Cc: git@vger.kernel.org
Subject: Re: [PATCH] style: indent multiline "if" conditions by 4 spaces
Date: Thu, 3 Dec 2020 13:32:05 -0500	[thread overview]
Message-ID: <X8kvJRnOtSEYziRK@coredump.intra.peff.net> (raw)
In-Reply-To: <xmqqv9dihhqs.fsf@gitster.c.googlers.com>

On Thu, Dec 03, 2020 at 10:22:35AM -0800, Junio C Hamano wrote:

> Jeff King <peff@peff.net> 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@peff.net>
> > ---
> > 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.

Yeah, the goal is to align it, but I had trouble thinking of a succinct
way to say that. Maybe just:

  style: align indent of multiline "if" conditions

?

-Peff

  reply	other threads:[~2020-12-03 18:36 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-03  8:00 [PATCH] style: indent multiline "if" conditions by 4 spaces Jeff King
2020-12-03 18:22 ` Junio C Hamano
2020-12-03 18:32   ` Jeff King [this message]
2020-12-03 18:38     ` Junio C Hamano
2020-12-03 18:51       ` Jeff King

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=X8kvJRnOtSEYziRK@coredump.intra.peff.net \
    --to=peff@peff.net \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).