Skip to content

Fix clang-format refusing to read the repo's config - #627

Merged
hannesa2 merged 1 commit into
gitx:masterfrom
goneng:fix-clang-format-duplicate-key
Sep 13, 2026
Merged

hannesa2 merged 1 commit into
gitx:masterfrom
goneng:fix-clang-format-duplicate-key

Conversation

@goneng

@goneng goneng commented Sep 13, 2026

Copy link
Copy Markdown
Collaborator

A duplicated key makes the whole file unusable, not just that setting.

.clang-format lists AllowShortFunctionsOnASingleLine twice, on lines 19 and
21, and clang-format rejects the file outright rather than taking the last
value:

.clang-format:21:1: error: duplicated mapping key 'AllowShortFunctionsOnASingleLine'
Error reading .clang-format: Invalid argument

So .github/instructions/objective-c.instructions.md asks for a clang-format
run before committing that cannot succeed, and nothing in the build or in
BuildPR.yml runs the tool, so the breakage never surfaces in a log. Raised by
@anandghegde while working on #621.

  • Drop the older true spelling and keep All, which is the same value, so
    the effective style is unchanged

Test plan

  • Before: xcrun clang-format -style=file -dump-config fails with the error
    above. After: it prints a config. (Apple clang-format 17.0.0, the one Xcode
    ships, so no install is needed to reproduce.)
  • No formatting change: dumping the config with line 21 removed instead of line
    19 gives a byte-identical result, since the legacy boolean true maps to
    All
  • Nothing to build or test: clang-format is not part of the build

A duplicated key makes the whole file unusable, not just that setting.

clang-format stops at the second AllowShortFunctionsOnASingleLine and
reads no style at all, so anyone following the instruction to format
before committing gets an error and commits unformatted instead.

* Drop the older `true` spelling and keep `All`, which is the same
  value, so the effective style is unchanged
@goneng
goneng force-pushed the fix-clang-format-duplicate-key branch from 40c175a to e1a93f9 Compare September 13, 2026 08:42
@goneng
goneng marked this pull request as ready for review September 13, 2026 09:52
@hannesa2
hannesa2 merged commit 96f496b into gitx:master Sep 13, 2026
3 checks passed
@goneng
goneng deleted the fix-clang-format-duplicate-key branch September 13, 2026 11:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants