git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: What's cooking in git.git (Jan 2017, #02; Sun, 15)

From
Jeff King <peff@peff.net>
Date
Jan 17, 2017, 19:36 UTC
Message-ID
<20170117193639.mt3x3md3nbh2qgws@sigill.intra.peff.net>
In-Reply-To
<xmqqk29tfq79.fsf@gitster.mtv.corp.google.com>
On Tue, Jan 17, 2017 at 11:20:58AM -0800, Junio C Hamano wrote:
Show 27 quoted lines
> > Documentation/CodingGuidelines says:
> >
> >  - We avoid using braces unnecessarily.  I.e.
> >
> >         if (bla) {
> >                 x = 1;
> >         }
> >
> >    is frowned upon.  A gray area is when the statement extends
> >    over a few lines, and/or you have a lengthy comment atop of
> >    it.  Also, like in the Linux kernel, if there is a long list
> >    of "else if" statements, it can make sense to add braces to
> >    single line blocks.
> >
> > I think this is pretty clearly the "gray area" mentioned there. Which
> > yes, does not say "definitely do it this way", but I hope makes it clear
> > that you're supposed to use judgement about readability.
> 
> I always took "gray area" to mean "we do not have strong preference
> either way, i.e.
> 
>  * It is OK for you to write your new code in either style (the
>    usual "match existing style in surrounding code" applies,
>    obviously);
> 
>  * It is not OK for you to churn the codebase with a patch that only
>    changes existing code to flip between the two styles.

That was my general impression, too. But I seem to recall it was you in a nearby thread saying that:

  if (foo)
	bar();
  else {
        one();
	two();
  }
was wrong. Maybe I misunderstood.
-Peff
Previous: Junio C HamanoNext: Junio C Hamano
Message 21 of 28 in “What's cooking in git.git (Jan 2017, #02; Sun, 15)”
  1. Junio C HamanoJan 16, 2017
  2. Johannes SixtJan 16, 2017
  3. Junio C HamanoJan 16, 2017
  4. Johannes SchindelinJan 16, 2017
  5. Jeff KingJan 16, 2017
  6. Johannes SchindelinJan 16, 2017
  7. Johannes SixtJan 16, 2017
  8. Jeff KingJan 16, 2017
  9. Junio C HamanoJan 17, 2017
  10. Johannes SixtJan 18, 2017
  11. Junio C HamanoJan 18, 2017
  12. Johannes SchindelinJan 19, 2017
  13. Jeff KingJan 16, 2017
  14. CodingGuidelines: clarify multi-line brace styleJeff King, Jan 16, 2017
  15. Junio C HamanoJan 17, 2017
  16. Jeff KingJan 17, 2017
  17. Junio C HamanoJan 17, 2017
  18. Jacob KellerJan 17, 2017
  19. Jeff KingJan 17, 2017
  20. Junio C HamanoJan 17, 2017
  21. Jeff KingJan 17, 2017
  22. Junio C HamanoJan 17, 2017
  23. Jeff KingJan 17, 2017
  24. Johannes SchindelinJan 16, 2017
  25. Junio C HamanoJan 17, 2017
  26. Johannes SchindelinJan 18, 2017
  27. Johannes SchindelinJan 16, 2017
  28. 4/4 unpack-trees: support super-prefix optionStefan Beller, Jan 18, 2017

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.