Skip to content

Commit 6c1db1b

Browse files
jrngitster
authored andcommitted
unpack-trees: use 'cuddled' style for if-else cascade
Match the predominant style in git by following K&R style for if/else cascades. Documentation/CodingStyle from linux.git 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: if (x == y) { .. } else if (x > y) { ... } else { .... } Rationale: K&R. Also, note that this brace-placement also minimizes the number of empty (or almost empty) lines, without any loss of readability. Signed-off-by: Jonathan Nieder <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 0ecd180 commit 6c1db1b

File tree

1 file changed

+4
-8
lines changed

1 file changed

+4
-8
lines changed

unpack-trees.c

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1771,8 +1771,7 @@ int twoway_merge(const struct cache_entry * const *src,
17711771
return merged_entry(newtree, current, o);
17721772
}
17731773
return o->gently ? -1 : reject_merge(current, o);
1774-
}
1775-
else if ((!oldtree && !newtree) || /* 4 and 5 */
1774+
} else if ((!oldtree && !newtree) || /* 4 and 5 */
17761775
(!oldtree && newtree &&
17771776
same(current, newtree)) || /* 6 and 7 */
17781777
(oldtree && newtree &&
@@ -1781,17 +1780,14 @@ int twoway_merge(const struct cache_entry * const *src,
17811780
!same(oldtree, newtree) && /* 18 and 19 */
17821781
same(current, newtree))) {
17831782
return keep_entry(current, o);
1784-
}
1785-
else if (oldtree && !newtree && same(current, oldtree)) {
1783+
} else if (oldtree && !newtree && same(current, oldtree)) {
17861784
/* 10 or 11 */
17871785
return deleted_entry(oldtree, current, o);
1788-
}
1789-
else if (oldtree && newtree &&
1786+
} else if (oldtree && newtree &&
17901787
same(current, oldtree) && !same(current, newtree)) {
17911788
/* 20 or 21 */
17921789
return merged_entry(newtree, current, o);
1793-
}
1794-
else
1790+
} else
17951791
return o->gently ? -1 : reject_merge(current, o);
17961792
}
17971793
else if (newtree) {

0 commit comments

Comments
 (0)