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

Re: [PATCH] Make git-clean a builtin

From
Brian Downing <bdowning@lavos.net>
Date
Nov 7, 2007, 20:51 UTC
Message-ID
<20071107205101.GE6212@lavos.net>
In-Reply-To
<Pine.LNX.4.64.0711071501270.4362@racer.site>
On Wed, Nov 07, 2007 at 03:04:52PM +0000, Johannes Schindelin wrote:
> I do count them.  Personally, I find it highly distracting and ugly.  
> Besides, we have the convention of putting the "}" not into the same line 
> as "else".  (See keyword "uncuddling" in the list archives.)

I was under the impression that Git followed the kernel coding standards, which seem to want "cuddled" else statements:

136 Note that the closing brace is empty on a line of its own, _except_ in 137 the cases where it is followed by a continuation of the same statement, 138 ie a "while" in a do-statement or an "else" in an if-statement, like 139 this: 140 141 do { 142 body of do-loop 143 } while (condition); 144 145 and 146 147 if (x == y) { 148 .. 149 } else if (x > y) { 150 ... 151 } else { 152 .... 153 } 154 155 Rationale: K&R.

Searching the MARC list archives for "uncuddling" only yields the message I am replying to.

In addition, the kernel style seems to want braces for all branches of a conditional if any branch needs it:

163 Do not unnecessarily use braces where a single statement will do. 164 165 if (condition) 166 action(); 167 168 This does not apply if one branch of a conditional statement is a single 169 statement. Use braces in both branches. 170 171 if (condition) { 172 do_this(); 173 do_that(); 174 } else { 175 otherwise(); 176 }

This makes sense (to me), as at most you're only adding one extra line for the final closing brace, and it makes the whole conditional look more "balanced", IMHO.

But regardless, whatever the actual style for Git should be followed. Life's too short for arguments about coding style (even if divergence from K&R brace style is just plain wrong. :)

-bcd
Previous: Johannes SchindelinNext: Junio C Hamano
Message 10 of 13 in “Make git-clean a builtin”
  1. Make git-clean a builtinShawn Bohrer, Nov 7, 2007
  2. Johannes SchindelinNov 7, 2007
  3. Bill LearNov 7, 2007
  4. Johannes SchindelinNov 7, 2007
  5. Matthieu MoyNov 7, 2007
  6. Jon LoeligerNov 7, 2007
  7. Miles BaderNov 10, 2007
  8. Shawn BohrerNov 7, 2007
  9. Johannes SchindelinNov 7, 2007
  10. Brian DowningNov 7, 2007
  11. Junio C HamanoNov 7, 2007
  12. Junio C HamanoNov 7, 2007
  13. Shawn BohrerNov 8, 2007

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.