<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/60153>60153</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            git-clang-format: InsertBraces on a diff does not apply braces to entire if-else-if-else.
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            new issue
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          pbos
      </td>
    </tr>
</table>

<pre>
    From a report in https://bugs.chromium.org/p/chromium/issues/detail?id=1392808#c5 formatting the diff applies braces to an else-if without the previous if or else-if statements:

```
+++ b/third_party/blink/renderer/core/page/focus_controller.cc
@@ -203,9 +203,9 @@ class FocusNavigation : public GarbageCollected<FocusNavigation> {
       owner = node.ParentOrShadowHostElement();
     else if (&node == node.ContainingTreeScope().RootNode())
       owner = TreeOwner(&node);
-    else if (owner_popover_invoker)
+    else if (owner_popover_invoker) {
       owner = owner_popover_invoker;
- else if (node.parentNode())
+    } else if (node.parentNode())
 owner = FindOwner(*node.parentNode());
```

It would be preferable if we extended diff formatting to the entire if-else-if-else thing. This also unfortunately hits one of our lint scripts:

`third_party/blink/renderer/core/page/focus_controller.cc:206: If one part of an if-else statement uses curly braces, the other part must too.  [whitespace/braces] [4]`

A known workaround is of course to format the codebase to be consistent with InsertBraces but that's currently controversial on our end.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJysVUFv4zgP_TXKhYjhSHHSHHJomvH3zWVmsTP3QrZoW1tFNCQ62fz7heS0zRbdxRw2EKzI0iMfn0VSx2h7j7gX1UFUx4WeeKCwHxuKi4bMdV8HOoGGgCMFButhYB6jUI9C1kLWzdTHoh0Cnex0Kij0QtajkPXrKyFrG-OEUcjaIGvrhKqtEeq4Ujv5UD4IqdoKOgonzWx9DzwgGNt1oMfRWYzQBN1iBCbQHtBFXNoOLpYHmjifHgOeLU0RbAcU3o5E1own9JzZlk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