Re: [PATCH 1/5] safe_create_leading_directories(): modernize format of if chaining

2013-12-26 Thread Jonathan Nieder
Michael Haggerty wrote:

 [Subject: safe_create_leading_directories(): modernize format of if 
 chaining]

Trivia: it's not so much modernizing as following KR style, which git
more or less followed since day 1.  Linux's Documentation/CodingStyle
explains:

  Note that the closing brace is empty on a line of its own, _except_ in
  the cases where it is followed by a continuation of the same statement,
  ie a while in a do-statement or an else in an if-statement, like
  this:
[...]
  Rationale: KR.

  Also, note that this brace-placement also minimizes the number of empty
  (or almost empty) lines, without any loss of readability.  Thus, as the
  supply of new-lines on your screen is not a renewable resource (think
  25-line terminal screens here), you have more empty lines to put
  comments on.

Here it's especially jarring since the function uses a mix of styles.
Thanks for cleaning it up.
--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 1/5] safe_create_leading_directories(): modernize format of if chaining

2013-12-21 Thread Michael Haggerty
Signed-off-by: Michael Haggerty mhag...@alum.mit.edu
---
 sha1_file.c | 6 ++
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/sha1_file.c b/sha1_file.c
index daacc0c..c9245a6 100644
--- a/sha1_file.c
+++ b/sha1_file.c
@@ -125,8 +125,7 @@ int safe_create_leading_directories(char *path)
*pos = '/';
return -3;
}
-   }
-   else if (mkdir(path, 0777)) {
+   } else if (mkdir(path, 0777)) {
if (errno == EEXIST 
!stat(path, st)  S_ISDIR(st.st_mode)) {
; /* somebody created it since we checked */
@@ -134,8 +133,7 @@ int safe_create_leading_directories(char *path)
*pos = '/';
return -1;
}
-   }
-   else if (adjust_shared_perm(path)) {
+   } else if (adjust_shared_perm(path)) {
*pos = '/';
return -2;
}
-- 
1.8.5.1

--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html