{"thread":{"id":"62294","subject":"[PATCH 0/3] clang-format: fix rules to make the CI job cleaner","startedAt":"2024-10-09T12:51:13Z","lastAt":"2024-10-25T09:48:40Z","messageCount":34,"participants":["Karthik Nayak","Justin Tobler","Junio C Hamano","Toon Claes","karthik nayak","Kyle Lippincott","Taylor Blau"],"isPatch":true,"patchVersion":1,"patchTotal":3},"messages":[{"id":"504550","messageId":"CAOLa=ZRvFBhageS65uE5enzLBz7H_CAvvnEcPsi_QAi0exRx2w@mail.gmail.com","threadId":"62294","inReplyTo":null,"subject":"[PATCH 0/3] clang-format: fix rules to make the CI job cleaner","fromName":"Karthik Nayak","fromEmail":"karthik.188@gmail.com","sentAt":"2024-10-09T12:51:11Z","receivedAt":"2024-10-09T12:51:13Z","isPatch":true,"sender":{"key":"karthik.188@gmail.com","avatar":"https://avatars.githubusercontent.com/u/1786334?v=4"},"body":"The clang-format CI job is currently cluttered due to too many errors being\nreported. See some of the examples here:\n\n* https://gitlab.com/gitlab-org/git/-/jobs/7854601948\n* https://gitlab.com/gitlab-org/git/-/jobs/7843131109\n\nSo modify the clang-format with the following changes:\n1. Remove the column limit since this is more of a guideline and we always\ntend to prefer readability. This is the cause of most of the errors reported\nby the tool and should cleanup the reports so we can actually focus on the real\nremaining issues.\n2. Don't align expressions after linebreaks to ensure that we instead rely on\n'ContinuationIndentWidth'. This fix is rather small and ensures that instead of\ntrying to align wrapped expressions, we follow the indentation width.\n3. Align the macro definitions. This is something we follow to keep the macros\nreadable.\n\nI will still keep monitoring the jobs from time to time to ensure we can fine\ntune more as needed, if someone see's something odd, do keep me in the loop.\n\nThanks\n\nKarthik Nayak (3):\n  clang-format: don't enforce the column limit\n  clang-format: don't align expressions after linebreaks\n  clang-format: align consecutive macro definitions\n\n .clang-format | 16 +++++++++++-----\n 1 file changed, 11 insertions(+), 5 deletions(-)\n\n-- \n2.46.2\n"},{"id":"504552","messageId":"CAOLa=ZS+naxOzJUkLLOZk++WVZ2dt3eQq9VmW+G-5O1ZLgggUA@mail.gmail.com","threadId":"62294","inReplyTo":"CAOLa=ZRvFBhageS65uE5enzLBz7H_CAvvnEcPsi_QAi0exRx2w@mail.gmail.com","subject":"[PATCH 1/3] clang-format: don't enforce the column limit","fromName":"Karthik Nayak","fromEmail":"karthik.188@gmail.com","sentAt":"2024-10-09T12:55:59Z","receivedAt":"2024-10-09T12:56:00Z","isPatch":true,"sender":{"key":"karthik.188@gmail.com","avatar":"https://avatars.githubusercontent.com/u/1786334?v=4"},"body":"The current value for the column limit is set to 80. While this is as\nexpected, we often prefer readability over this strict limit. This means\nit is common to find code which extends over 80 characters. So let's\nchange the column limit to be 0 instead. This ensures that the formatter\ndoesn't complain about code strictly not following the column limit.\n\nSigned-off-by: Karthik Nayak <karthik.188@gmail.com>\n---\n .clang-format | 6 +++++-\n 1 file changed, 5 insertions(+), 1 deletion(-)\n\ndiff --git a/.clang-format b/.clang-format\nindex 41969eca4b..38910a3a53 100644\n--- a/.clang-format\n+++ b/.clang-format\n@@ -12,7 +12,11 @@ UseTab: Always\n TabWidth: 8\n IndentWidth: 8\n ContinuationIndentWidth: 8\n-ColumnLimit: 80\n+\n+# While we recommend keeping column limit to 80, we don't want to\n+# enforce it as we generally are more lenient with this rule and\n+# prefer to prioritize readability.\n+ColumnLimit: 0\n\n # C Language specifics\n Language: Cpp\n-- \n2.46.2\n"},{"id":"504553","messageId":"CAOLa=ZQOyio__8a5=h=65kkENhxPC4tTAFczioeOTvU2iSSkJQ@mail.gmail.com","threadId":"62294","inReplyTo":"CAOLa=ZRvFBhageS65uE5enzLBz7H_CAvvnEcPsi_QAi0exRx2w@mail.gmail.com","subject":"[PATCH 2/3] clang-format: don't align expressions after linebreaks","fromName":"Karthik Nayak","fromEmail":"karthik.188@gmail.com","sentAt":"2024-10-09T12:56:08Z","receivedAt":"2024-10-09T12:56:09Z","isPatch":true,"sender":{"key":"karthik.188@gmail.com","avatar":"https://avatars.githubusercontent.com/u/1786334?v=4"},"body":"We enforce alignment of expressions after linebreaks. Which means for\ncode such as\n\n    return a || b;\n\nit will expect:\n\n   return a ||\n          b;\n\nwe instead want 'b' to be indent with tabs, which is already done by the\n'ContinuationIndentWidth' variable. So let's explicitly set\n'AlignOperands' to false.\n\nSigned-off-by: Karthik Nayak <karthik.188@gmail.com>\n---\n .clang-format | 7 +++----\n 1 file changed, 3 insertions(+), 4 deletions(-)\n\ndiff --git a/.clang-format b/.clang-format\nindex 38910a3a53..af12a038f7 100644\n--- a/.clang-format\n+++ b/.clang-format\n@@ -43,10 +43,9 @@ AlignConsecutiveDeclarations: false\n #   int cccccccc;\n AlignEscapedNewlines: Left\n\n-# Align operands of binary and ternary expressions\n-# int aaa = bbbbbbbbbbb +\n-#           cccccc;\n-AlignOperands: true\n+# Don't enforce alignment after linebreaks and instead\n+# rely on the ContinuationIndentWidth value.\n+AlignOperands: false\n\n # Don't align trailing comments\n # int a; // Comment a\n-- \n2.46.2\n"},{"id":"504554","messageId":"CAOLa=ZTAgaOK3KzsncTq1ZydXFbiG8M7MSsC9S9zUK4gdPPdOQ@mail.gmail.com","threadId":"62294","inReplyTo":"CAOLa=ZRvFBhageS65uE5enzLBz7H_CAvvnEcPsi_QAi0exRx2w@mail.gmail.com","subject":"[PATCH 3/3] clang-format: align consecutive macro definitions","fromName":"Karthik Nayak","fromEmail":"karthik.188@gmail.com","sentAt":"2024-10-09T12:56:14Z","receivedAt":"2024-10-09T12:56:15Z","isPatch":true,"sender":{"key":"karthik.188@gmail.com","avatar":"https://avatars.githubusercontent.com/u/1786334?v=4"},"body":"We generally align consecutive macro definitions for better readability.\nSo let's add the rule in clang-format to follow this.\n\nSigned-off-by: Karthik Nayak <karthik.188@gmail.com>\n---\n .clang-format | 3 +++\n 1 file changed, 3 insertions(+)\n\ndiff --git a/.clang-format b/.clang-format\nindex af12a038f7..d76d5f1e6a 100644\n--- a/.clang-format\n+++ b/.clang-format\n@@ -36,6 +36,9 @@ AlignConsecutiveAssignments: false\n # double b = 3.14;\n AlignConsecutiveDeclarations: false\n\n+# Align consecutive macro definitions.\n+AlignConsecutiveMacros: true\n+\n # Align escaped newlines as far left as possible\n # #define A   \\\n #   int aaaa; \\\n-- \n2.46.2\n"},{"id":"504598","messageId":"zmqyj3v2h3hswoujpz2er5luvjipjl3i4ts6xjdeb43wp42xf2@i5xee2lsmriz","threadId":"62294","inReplyTo":"CAOLa=ZS+naxOzJUkLLOZk++WVZ2dt3eQq9VmW+G-5O1ZLgggUA@mail.gmail.com","subject":"Re: [PATCH 1/3] clang-format: don't enforce the column limit","fromName":"Justin Tobler","fromEmail":"jltobler@gmail.com","sentAt":"2024-10-09T15:45:45Z","receivedAt":"2024-10-09T15:47:11Z","isPatch":true,"sender":{"key":"jltobler@gmail.com","avatar":"https://avatars.githubusercontent.com/u/53454972?v=4"},"body":"On 24/10/09 05:55AM, Karthik Nayak wrote:\n> The current value for the column limit is set to 80. While this is as\n> expected, we often prefer readability over this strict limit. This means\n> it is common to find code which extends over 80 characters. So let's\n> change the column limit to be 0 instead. This ensures that the formatter\n> doesn't complain about code strictly not following the column limit.\n\nThe column limit does lead to quite a few false positives. At the same\ntime though, in some ways having a tool point out all the instances it\noccurs does make it easier to review if any should be addressed.\n\nIf the goal is to have a CI job that we generally expect to pass, then\nit makes sense to remove it. I don't feel super strongly either way.\n\n-Justin\n"},{"id":"504660","messageId":"xmqqttdkoqks.fsf@gitster.g","threadId":"62294","inReplyTo":"zmqyj3v2h3hswoujpz2er5luvjipjl3i4ts6xjdeb43wp42xf2@i5xee2lsmriz","subject":"Re: [PATCH 1/3] clang-format: don't enforce the column limit","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2024-10-09T22:32:19Z","receivedAt":"2024-10-09T22:32:22Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Justin Tobler <jltobler@gmail.com> writes:\n\n> On 24/10/09 05:55AM, Karthik Nayak wrote:\n>> The current value for the column limit is set to 80. While this is as\n>> expected, we often prefer readability over this strict limit. This means\n>> it is common to find code which extends over 80 characters. So let's\n>> change the column limit to be 0 instead. This ensures that the formatter\n>> doesn't complain about code strictly not following the column limit.\n>\n> The column limit does lead to quite a few false positives. At the same\n> time though, in some ways having a tool point out all the instances it\n> occurs does make it easier to review if any should be addressed.\n>\n> If the goal is to have a CI job that we generally expect to pass, then\n> it makes sense to remove it. I don't feel super strongly either way.\n\nIs it possible for gatekeeper jobs to complain only on newly added\nviolations?  Then it is fine to have a limit with a bit of slack,\nsay like 96 columns (with 16-column readability slack).\n\n"},{"id":"504683","messageId":"87a5fcs6qr.fsf@iotcl.com","threadId":"62294","inReplyTo":"CAOLa=ZTAgaOK3KzsncTq1ZydXFbiG8M7MSsC9S9zUK4gdPPdOQ@mail.gmail.com","subject":"Re: [PATCH 3/3] clang-format: align consecutive macro definitions","fromName":"Toon Claes","fromEmail":"toon@iotcl.com","sentAt":"2024-10-10T08:27:08Z","receivedAt":"2024-10-10T08:27:41Z","isPatch":true,"sender":{"key":"toon@iotcl.com","avatar":"https://avatars.githubusercontent.com/u/121621?v=4"},"body":"Karthik Nayak <karthik.188@gmail.com> writes:\n\n> We generally align consecutive macro definitions for better readability.\n> So let's add the rule in clang-format to follow this.\n>\n> Signed-off-by: Karthik Nayak <karthik.188@gmail.com>\n\nI think it's valuable to add an example what bad vs good formatted code\nlooks like.\n\nOtherwise no comments about this series.\n\n--\nToon\n"},{"id":"504714","messageId":"CAOLa=ZRRHYwe7=aJogL0=R8SHyPkHeC7C34R3mkR-gmzkRQ9JA@mail.gmail.com","threadId":"62294","inReplyTo":"xmqqttdkoqks.fsf@gitster.g","subject":"Re: [PATCH 1/3] clang-format: don't enforce the column limit","fromName":"karthik nayak","fromEmail":"karthik.188@gmail.com","sentAt":"2024-10-10T16:48:34Z","receivedAt":"2024-10-10T16:48:36Z","isPatch":true,"sender":{"key":"karthik.188@gmail.com","avatar":"https://avatars.githubusercontent.com/u/1786334?v=4"},"body":"Junio C Hamano <gitster@pobox.com> writes:\n\n> Justin Tobler <jltobler@gmail.com> writes:\n>\n>> On 24/10/09 05:55AM, Karthik Nayak wrote:\n>>> The current value for the column limit is set to 80. While this is as\n>>> expected, we often prefer readability over this strict limit. This means\n>>> it is common to find code which extends over 80 characters. So let's\n>>> change the column limit to be 0 instead. This ensures that the formatter\n>>> doesn't complain about code strictly not following the column limit.\n>>\n>> The column limit does lead to quite a few false positives. At the same\n>> time though, in some ways having a tool point out all the instances it\n>> occurs does make it easier to review if any should be addressed.\n>>\n>> If the goal is to have a CI job that we generally expect to pass, then\n>> it makes sense to remove it. I don't feel super strongly either way.\n> Is it possible for gatekeeper jobs to complain only on newly added\n> violations?\n\nThe CI job is indeed only checking the newly added code. We do this\nusing 'git clang-format' which takes in the basecommit as a param. This\nis in 'ci/run-style-check.sh'.\n\n> Then it is fine to have a limit with a bit of slack,\n> say like 96 columns (with 16-column readability slack).\n\nThis is a good idea. Let me add change this in the next version.\n"},{"id":"504889","messageId":"cover.1728697428.git.karthik.188@gmail.com","threadId":"62294","inReplyTo":"CAOLa=ZRvFBhageS65uE5enzLBz7H_CAvvnEcPsi_QAi0exRx2w@mail.gmail.com","subject":"[PATCH v3 0/3] clang-format: fix rules to make the CI job cleaner","fromName":"Karthik Nayak","fromEmail":"karthik.188@gmail.com","sentAt":"2024-10-12T01:49:50Z","receivedAt":"2024-10-12T01:49:59Z","isPatch":true,"sender":{"key":"karthik.188@gmail.com","avatar":"https://avatars.githubusercontent.com/u/1786334?v=4"},"body":"The clang-format CI job is currently cluttered due to too many errors being\nreported. See some of the examples here:\n\n* https://gitlab.com/gitlab-org/git/-/jobs/7854601948\n* https://gitlab.com/gitlab-org/git/-/jobs/7843131109\n\nSo modify the clang-format with the following changes:\n1. Modify the penalties for linebreaks to be more considerate towards\nreadability. The commit goes into detail explaining how/why.  \n2. Don't align expressions after linebreaks to ensure that we instead rely on\n'ContinuationIndentWidth'. This fix is rather small and ensures that instead of\ntrying to align wrapped expressions, we follow the indentation width.\n3. Align the macro definitions. This is something we follow to keep the macros\nreadable. \n\nI will still keep monitoring the jobs from time to time to ensure we can fine\ntune more as needed, if someone see's something odd, do keep me in the loop.\n\nThanks\n\nChanges over the previous version:\n1. I figured that we can keep the column limit to the previous 80 while still\nhaving some breathing room by tweaking the penalties associated with line breaks.\nAlso CC'in Johannes here, since this builds on top of his changes.\n\nKarthik Nayak (3):\n  clang-format: re-adjust line break penalties\n  clang-format: align consecutive macro definitions\n  clang-format: don't align expressions after linebreaks\n\n .clang-format | 23 +++++++++++++----------\n 1 file changed, 13 insertions(+), 10 deletions(-)\n\nRange-diff against v2:\n1:  e22ffbe0f6 ! 1:  74bbd2f9db clang-format: change column limit to 96 characters\n    @@ Metadata\n     Author: Karthik Nayak <karthik.188@gmail.com>\n     \n      ## Commit message ##\n    -    clang-format: change column limit to 96 characters\n    +    clang-format: re-adjust line break penalties\n     \n    -    The current value for the column limit is set to 80. While this is as\n    -    expected, we often prefer readability over this strict limit. This means\n    -    it is common to find code which extends over 80 characters. So let's\n    -    change the column limit to be 96 instead. This provides some slack so we\n    -    can ensure readability takes preference over the 80 character hard\n    -    limit.\n    +    In 42efde4c29 (clang-format: adjust line break penalties, 2017-09-29) we\n    +    adjusted the line break penalties to really fine tune what we care about\n    +    while doing line breaks. Modify some of those to be more inline with\n    +    what we care about in the Git project now.\n    +\n    +    We need to understand that the values set to penalties in\n    +    '.clang-format' are relative to each other and do not hold any absolute\n    +    value. The penalty arguments take an 'Unsigned' value, so we have some\n    +    liberty over the values we can set.\n    +\n    +    First, in that commit, we decided, that under no circumstances do we\n    +    want to exceed 80 characters. This seems a bit too strict. We do\n    +    overshoot this limit from time to time to prioritize readability. So\n    +    let's reduce the value for 'PenaltyExcessCharacter' to 10. This means we\n    +    that we add a penalty of 10 for each character that exceeds the column\n    +    limit. By itself this is enough to restrict to column limit. Tuning\n    +    other penalties in relation to this is what is important.\n    +\n    +    The penalty `PenaltyBreakAssignment` talks about the penalty for\n    +    breaking an assignment operator on to the next line. In our project, we\n    +    are okay with this, so giving a value of 5, which is below the value for\n    +    'PenaltyExcessCharacter' ensures that in the end, even 1 character over\n    +    the column limit is not worth keeping an assignment on the same line.\n    +\n    +    Similarly set the penalty for breaking before the first call parameter\n    +    'PenaltyBreakBeforeFirstCallParameter' and the penalty for breaking\n    +    comments 'PenaltyBreakComment' and the penalty for breaking string\n    +    literals 'PenaltyBreakString' also to 5.\n    +\n    +    Finally, we really care about not breaking the return type into its own\n    +    line and we really care about not breaking before an open parenthesis.\n    +    This avoids weird formatting like:\n    +\n    +       static const struct strbuf *\n    +              a_really_really_large_function_name(struct strbuf resolved,\n    +              const char *path, int flags)\n    +\n    +    or\n    +\n    +       static const struct strbuf *a_really_really_large_function_name(\n    +                struct strbuf resolved, const char *path, int flags)\n    +\n    +    to instead have something more readable like:\n    +\n    +       static const struct strbuf *a_really_really_large_function_name(struct strbuf resolved,\n    +              const char *path, int flags)\n    +\n    +    This is done by bumping the values of 'PenaltyReturnTypeOnItsOwnLine'\n    +    and 'PenaltyBreakOpenParenthesis' to 300. This is so that we can allow a\n    +    few characters above the 80 column limit to make code more readable.\n     \n         Signed-off-by: Karthik Nayak <karthik.188@gmail.com>\n     \n      ## .clang-format ##\n    -@@ .clang-format: UseTab: Always\n    - TabWidth: 8\n    - IndentWidth: 8\n    - ContinuationIndentWidth: 8\n    --ColumnLimit: 80\n    -+\n    -+# While we recommend keeping column limit to 80, we want to also provide\n    -+# some slack to maintain readability.\n    -+ColumnLimit: 96\n    +@@ .clang-format: KeepEmptyLinesAtTheStartOfBlocks: false\n    + \n    + # Penalties\n    + # This decides what order things should be done if a line is too long\n    +-PenaltyBreakAssignment: 10\n    +-PenaltyBreakBeforeFirstCallParameter: 30\n    +-PenaltyBreakComment: 10\n    ++PenaltyBreakAssignment: 5\n    ++PenaltyBreakBeforeFirstCallParameter: 5\n    ++PenaltyBreakComment: 5\n    + PenaltyBreakFirstLessLess: 0\n    +-PenaltyBreakString: 10\n    +-PenaltyExcessCharacter: 100\n    +-PenaltyReturnTypeOnItsOwnLine: 60\n    ++PenaltyBreakOpenParenthesis: 300\n    ++PenaltyBreakString: 5\n    ++PenaltyExcessCharacter: 10\n    ++PenaltyReturnTypeOnItsOwnLine: 300\n      \n    - # C Language specifics\n    - Language: Cpp\n    + # Don't sort #include's\n    + SortIncludes: false\n3:  6ebcd2690e = 2:  1586d53769 clang-format: align consecutive macro definitions\n2:  b55d5d2c14 ! 3:  36a53299c1 clang-format: don't align expressions after linebreaks\n    @@ Commit message\n         Signed-off-by: Karthik Nayak <karthik.188@gmail.com>\n     \n      ## .clang-format ##\n    -@@ .clang-format: AlignConsecutiveDeclarations: false\n    +@@ .clang-format: AlignConsecutiveMacros: true\n      #   int cccccccc;\n      AlignEscapedNewlines: Left\n      \n-- \n2.47.0\n\n"},{"id":"504890","messageId":"74bbd2f9db1ddfd5210be8fde2db84f67acff27d.1728697428.git.karthik.188@gmail.com","threadId":"62294","inReplyTo":"cover.1728697428.git.karthik.188@gmail.com","subject":"[PATCH v3 1/3] clang-format: re-adjust line break penalties","fromName":"Karthik Nayak","fromEmail":"karthik.188@gmail.com","sentAt":"2024-10-12T01:49:51Z","receivedAt":"2024-10-12T01:50:01Z","isPatch":true,"sender":{"key":"karthik.188@gmail.com","avatar":"https://avatars.githubusercontent.com/u/1786334?v=4"},"body":"In 42efde4c29 (clang-format: adjust line break penalties, 2017-09-29) we\nadjusted the line break penalties to really fine tune what we care about\nwhile doing line breaks. Modify some of those to be more inline with\nwhat we care about in the Git project now.\n\nWe need to understand that the values set to penalties in\n'.clang-format' are relative to each other and do not hold any absolute\nvalue. The penalty arguments take an 'Unsigned' value, so we have some\nliberty over the values we can set.\n\nFirst, in that commit, we decided, that under no circumstances do we\nwant to exceed 80 characters. This seems a bit too strict. We do\novershoot this limit from time to time to prioritize readability. So\nlet's reduce the value for 'PenaltyExcessCharacter' to 10. This means we\nthat we add a penalty of 10 for each character that exceeds the column\nlimit. By itself this is enough to restrict to column limit. Tuning\nother penalties in relation to this is what is important.\n\nThe penalty `PenaltyBreakAssignment` talks about the penalty for\nbreaking an assignment operator on to the next line. In our project, we\nare okay with this, so giving a value of 5, which is below the value for\n'PenaltyExcessCharacter' ensures that in the end, even 1 character over\nthe column limit is not worth keeping an assignment on the same line.\n\nSimilarly set the penalty for breaking before the first call parameter\n'PenaltyBreakBeforeFirstCallParameter' and the penalty for breaking\ncomments 'PenaltyBreakComment' and the penalty for breaking string\nliterals 'PenaltyBreakString' also to 5.\n\nFinally, we really care about not breaking the return type into its own\nline and we really care about not breaking before an open parenthesis.\nThis avoids weird formatting like:\n\n   static const struct strbuf *\n          a_really_really_large_function_name(struct strbuf resolved,\n          const char *path, int flags)\n\nor\n\n   static const struct strbuf *a_really_really_large_function_name(\n   \t    struct strbuf resolved, const char *path, int flags)\n\nto instead have something more readable like:\n\n   static const struct strbuf *a_really_really_large_function_name(struct strbuf resolved,\n          const char *path, int flags)\n\nThis is done by bumping the values of 'PenaltyReturnTypeOnItsOwnLine'\nand 'PenaltyBreakOpenParenthesis' to 300. This is so that we can allow a\nfew characters above the 80 column limit to make code more readable.\n\nSigned-off-by: Karthik Nayak <karthik.188@gmail.com>\n---\n .clang-format | 13 +++++++------\n 1 file changed, 7 insertions(+), 6 deletions(-)\n\ndiff --git a/.clang-format b/.clang-format\nindex 41969eca4b..66a2360ae5 100644\n--- a/.clang-format\n+++ b/.clang-format\n@@ -209,13 +209,14 @@ KeepEmptyLinesAtTheStartOfBlocks: false\n \n # Penalties\n # This decides what order things should be done if a line is too long\n-PenaltyBreakAssignment: 10\n-PenaltyBreakBeforeFirstCallParameter: 30\n-PenaltyBreakComment: 10\n+PenaltyBreakAssignment: 5\n+PenaltyBreakBeforeFirstCallParameter: 5\n+PenaltyBreakComment: 5\n PenaltyBreakFirstLessLess: 0\n-PenaltyBreakString: 10\n-PenaltyExcessCharacter: 100\n-PenaltyReturnTypeOnItsOwnLine: 60\n+PenaltyBreakOpenParenthesis: 300\n+PenaltyBreakString: 5\n+PenaltyExcessCharacter: 10\n+PenaltyReturnTypeOnItsOwnLine: 300\n \n # Don't sort #include's\n SortIncludes: false\n-- \n2.47.0\n\n"},{"id":"504891","messageId":"1586d5376915a4662c92b8c0881596952c4500bb.1728697428.git.karthik.188@gmail.com","threadId":"62294","inReplyTo":"cover.1728697428.git.karthik.188@gmail.com","subject":"[PATCH v3 2/3] clang-format: align consecutive macro definitions","fromName":"Karthik Nayak","fromEmail":"karthik.188@gmail.com","sentAt":"2024-10-12T01:49:52Z","receivedAt":"2024-10-12T01:50:03Z","isPatch":true,"sender":{"key":"karthik.188@gmail.com","avatar":"https://avatars.githubusercontent.com/u/1786334?v=4"},"body":"We generally align consecutive macro definitions for better readability:\n\n  #define OUTPUT_ANNOTATE_COMPAT      (1U<<0)\n  #define OUTPUT_LONG_OBJECT_NAME     (1U<<1)\n  #define OUTPUT_RAW_TIMESTAMP        (1U<<2)\n  #define OUTPUT_PORCELAIN            (1U<<3)\n\nover\n\n  #define OUTPUT_ANNOTATE_COMPAT (1U<<0)\n  #define OUTPUT_LONG_OBJECT_NAME (1U<<1)\n  #define OUTPUT_RAW_TIMESTAMP (1U<<2)\n  #define OUTPUT_PORCELAIN (1U<<3)\n\nSo let's add the rule in clang-format to follow this.\n\nSigned-off-by: Karthik Nayak <karthik.188@gmail.com>\n---\n .clang-format | 3 +++\n 1 file changed, 3 insertions(+)\n\ndiff --git a/.clang-format b/.clang-format\nindex 66a2360ae5..9547fe1b77 100644\n--- a/.clang-format\n+++ b/.clang-format\n@@ -32,6 +32,9 @@ AlignConsecutiveAssignments: false\n # double b = 3.14;\n AlignConsecutiveDeclarations: false\n \n+# Align consecutive macro definitions.\n+AlignConsecutiveMacros: true\n+\n # Align escaped newlines as far left as possible\n # #define A   \\\n #   int aaaa; \\\n-- \n2.47.0\n\n"},{"id":"504892","messageId":"36a53299c1ab1b55a09b7e1d499832e6715ebaba.1728697428.git.karthik.188@gmail.com","threadId":"62294","inReplyTo":"cover.1728697428.git.karthik.188@gmail.com","subject":"[PATCH v3 3/3] clang-format: don't align expressions after linebreaks","fromName":"Karthik Nayak","fromEmail":"karthik.188@gmail.com","sentAt":"2024-10-12T01:49:53Z","receivedAt":"2024-10-12T01:50:05Z","isPatch":true,"sender":{"key":"karthik.188@gmail.com","avatar":"https://avatars.githubusercontent.com/u/1786334?v=4"},"body":"We enforce alignment of expressions after linebreaks. Which means for\ncode such as\n\n    return a || b;\n\nit will expect:\n\n   return a ||\n          b;\n\nwe instead want 'b' to be indent with tabs, which is already done by the\n'ContinuationIndentWidth' variable. So let's explicitly set\n'AlignOperands' to false.\n\nSigned-off-by: Karthik Nayak <karthik.188@gmail.com>\n---\n .clang-format | 7 +++----\n 1 file changed, 3 insertions(+), 4 deletions(-)\n\ndiff --git a/.clang-format b/.clang-format\nindex 9547fe1b77..b48e7813e4 100644\n--- a/.clang-format\n+++ b/.clang-format\n@@ -42,10 +42,9 @@ AlignConsecutiveMacros: true\n #   int cccccccc;\n AlignEscapedNewlines: Left\n \n-# Align operands of binary and ternary expressions\n-# int aaa = bbbbbbbbbbb +\n-#           cccccc;\n-AlignOperands: true\n+# Don't enforce alignment after linebreaks and instead\n+# rely on the ContinuationIndentWidth value.\n+AlignOperands: false\n \n # Don't align trailing comments\n # int a; // Comment a\n-- \n2.47.0\n\n"},{"id":"504976","messageId":"871q0jrr02.fsf@iotcl.com","threadId":"62294","inReplyTo":"74bbd2f9db1ddfd5210be8fde2db84f67acff27d.1728697428.git.karthik.188@gmail.com","subject":"Re: [PATCH v3 1/3] clang-format: re-adjust line break penalties","fromName":"Toon Claes","fromEmail":"toon@iotcl.com","sentAt":"2024-10-14T09:08:29Z","receivedAt":"2024-10-14T09:08:47Z","isPatch":true,"sender":{"key":"toon@iotcl.com","avatar":"https://avatars.githubusercontent.com/u/121621?v=4"},"body":"Karthik Nayak <karthik.188@gmail.com> writes:\n\n[snip]\n\n> This avoids weird formatting like:\n>\n>    static const struct strbuf *\n>           a_really_really_large_function_name(struct strbuf resolved,\n>           const char *path, int flags)\n>\n> or\n>\n>    static const struct strbuf *a_really_really_large_function_name(\n>    \t    struct strbuf resolved, const char *path, int flags)\n>\n> to instead have something more readable like:\n>\n>    static const struct strbuf *a_really_really_large_function_name(struct strbuf resolved,\n>           const char *path, int flags)\n>\n> This is done by bumping the values of 'PenaltyReturnTypeOnItsOwnLine'\n> and 'PenaltyBreakOpenParenthesis' to 300. This is so that we can allow a\n> few characters above the 80 column limit to make code more readable.\n\nI'm really liking the idea of penalties, but I feel we're relying too\nmuch on guestimation of these values. What do you think about adding\nexample files to our codebase? Having concrete examples at hand will\nallow us to tweak the values in the future, while preserving behavior\nfor existing cases. Or when we decide to change them, we understand\nwhat and when.\n\nNow, I'm not sure where to put such files. I think I would suggest\nsomething like t/style-lint or t/clang-format. Anyway, for our tooling\nit doesn't seem to matter, because both `make style` and\n`ci/run-style-check.sh` pick up all .c and .h files anywhere in the\nsource tree. Adding a README to that directory will help people\nunderstand why the files are there.\n\n--\nToon\n"},{"id":"505058","messageId":"CAO_smViSU5KohOqVXp2L_cM3G-jrOGQY=J=qf=-GbiGsOYd9TQ@mail.gmail.com","threadId":"62294","inReplyTo":"74bbd2f9db1ddfd5210be8fde2db84f67acff27d.1728697428.git.karthik.188@gmail.com","subject":"Re: [PATCH v3 1/3] clang-format: re-adjust line break penalties","fromName":"Kyle Lippincott","fromEmail":"spectral@google.com","sentAt":"2024-10-14T20:59:57Z","receivedAt":"2024-10-14T21:00:10Z","isPatch":true,"sender":{"key":"spectral@google.com","avatar":"https://avatars.githubusercontent.com/u/6371650?v=4"},"body":"On Fri, Oct 11, 2024 at 6:50 PM Karthik Nayak <karthik.188@gmail.com> wrote:\n>\n> In 42efde4c29 (clang-format: adjust line break penalties, 2017-09-29) we\n> adjusted the line break penalties to really fine tune what we care about\n> while doing line breaks. Modify some of those to be more inline with\n> what we care about in the Git project now.\n>\n> We need to understand that the values set to penalties in\n> '.clang-format' are relative to each other and do not hold any absolute\n> value. The penalty arguments take an 'Unsigned' value, so we have some\n> liberty over the values we can set.\n>\n> First, in that commit, we decided, that under no circumstances do we\n> want to exceed 80 characters. This seems a bit too strict. We do\n> overshoot this limit from time to time to prioritize readability.\n\nI think that attempting to get the weights right so as to avoid cases\nwhere there was an intentional affordance for readability is going to\nbe essentially impossible. Areas where there's an intentional\ndisregard for the clang-format-generated formatting should disable the\nformatter for that line/region, instead of trying to find a way to\nadjust the rules to produce something that's going to end up being\ncontext dependent.\n\nExample: In ref-filter.c, there's 13 lines when initializing the\n`valid_atom` array that are >80 characters, and 20 lines that are >80\ncolumns (when using 8-space tabs). Line breaking in that block of code\nmay be undesirable, so just disable clang-format there. I don't think\nthere's a consistent set of penalties you could establish that would\nhandle that well without mishandling some other section of code.\n\nIt's also not clear what the reason for the overshoot is in many cases.\n- difference between \"80 characters\" and \"80 columns\"?\n    - (1394 >80char lines in *.{h,c}, 4849 >80col lines in the same files)\n- intentional for readability?\n- refactorings pushed originally compliant lines out of compliance?\n- no one caught it and it was just added without any intentional decision?\n\n> So\n> let's reduce the value for 'PenaltyExcessCharacter' to 10. This means we\n> that we add a penalty of 10 for each character that exceeds the column\n> limit. By itself this is enough to restrict to column limit. Tuning\n> other penalties in relation to this is what is important.\n>\n> The penalty `PenaltyBreakAssignment` talks about the penalty for\n> breaking an assignment operator on to the next line. In our project, we\n> are okay with this, so giving a value of 5, which is below the value for\n> 'PenaltyExcessCharacter' ensures that in the end, even 1 character over\n> the column limit is not worth keeping an assignment on the same line.\n>\n> Similarly set the penalty for breaking before the first call parameter\n> 'PenaltyBreakBeforeFirstCallParameter' and the penalty for breaking\n> comments 'PenaltyBreakComment' and the penalty for breaking string\n> literals 'PenaltyBreakString' also to 5.\n>\n> Finally, we really care about not breaking the return type into its own\n> line and we really care about not breaking before an open parenthesis.\n> This avoids weird formatting like:\n>\n>    static const struct strbuf *\n>           a_really_really_large_function_name(struct strbuf resolved,\n>           const char *path, int flags)\n\nIs this how it'd be indented without the penalties, or would it do\nthis, with the function name indented the same amount as the return\ntype (which is, in C, probably going to be the 0th column most times):\n\nstatic const struct strbuf *\na_really_really_large_function_name(struct strbuf resolved,\n        const char *path, int flags)\n\n>\n> or\n>\n>    static const struct strbuf *a_really_really_large_function_name(\n>             struct strbuf resolved, const char *path, int flags)\n\nPersonal opinion: I prefer this over the version that has a single\nargument on the first line. My preference for reading functions is:\n\nreturn_type func_name(arg1, arg2,\n                      arg3, arg4,\n                      arg5, arg6, ...);\n\nOr\n\nreturn_type func_name(\n        arg1, arg2, arg3, arg4,\n        arg5, arg6, ...);\n\nor, in some cases, putting every argument on their own line (typically\nwhen the majority of the arguments are already on their own line, not\nhaving one \"hiding\" somewhere is preferable, but at this point if\nthat's not what my formatter does, I don't fight it).\n\nFor functions that accept an obvious first parameter, such as\n`strbuf_add`, maybe having the first parameter on the first line is\nacceptable/desirable, since it's \"obvious\" what it is/does. But for\nmany functions that's not the case, and needing to read the end of the\nfirst line, potentially beyond the 80th column, feels weird.\n\n>\n> to instead have something more readable like:\n>\n>    static const struct strbuf *a_really_really_large_function_name(struct strbuf resolved,\n>           const char *path, int flags)\n>\n> This is done by bumping the values of 'PenaltyReturnTypeOnItsOwnLine'\n> and 'PenaltyBreakOpenParenthesis' to 300. This is so that we can allow a\n> few characters above the 80 column limit to make code more readable.\n\nA few examples, such as by formatting the code using the current rules\n(since much of the codebase does not currently comply), and then\nchanging the penalties and seeing what changes, might be nice?\n\n\n>\n> Signed-off-by: Karthik Nayak <karthik.188@gmail.com>\n> ---\n>  .clang-format | 13 +++++++------\n>  1 file changed, 7 insertions(+), 6 deletions(-)\n>\n> diff --git a/.clang-format b/.clang-format\n> index 41969eca4b..66a2360ae5 100644\n> --- a/.clang-format\n> +++ b/.clang-format\n> @@ -209,13 +209,14 @@ KeepEmptyLinesAtTheStartOfBlocks: false\n>\n>  # Penalties\n>  # This decides what order things should be done if a line is too long\n> -PenaltyBreakAssignment: 10\n> -PenaltyBreakBeforeFirstCallParameter: 30\n> -PenaltyBreakComment: 10\n> +PenaltyBreakAssignment: 5\n> +PenaltyBreakBeforeFirstCallParameter: 5\n> +PenaltyBreakComment: 5\n>  PenaltyBreakFirstLessLess: 0\n> -PenaltyBreakString: 10\n> -PenaltyExcessCharacter: 100\n> -PenaltyReturnTypeOnItsOwnLine: 60\n> +PenaltyBreakOpenParenthesis: 300\n\nHow does this interact with PenaltyBreakBeforeFirstCallParameter? Does\none override the other?\n\n> +PenaltyBreakString: 5\n> +PenaltyExcessCharacter: 10\n> +PenaltyReturnTypeOnItsOwnLine: 300\n>\n>  # Don't sort #include's\n>  SortIncludes: false\n> --\n> 2.47.0\n>\n"},{"id":"505065","messageId":"CAO_smVhS8zw_Hk1OrsTg==4spziQOiQtOt+Hg8x-rEQVR+66rw@mail.gmail.com","threadId":"62294","inReplyTo":"1586d5376915a4662c92b8c0881596952c4500bb.1728697428.git.karthik.188@gmail.com","subject":"Re: [PATCH v3 2/3] clang-format: align consecutive macro definitions","fromName":"Kyle Lippincott","fromEmail":"spectral@google.com","sentAt":"2024-10-14T21:12:42Z","receivedAt":"2024-10-14T21:12:55Z","isPatch":true,"sender":{"key":"spectral@google.com","avatar":"https://avatars.githubusercontent.com/u/6371650?v=4"},"body":"On Fri, Oct 11, 2024 at 6:50 PM Karthik Nayak <karthik.188@gmail.com> wrote:\n>\n> We generally align consecutive macro definitions for better readability:\n>\n>   #define OUTPUT_ANNOTATE_COMPAT      (1U<<0)\n>   #define OUTPUT_LONG_OBJECT_NAME     (1U<<1)\n>   #define OUTPUT_RAW_TIMESTAMP        (1U<<2)\n>   #define OUTPUT_PORCELAIN            (1U<<3)\n\nI like this change, thanks. Is there a way of apply clang-format for\n*only* one rule/aspect? i.e. can we apply *only* this, and preserve\nevery other line? At first glance, I don't see a way of doing it. If\nthere was, I might recommend a whole series just to applying these\nchanges, but with how out of compliance much of the codebase is today,\nthat's not going to be feasible; we'd need to format it in a way that\nwe might not want (the current style), and then fix it, and that seems\ncounterproductive.\n\n>\n> over\n>\n>   #define OUTPUT_ANNOTATE_COMPAT (1U<<0)\n>   #define OUTPUT_LONG_OBJECT_NAME (1U<<1)\n>   #define OUTPUT_RAW_TIMESTAMP (1U<<2)\n>   #define OUTPUT_PORCELAIN (1U<<3)\n>\n> So let's add the rule in clang-format to follow this.\n>\n> Signed-off-by: Karthik Nayak <karthik.188@gmail.com>\n> ---\n>  .clang-format | 3 +++\n>  1 file changed, 3 insertions(+)\n>\n> diff --git a/.clang-format b/.clang-format\n> index 66a2360ae5..9547fe1b77 100644\n> --- a/.clang-format\n> +++ b/.clang-format\n> @@ -32,6 +32,9 @@ AlignConsecutiveAssignments: false\n>  # double b = 3.14;\n>  AlignConsecutiveDeclarations: false\n>\n> +# Align consecutive macro definitions.\n> +AlignConsecutiveMacros: true\n> +\n>  # Align escaped newlines as far left as possible\n>  # #define A   \\\n>  #   int aaaa; \\\n> --\n> 2.47.0\n>\n"},{"id":"505066","messageId":"Zw2Jq0cGPrRn6GAO@nand.local","threadId":"62294","inReplyTo":"871q0jrr02.fsf@iotcl.com","subject":"Re: [PATCH v3 1/3] clang-format: re-adjust line break penalties","fromName":"Taylor Blau","fromEmail":"me@ttaylorr.com","sentAt":"2024-10-14T21:14:19Z","receivedAt":"2024-10-14T21:14:22Z","isPatch":true,"sender":{"key":"me@ttaylorr.com","avatar":"https://avatars.githubusercontent.com/u/301000140?v=4"},"body":"On Mon, Oct 14, 2024 at 11:08:29AM +0200, Toon Claes wrote:\n> Karthik Nayak <karthik.188@gmail.com> writes:\n>\n> [snip]\n>\n> > This avoids weird formatting like:\n> >\n> >    static const struct strbuf *\n> >           a_really_really_large_function_name(struct strbuf resolved,\n> >           const char *path, int flags)\n> >\n> > or\n> >\n> >    static const struct strbuf *a_really_really_large_function_name(\n> >    \t    struct strbuf resolved, const char *path, int flags)\n> >\n> > to instead have something more readable like:\n> >\n> >    static const struct strbuf *a_really_really_large_function_name(struct strbuf resolved,\n> >           const char *path, int flags)\n> >\n> > This is done by bumping the values of 'PenaltyReturnTypeOnItsOwnLine'\n> > and 'PenaltyBreakOpenParenthesis' to 300. This is so that we can allow a\n> > few characters above the 80 column limit to make code more readable.\n>\n> I'm really liking the idea of penalties, but I feel we're relying too\n> much on guestimation of these values. What do you think about adding\n> example files to our codebase? Having concrete examples at hand will\n> allow us to tweak the values in the future, while preserving behavior\n> for existing cases. Or when we decide to change them, we understand\n> what and when.\n\nI am not sure I see it the same way.\n\nI might just be ill-informed or not experienced with these clang-format\nrules, but having these penalties be defined as such makes it difficult\nto reason about what lines will and won't be re-wrapped as a result of\nrunning the formatter.\n\nWhat is the purpose of these penalties?\n\nThanks,\nTaylor\n"},{"id":"505068","messageId":"CAO_smVg8aVjUFixKOicCJqQgAGhrbVPa9Q9Z8+OKKM+Thsx2oQ@mail.gmail.com","threadId":"62294","inReplyTo":"36a53299c1ab1b55a09b7e1d499832e6715ebaba.1728697428.git.karthik.188@gmail.com","subject":"Re: [PATCH v3 3/3] clang-format: don't align expressions after linebreaks","fromName":"Kyle Lippincott","fromEmail":"spectral@google.com","sentAt":"2024-10-14T21:23:21Z","receivedAt":"2024-10-14T21:23:34Z","isPatch":true,"sender":{"key":"spectral@google.com","avatar":"https://avatars.githubusercontent.com/u/6371650?v=4"},"body":"On Fri, Oct 11, 2024 at 6:50 PM Karthik Nayak <karthik.188@gmail.com> wrote:\n>\n> We enforce alignment of expressions after linebreaks. Which means for\n> code such as\n>\n>     return a || b;\n>\n> it will expect:\n>\n>    return a ||\n>           b;\n>\n> we instead want 'b' to be indent with tabs, which is already done by the\n> 'ContinuationIndentWidth' variable.\n\nWhy do we want `b` to be indented by 8 columns instead of aligned? I\nthink this is harder to read:\n\nint some_int_variable = aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa +\n        bbbbbbbbbbbbbbbbbbbbbbbbbbbbbb;\n\nOf course, this is even better, if it fits in 80 cols:\n\nint some_int_variable =\n        aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa + bbbbbbbbbbbbbbbbbbbbbbbbbbbbbb;\n\n> So let's explicitly set\n> 'AlignOperands' to false.\n>\n> Signed-off-by: Karthik Nayak <karthik.188@gmail.com>\n> ---\n>  .clang-format | 7 +++----\n>  1 file changed, 3 insertions(+), 4 deletions(-)\n>\n> diff --git a/.clang-format b/.clang-format\n> index 9547fe1b77..b48e7813e4 100644\n> --- a/.clang-format\n> +++ b/.clang-format\n> @@ -42,10 +42,9 @@ AlignConsecutiveMacros: true\n>  #   int cccccccc;\n>  AlignEscapedNewlines: Left\n>\n> -# Align operands of binary and ternary expressions\n> -# int aaa = bbbbbbbbbbb +\n> -#           cccccc;\n> -AlignOperands: true\n> +# Don't enforce alignment after linebreaks and instead\n> +# rely on the ContinuationIndentWidth value.\n> +AlignOperands: false\n>\n>  # Don't align trailing comments\n>  # int a; // Comment a\n> --\n> 2.47.0\n>\n"},{"id":"505124","messageId":"CAOLa=ZR5eR_WEiBhPGMc9pKX20HsamLy6hkfBrF2Kj8FnGRuGA@mail.gmail.com","threadId":"62294","inReplyTo":"CAO_smVhS8zw_Hk1OrsTg==4spziQOiQtOt+Hg8x-rEQVR+66rw@mail.gmail.com","subject":"Re: [PATCH v3 2/3] clang-format: align consecutive macro definitions","fromName":"karthik nayak","fromEmail":"karthik.188@gmail.com","sentAt":"2024-10-15T07:57:37Z","receivedAt":"2024-10-15T07:57:39Z","isPatch":true,"sender":{"key":"karthik.188@gmail.com","avatar":"https://avatars.githubusercontent.com/u/1786334?v=4"},"body":"Kyle Lippincott <spectral@google.com> writes:\n\n> On Fri, Oct 11, 2024 at 6:50 PM Karthik Nayak <karthik.188@gmail.com> wrote:\n>>\n>> We generally align consecutive macro definitions for better readability:\n>>\n>>   #define OUTPUT_ANNOTATE_COMPAT      (1U<<0)\n>>   #define OUTPUT_LONG_OBJECT_NAME     (1U<<1)\n>>   #define OUTPUT_RAW_TIMESTAMP        (1U<<2)\n>>   #define OUTPUT_PORCELAIN            (1U<<3)\n>\n> I like this change, thanks. Is there a way of apply clang-format for\n> *only* one rule/aspect? i.e. can we apply *only* this, and preserve\n> every other line? At first glance, I don't see a way of doing it. If\n> there was, I might recommend a whole series just to applying these\n> changes, but with how out of compliance much of the codebase is today,\n> that's not going to be feasible; we'd need to format it in a way that\n> we might not want (the current style), and then fix it, and that seems\n> counterproductive.\n>\n\nI think we can apply a single rule by specifying the rule over the CLI.\n\nOverall I think its best to take things iteratively. Also because\n'clang-format' is a bit rough around the edges and we might discover\nsome other changes needed.\n"},{"id":"505138","messageId":"CAOLa=ZRZGhcKTWMApyuAi1Ec2_4F+QEDzX_MEG6PT1NEbRVbdQ@mail.gmail.com","threadId":"62294","inReplyTo":"CAO_smVg8aVjUFixKOicCJqQgAGhrbVPa9Q9Z8+OKKM+Thsx2oQ@mail.gmail.com","subject":"Re: [PATCH v3 3/3] clang-format: don't align expressions after linebreaks","fromName":"karthik nayak","fromEmail":"karthik.188@gmail.com","sentAt":"2024-10-15T11:17:48Z","receivedAt":"2024-10-15T11:17:50Z","isPatch":true,"sender":{"key":"karthik.188@gmail.com","avatar":"https://avatars.githubusercontent.com/u/1786334?v=4"},"body":"Kyle Lippincott <spectral@google.com> writes:\n\n> On Fri, Oct 11, 2024 at 6:50 PM Karthik Nayak <karthik.188@gmail.com> wrote:\n>>\n>> We enforce alignment of expressions after linebreaks. Which means for\n>> code such as\n>>\n>>     return a || b;\n>>\n>> it will expect:\n>>\n>>    return a ||\n>>           b;\n>>\n>> we instead want 'b' to be indent with tabs, which is already done by the\n>> 'ContinuationIndentWidth' variable.\n>\n> Why do we want `b` to be indented by 8 columns instead of aligned? I\n> think this is harder to read:\n>\n> int some_int_variable = aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa +\n>         bbbbbbbbbbbbbbbbbbbbbbbbbbbbbb;\n>\n\nThe reason I added this is because by default editors will follow the\n'.editorconfig' and follow the 'tab_width = 8' rule when there is a line\nbreak.\n\nThis means more often than not, most patches don't follow this rule. We\ndon't enforce clang-format at this point so it makes more sense to align\nthe rule to what everyone is doing. The goal being that once we have a\ngood set of base rules with less false positives, we can start\nenforcing.\n\n> Of course, this is even better, if it fits in 80 cols:\n>\n> int some_int_variable =\n>         aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa + bbbbbbbbbbbbbbbbbbbbbbbbbbbbbb;\n>\n\nI'm sure we can tweak this with penalties ;) But I'd say this is\nsomething we can tune later.\n"},{"id":"505139","messageId":"CAOLa=ZRFqgXuJQCMphwSX0d_saT4zzv8VNdXNkT_RhkfSHVPEA@mail.gmail.com","threadId":"62294","inReplyTo":"871q0jrr02.fsf@iotcl.com","subject":"Re: [PATCH v3 1/3] clang-format: re-adjust line break penalties","fromName":"karthik nayak","fromEmail":"karthik.188@gmail.com","sentAt":"2024-10-15T11:20:19Z","receivedAt":"2024-10-15T11:20:22Z","isPatch":true,"sender":{"key":"karthik.188@gmail.com","avatar":"https://avatars.githubusercontent.com/u/1786334?v=4"},"body":"Toon Claes <toon@iotcl.com> writes:\n\n> Karthik Nayak <karthik.188@gmail.com> writes:\n>\n> [snip]\n>\n>> This avoids weird formatting like:\n>>\n>>    static const struct strbuf *\n>>           a_really_really_large_function_name(struct strbuf resolved,\n>>           const char *path, int flags)\n>>\n>> or\n>>\n>>    static const struct strbuf *a_really_really_large_function_name(\n>>    \t    struct strbuf resolved, const char *path, int flags)\n>>\n>> to instead have something more readable like:\n>>\n>>    static const struct strbuf *a_really_really_large_function_name(struct strbuf resolved,\n>>           const char *path, int flags)\n>>\n>> This is done by bumping the values of 'PenaltyReturnTypeOnItsOwnLine'\n>> and 'PenaltyBreakOpenParenthesis' to 300. This is so that we can allow a\n>> few characters above the 80 column limit to make code more readable.\n>\n> I'm really liking the idea of penalties, but I feel we're relying too\n> much on guestimation of these values. What do you think about adding\n\nThat is true indeed. There is a bit of guestimation done here, I had to\ntry various values to find the ones which worked well. I wish there was\na more formal way to do this...\n\n> example files to our codebase? Having concrete examples at hand will\n> allow us to tweak the values in the future, while preserving behavior\n> for existing cases. Or when we decide to change them, we understand\n> what and when.\n>\n> Now, I'm not sure where to put such files. I think I would suggest\n> something like t/style-lint or t/clang-format. Anyway, for our tooling\n> it doesn't seem to matter, because both `make style` and\n> `ci/run-style-check.sh` pick up all .c and .h files anywhere in the\n> source tree. Adding a README to that directory will help people\n> understand why the files are there.\n>\n\nI'm not too keen on adding examples, for the mere facts that:\n1. They will be outdated each time we change rules.\n2. The commit message already has the information around each rule.\n\nKarthik\n"},{"id":"505143","messageId":"CAOLa=ZRuEV1dyrn2N_O+W1DwSuHgHTghoauH4w6YX2HXi3UG4g@mail.gmail.com","threadId":"62294","inReplyTo":"Zw2Jq0cGPrRn6GAO@nand.local","subject":"Re: [PATCH v3 1/3] clang-format: re-adjust line break penalties","fromName":"karthik nayak","fromEmail":"karthik.188@gmail.com","sentAt":"2024-10-15T11:35:19Z","receivedAt":"2024-10-15T11:35:20Z","isPatch":true,"sender":{"key":"karthik.188@gmail.com","avatar":"https://avatars.githubusercontent.com/u/1786334?v=4"},"body":"Taylor Blau <me@ttaylorr.com> writes:\n\n> On Mon, Oct 14, 2024 at 11:08:29AM +0200, Toon Claes wrote:\n>> Karthik Nayak <karthik.188@gmail.com> writes:\n>>\n>> [snip]\n>>\n>> > This avoids weird formatting like:\n>> >\n>> >    static const struct strbuf *\n>> >           a_really_really_large_function_name(struct strbuf resolved,\n>> >           const char *path, int flags)\n>> >\n>> > or\n>> >\n>> >    static const struct strbuf *a_really_really_large_function_name(\n>> >    \t    struct strbuf resolved, const char *path, int flags)\n>> >\n>> > to instead have something more readable like:\n>> >\n>> >    static const struct strbuf *a_really_really_large_function_name(struct strbuf resolved,\n>> >           const char *path, int flags)\n>> >\n>> > This is done by bumping the values of 'PenaltyReturnTypeOnItsOwnLine'\n>> > and 'PenaltyBreakOpenParenthesis' to 300. This is so that we can allow a\n>> > few characters above the 80 column limit to make code more readable.\n>>\n>> I'm really liking the idea of penalties, but I feel we're relying too\n>> much on guestimation of these values. What do you think about adding\n>> example files to our codebase? Having concrete examples at hand will\n>> allow us to tweak the values in the future, while preserving behavior\n>> for existing cases. Or when we decide to change them, we understand\n>> what and when.\n>\n> I am not sure I see it the same way.\n>\n> I might just be ill-informed or not experienced with these clang-format\n> rules, but having these penalties be defined as such makes it difficult\n> to reason about what lines will and won't be re-wrapped as a result of\n> running the formatter.\n>\n> What is the purpose of these penalties?\n>\n\nWe have a column limit set in our clang-format 'ColumnLimit: 80', this\ndictates when line breaks should occur in our code.\n\nThe penalties are options through which we can influence this decision\n[1].\n\n> Thanks,\n> Taylor\n\n[1]: https://stackoverflow.com/a/27608250\n"},{"id":"505162","messageId":"CAOLa=ZT0qsG7cnnzwg7GDkBuTqZO_e+C5HwT5o9kWZ1Cto=0kg@mail.gmail.com","threadId":"62294","inReplyTo":"CAO_smViSU5KohOqVXp2L_cM3G-jrOGQY=J=qf=-GbiGsOYd9TQ@mail.gmail.com","subject":"Re: [PATCH v3 1/3] clang-format: re-adjust line break penalties","fromName":"karthik nayak","fromEmail":"karthik.188@gmail.com","sentAt":"2024-10-15T12:37:41Z","receivedAt":"2024-10-15T12:37:43Z","isPatch":true,"sender":{"key":"karthik.188@gmail.com","avatar":"https://avatars.githubusercontent.com/u/1786334?v=4"},"body":"Kyle Lippincott <spectral@google.com> writes:\n\n> On Fri, Oct 11, 2024 at 6:50 PM Karthik Nayak <karthik.188@gmail.com> wrote:\n>>\n>> In 42efde4c29 (clang-format: adjust line break penalties, 2017-09-29) we\n>> adjusted the line break penalties to really fine tune what we care about\n>> while doing line breaks. Modify some of those to be more inline with\n>> what we care about in the Git project now.\n>>\n>> We need to understand that the values set to penalties in\n>> '.clang-format' are relative to each other and do not hold any absolute\n>> value. The penalty arguments take an 'Unsigned' value, so we have some\n>> liberty over the values we can set.\n>>\n>> First, in that commit, we decided, that under no circumstances do we\n>> want to exceed 80 characters. This seems a bit too strict. We do\n>> overshoot this limit from time to time to prioritize readability.\n>\n> I think that attempting to get the weights right so as to avoid cases\n> where there was an intentional affordance for readability is going to\n> be essentially impossible. Areas where there's an intentional\n> disregard for the clang-format-generated formatting should disable the\n> formatter for that line/region, instead of trying to find a way to\n> adjust the rules to produce something that's going to end up being\n> context dependent.\n>\n\nTo some extent I agree. But the issue is that clang-format is still not\nenforced within the code base. So expecting users to add:\n    // clang-format off\nwill not hold, at least for _now_.\n\nSo the next best thing we can do is to get the format rules as close as\nwe can to the current styling, so the actual errors thrown by the CI job\nis something we can look at without containing too many false positives.\n\n> Example: In ref-filter.c, there's 13 lines when initializing the\n> `valid_atom` array that are >80 characters, and 20 lines that are >80\n> columns (when using 8-space tabs). Line breaking in that block of code\n> may be undesirable, so just disable clang-format there. I don't think\n> there's a consistent set of penalties you could establish that would\n> handle that well without mishandling some other section of code.\n\nWhile true, we can quantify if it is better or not:\n\n      ❯ ci/run-style-check.sh @~50 | wc -l\n      4718 (master)\n\n      ❯ ci/run-style-check.sh @~53 | wc -l\n      4475 (with these patches)\n\nAnd looking through the other changes, those look like violations which\nshould have been fixed.\n\n> It's also not clear what the reason for the overshoot is in many cases.\n> - difference between \"80 characters\" and \"80 columns\"?\n>     - (1394 >80char lines in *.{h,c}, 4849 >80col lines in the same files)\n> - intentional for readability?\n> - refactorings pushed originally compliant lines out of compliance?\n> - no one caught it and it was just added without any intentional decision?\n>\n\nI agree with your inference here, but I'm not sure there is a smooth way\nto have this information. Either we go full in and say we enable the\nformatting and every patch must conform to it, or we simply keep the\nclang-format as a warning system. Currently we do neither. I'd say we\nshould be in a state to reach the latter and then we can gradually think\nof how to move to the former.\n\n>> So\n>> let's reduce the value for 'PenaltyExcessCharacter' to 10. This means we\n>> that we add a penalty of 10 for each character that exceeds the column\n>> limit. By itself this is enough to restrict to column limit. Tuning\n>> other penalties in relation to this is what is important.\n>>\n>> The penalty `PenaltyBreakAssignment` talks about the penalty for\n>> breaking an assignment operator on to the next line. In our project, we\n>> are okay with this, so giving a value of 5, which is below the value for\n>> 'PenaltyExcessCharacter' ensures that in the end, even 1 character over\n>> the column limit is not worth keeping an assignment on the same line.\n>>\n>> Similarly set the penalty for breaking before the first call parameter\n>> 'PenaltyBreakBeforeFirstCallParameter' and the penalty for breaking\n>> comments 'PenaltyBreakComment' and the penalty for breaking string\n>> literals 'PenaltyBreakString' also to 5.\n>>\n>> Finally, we really care about not breaking the return type into its own\n>> line and we really care about not breaking before an open parenthesis.\n>> This avoids weird formatting like:\n>>\n>>    static const struct strbuf *\n>>           a_really_really_large_function_name(struct strbuf resolved,\n>>           const char *path, int flags)\n>\n> Is this how it'd be indented without the penalties, or would it do\n> this, with the function name indented the same amount as the return\n> type (which is, in C, probably going to be the 0th column most times):\n>\n> static const struct strbuf *\n> a_really_really_large_function_name(struct strbuf resolved,\n>         const char *path, int flags)\n>\n\nIt will be indented, so not the 0th column.\n\n>>\n>> or\n>>\n>>    static const struct strbuf *a_really_really_large_function_name(\n>>             struct strbuf resolved, const char *path, int flags)\n>\n> Personal opinion: I prefer this over the version that has a single\n> argument on the first line. My preference for reading functions is:\n>\n> return_type func_name(arg1, arg2,\n>                       arg3, arg4,\n>                       arg5, arg6, ...);\n>\n> Or\n>\n> return_type func_name(\n>         arg1, arg2, arg3, arg4,\n>         arg5, arg6, ...);\n>\n\nI'm mostly basing my changes on the current state of the 'clang-format'\nand our code base. I'm happy to change it if everyone agrees on this :)\n\n> or, in some cases, putting every argument on their own line (typically\n> when the majority of the arguments are already on their own line, not\n> having one \"hiding\" somewhere is preferable, but at this point if\n> that's not what my formatter does, I don't fight it).\n>\n> For functions that accept an obvious first parameter, such as\n> `strbuf_add`, maybe having the first parameter on the first line is\n> acceptable/desirable, since it's \"obvious\" what it is/does. But for\n> many functions that's not the case, and needing to read the end of the\n> first line, potentially beyond the 80th column, feels weird.\n>\n>>\n>> to instead have something more readable like:\n>>\n>>    static const struct strbuf *a_really_really_large_function_name(struct strbuf resolved,\n>>           const char *path, int flags)\n>>\n>> This is done by bumping the values of 'PenaltyReturnTypeOnItsOwnLine'\n>> and 'PenaltyBreakOpenParenthesis' to 300. This is so that we can allow a\n>> few characters above the 80 column limit to make code more readable.\n>\n> A few examples, such as by formatting the code using the current rules\n> (since much of the codebase does not currently comply), and then\n> changing the penalties and seeing what changes, might be nice?\n>\n\nYou mean apart from the example above?\n\n>\n>>\n>> Signed-off-by: Karthik Nayak <karthik.188@gmail.com>\n>> ---\n>>  .clang-format | 13 +++++++------\n>>  1 file changed, 7 insertions(+), 6 deletions(-)\n>>\n>> diff --git a/.clang-format b/.clang-format\n>> index 41969eca4b..66a2360ae5 100644\n>> --- a/.clang-format\n>> +++ b/.clang-format\n>> @@ -209,13 +209,14 @@ KeepEmptyLinesAtTheStartOfBlocks: false\n>>\n>>  # Penalties\n>>  # This decides what order things should be done if a line is too long\n>> -PenaltyBreakAssignment: 10\n>> -PenaltyBreakBeforeFirstCallParameter: 30\n>> -PenaltyBreakComment: 10\n>> +PenaltyBreakAssignment: 5\n>> +PenaltyBreakBeforeFirstCallParameter: 5\n>> +PenaltyBreakComment: 5\n>>  PenaltyBreakFirstLessLess: 0\n>> -PenaltyBreakString: 10\n>> -PenaltyExcessCharacter: 100\n>> -PenaltyReturnTypeOnItsOwnLine: 60\n>> +PenaltyBreakOpenParenthesis: 300\n>\n> How does this interact with PenaltyBreakBeforeFirstCallParameter? Does\n> one override the other?\n>\n\nFrom my understanding PenaltyBreakOpenParenthesis seems to apply more\ngenerally and is the more preferred value.\n\n[1]: https://github.com/llvm/llvm-project/blob/a4367d2d136420f562f64e7731b9393fb609f3fc/clang/lib/Format/TokenAnnotator.cpp#L4322\n\n>> +PenaltyBreakString: 5\n>> +PenaltyExcessCharacter: 10\n>> +PenaltyReturnTypeOnItsOwnLine: 300\n>>\n>>  # Don't sort #include's\n>>  SortIncludes: false\n>> --\n>> 2.47.0\n>>\n"},{"id":"505223","messageId":"CAO_smVjXkpaJOKyvg_mVqxpoK5C=kVpcfGWEH5qC4vfQS=rTgg@mail.gmail.com","threadId":"62294","inReplyTo":"CAOLa=ZT0qsG7cnnzwg7GDkBuTqZO_e+C5HwT5o9kWZ1Cto=0kg@mail.gmail.com","subject":"Re: [PATCH v3 1/3] clang-format: re-adjust line break penalties","fromName":"Kyle Lippincott","fromEmail":"spectral@google.com","sentAt":"2024-10-16T01:38:17Z","receivedAt":"2024-10-16T01:38:34Z","isPatch":true,"sender":{"key":"spectral@google.com","avatar":"https://avatars.githubusercontent.com/u/6371650?v=4"},"body":"On Tue, Oct 15, 2024 at 5:37 AM karthik nayak <karthik.188@gmail.com> wrote:\n>\n> Kyle Lippincott <spectral@google.com> writes:\n>\n> > On Fri, Oct 11, 2024 at 6:50 PM Karthik Nayak <karthik.188@gmail.com> wrote:\n> >>\n> >> In 42efde4c29 (clang-format: adjust line break penalties, 2017-09-29) we\n> >> adjusted the line break penalties to really fine tune what we care about\n> >> while doing line breaks. Modify some of those to be more inline with\n> >> what we care about in the Git project now.\n> >>\n> >> We need to understand that the values set to penalties in\n> >> '.clang-format' are relative to each other and do not hold any absolute\n> >> value. The penalty arguments take an 'Unsigned' value, so we have some\n> >> liberty over the values we can set.\n> >>\n> >> First, in that commit, we decided, that under no circumstances do we\n> >> want to exceed 80 characters. This seems a bit too strict. We do\n> >> overshoot this limit from time to time to prioritize readability.\n> >\n> > I think that attempting to get the weights right so as to avoid cases\n> > where there was an intentional affordance for readability is going to\n> > be essentially impossible. Areas where there's an intentional\n> > disregard for the clang-format-generated formatting should disable the\n> > formatter for that line/region, instead of trying to find a way to\n> > adjust the rules to produce something that's going to end up being\n> > context dependent.\n> >\n>\n> To some extent I agree. But the issue is that clang-format is still not\n> enforced within the code base. So expecting users to add:\n>     // clang-format off\n> will not hold, at least for _now_.\n>\n> So the next best thing we can do is to get the format rules as close as\n> we can to the current styling, so the actual errors thrown by the CI job\n> is something we can look at without containing too many false positives.\n>\n> > Example: In ref-filter.c, there's 13 lines when initializing the\n> > `valid_atom` array that are >80 characters, and 20 lines that are >80\n> > columns (when using 8-space tabs). Line breaking in that block of code\n> > may be undesirable, so just disable clang-format there. I don't think\n> > there's a consistent set of penalties you could establish that would\n> > handle that well without mishandling some other section of code.\n>\n> While true, we can quantify if it is better or not:\n>\n>       ❯ ci/run-style-check.sh @~50 | wc -l\n>       4718 (master)\n>\n>       ❯ ci/run-style-check.sh @~53 | wc -l\n>       4475 (with these patches)\n>\n> And looking through the other changes, those look like violations which\n> should have been fixed.\n>\n> > It's also not clear what the reason for the overshoot is in many cases.\n> > - difference between \"80 characters\" and \"80 columns\"?\n> >     - (1394 >80char lines in *.{h,c}, 4849 >80col lines in the same files)\n> > - intentional for readability?\n> > - refactorings pushed originally compliant lines out of compliance?\n> > - no one caught it and it was just added without any intentional decision?\n> >\n>\n> I agree with your inference here, but I'm not sure there is a smooth way\n> to have this information. Either we go full in and say we enable the\n> formatting and every patch must conform to it, or we simply keep the\n> clang-format as a warning system. Currently we do neither. I'd say we\n> should be in a state to reach the latter and then we can gradually think\n> of how to move to the former.\n>\n> >> So\n> >> let's reduce the value for 'PenaltyExcessCharacter' to 10. This means we\n> >> that we add a penalty of 10 for each character that exceeds the column\n> >> limit. By itself this is enough to restrict to column limit. Tuning\n> >> other penalties in relation to this is what is important.\n> >>\n> >> The penalty `PenaltyBreakAssignment` talks about the penalty for\n> >> breaking an assignment operator on to the next line. In our project, we\n> >> are okay with this, so giving a value of 5, which is below the value for\n> >> 'PenaltyExcessCharacter' ensures that in the end, even 1 character over\n> >> the column limit is not worth keeping an assignment on the same line.\n> >>\n> >> Similarly set the penalty for breaking before the first call parameter\n> >> 'PenaltyBreakBeforeFirstCallParameter' and the penalty for breaking\n> >> comments 'PenaltyBreakComment' and the penalty for breaking string\n> >> literals 'PenaltyBreakString' also to 5.\n> >>\n> >> Finally, we really care about not breaking the return type into its own\n> >> line and we really care about not breaking before an open parenthesis.\n> >> This avoids weird formatting like:\n> >>\n> >>    static const struct strbuf *\n> >>           a_really_really_large_function_name(struct strbuf resolved,\n> >>           const char *path, int flags)\n> >\n> > Is this how it'd be indented without the penalties, or would it do\n> > this, with the function name indented the same amount as the return\n> > type (which is, in C, probably going to be the 0th column most times):\n> >\n> > static const struct strbuf *\n> > a_really_really_large_function_name(struct strbuf resolved,\n> >         const char *path, int flags)\n> >\n>\n> It will be indented, so not the 0th column.\n\nI'm not getting that behavior when I try it. Is this only indented\nwith your updated penalties?\n\nCurrently on ef8ce8f3d4344fd3af049c17eeba5cd20d98b69f, git status is\nclean, added this line (no line breaks, just in case my email client\nmakes a mess of this) to top of path.h (chosen arbitrarily):\n\nstatic const struct strbuf *a_really_really_large_function_name(struct\nstrbuf resolved, const char *path, int flags);\n\nand ran `clang-format path.h | head -n20` and got this (where `int\nflags` is indented to align with the opening `(`, but tabs cause\nproblems yet again):\n\nstatic const struct strbuf *\na_really_really_large_function_name(struct strbuf resolved, const char *path,\n    int flags);\n\n`clang-format --version` shows it's a google-internal build, but it\nstill respects the .clang-format file, so this shouldn't matter? I'm\nassuming it's a relatively recent (within the past 1 month) commit\nthat it's based off of.\n\n>\n> >>\n> >> or\n> >>\n> >>    static const struct strbuf *a_really_really_large_function_name(\n> >>             struct strbuf resolved, const char *path, int flags)\n> >\n> > Personal opinion: I prefer this over the version that has a single\n> > argument on the first line. My preference for reading functions is:\n> >\n> > return_type func_name(arg1, arg2,\n> >                       arg3, arg4,\n> >                       arg5, arg6, ...);\n> >\n> > Or\n> >\n> > return_type func_name(\n> >         arg1, arg2, arg3, arg4,\n> >         arg5, arg6, ...);\n> >\n>\n> I'm mostly basing my changes on the current state of the 'clang-format'\n> and our code base. I'm happy to change it if everyone agrees on this :)\n\nI'm wondering if tabs have caused some confusion here... [thought\ncontinued below]\n\n>\n> > or, in some cases, putting every argument on their own line (typically\n> > when the majority of the arguments are already on their own line, not\n> > having one \"hiding\" somewhere is preferable, but at this point if\n> > that's not what my formatter does, I don't fight it).\n> >\n> > For functions that accept an obvious first parameter, such as\n> > `strbuf_add`, maybe having the first parameter on the first line is\n> > acceptable/desirable, since it's \"obvious\" what it is/does. But for\n> > many functions that's not the case, and needing to read the end of the\n> > first line, potentially beyond the 80th column, feels weird.\n> >\n> >>\n> >> to instead have something more readable like:\n> >>\n> >>    static const struct strbuf *a_really_really_large_function_name(struct strbuf resolved,\n> >>           const char *path, int flags)\n\nDoes this have `const char *path` aligned with the opening `(`? if so,\nthen that matches my first example and I'm fine with it. If this is\ntruly \"first argument immediately after (, other arguments indented\none indentation level\", then my original comment stands: I don't find\nthis readable at all, and I don't see evidence of this being an\nacceptable format according to our CodingGuidelines document.\n\nI also don't understand how the penalties would produce t\n\n\n> >>\n> >> This is done by bumping the values of 'PenaltyReturnTypeOnItsOwnLine'\n> >> and 'PenaltyBreakOpenParenthesis' to 300. This is so that we can allow a\n> >> few characters above the 80 column limit to make code more readable.\n> >\n> > A few examples, such as by formatting the code using the current rules\n> > (since much of the codebase does not currently comply), and then\n> > changing the penalties and seeing what changes, might be nice?\n> >\n>\n> You mean apart from the example above?\n\nThe example above is hypothetical, but I think I was thinking about\nthis incorrectly. Our existing codebase isn't formatted with\nclang-format, and formatting it first and then adjusting the penalties\ndoesn't really provide much useful information.\n\nSetting the penalties as you have them in this patch, and running it\non a copy of the line you have there, produces this for me:\n\nstatic const struct strbuf *\na_really_really_large_function_name(struct strbuf resolved, const char *path,\n                                    int flags);\n\nThe 80 column limit is still _strictly_ adhered to, it won't even go\nover by 1 character:\n\nstatic const struct strbuf *\na_really_really_large_function_named_Ed(struct strbuf resolved,\n                                        const char *path, int flags);\n\n(note: switched tabs to spaces because tabs are difficult to use\nduring discussions like this)\n\nSpecifically:\n- 80 column hard limit applied\n- return type on its own line\n- continuation arguments are aligned on the next line (which is\nexpected since we have AlignAfterOpenBracket set).\n\n>\n> >\n> >>\n> >> Signed-off-by: Karthik Nayak <karthik.188@gmail.com>\n> >> ---\n> >>  .clang-format | 13 +++++++------\n> >>  1 file changed, 7 insertions(+), 6 deletions(-)\n> >>\n> >> diff --git a/.clang-format b/.clang-format\n> >> index 41969eca4b..66a2360ae5 100644\n> >> --- a/.clang-format\n> >> +++ b/.clang-format\n> >> @@ -209,13 +209,14 @@ KeepEmptyLinesAtTheStartOfBlocks: false\n> >>\n> >>  # Penalties\n> >>  # This decides what order things should be done if a line is too long\n> >> -PenaltyBreakAssignment: 10\n> >> -PenaltyBreakBeforeFirstCallParameter: 30\n> >> -PenaltyBreakComment: 10\n> >> +PenaltyBreakAssignment: 5\n> >> +PenaltyBreakBeforeFirstCallParameter: 5\n> >> +PenaltyBreakComment: 5\n> >>  PenaltyBreakFirstLessLess: 0\n> >> -PenaltyBreakString: 10\n> >> -PenaltyExcessCharacter: 100\n> >> -PenaltyReturnTypeOnItsOwnLine: 60\n> >> +PenaltyBreakOpenParenthesis: 300\n> >\n> > How does this interact with PenaltyBreakBeforeFirstCallParameter? Does\n> > one override the other?\n> >\n>\n> From my understanding PenaltyBreakOpenParenthesis seems to apply more\n> generally and is the more preferred value.\n>\n> [1]: https://github.com/llvm/llvm-project/blob/a4367d2d136420f562f64e7731b9393fb609f3fc/clang/lib/Format/TokenAnnotator.cpp#L4322\n>\n> >> +PenaltyBreakString: 5\n> >> +PenaltyExcessCharacter: 10\n> >> +PenaltyReturnTypeOnItsOwnLine: 300\n> >>\n> >>  # Don't sort #include's\n> >>  SortIncludes: false\n> >> --\n> >> 2.47.0\n> >>\n"},{"id":"505313","messageId":"CAOLa=ZT-XiadQoUsvhrQO1ts-S9RQMUUyxzbR3Dd2reFQkU8yw@mail.gmail.com","threadId":"62294","inReplyTo":"CAO_smVjXkpaJOKyvg_mVqxpoK5C=kVpcfGWEH5qC4vfQS=rTgg@mail.gmail.com","subject":"Re: [PATCH v3 1/3] clang-format: re-adjust line break penalties","fromName":"karthik nayak","fromEmail":"karthik.188@gmail.com","sentAt":"2024-10-16T21:17:04Z","receivedAt":"2024-10-16T21:17:07Z","isPatch":true,"sender":{"key":"karthik.188@gmail.com","avatar":"https://avatars.githubusercontent.com/u/1786334?v=4"},"body":"Kyle Lippincott <spectral@google.com> writes:\n\n> On Tue, Oct 15, 2024 at 5:37 AM karthik nayak <karthik.188@gmail.com> wrote:\n>>\n>> Kyle Lippincott <spectral@google.com> writes:\n>>\n>> > On Fri, Oct 11, 2024 at 6:50 PM Karthik Nayak <karthik.188@gmail.com> wrote:\n>> >>\n>> >> In 42efde4c29 (clang-format: adjust line break penalties, 2017-09-29) we\n>> >> adjusted the line break penalties to really fine tune what we care about\n>> >> while doing line breaks. Modify some of those to be more inline with\n>> >> what we care about in the Git project now.\n>> >>\n>> >> We need to understand that the values set to penalties in\n>> >> '.clang-format' are relative to each other and do not hold any absolute\n>> >> value. The penalty arguments take an 'Unsigned' value, so we have some\n>> >> liberty over the values we can set.\n>> >>\n>> >> First, in that commit, we decided, that under no circumstances do we\n>> >> want to exceed 80 characters. This seems a bit too strict. We do\n>> >> overshoot this limit from time to time to prioritize readability.\n>> >\n>> > I think that attempting to get the weights right so as to avoid cases\n>> > where there was an intentional affordance for readability is going to\n>> > be essentially impossible. Areas where there's an intentional\n>> > disregard for the clang-format-generated formatting should disable the\n>> > formatter for that line/region, instead of trying to find a way to\n>> > adjust the rules to produce something that's going to end up being\n>> > context dependent.\n>> >\n>>\n>> To some extent I agree. But the issue is that clang-format is still not\n>> enforced within the code base. So expecting users to add:\n>>     // clang-format off\n>> will not hold, at least for _now_.\n>>\n>> So the next best thing we can do is to get the format rules as close as\n>> we can to the current styling, so the actual errors thrown by the CI job\n>> is something we can look at without containing too many false positives.\n>>\n>> > Example: In ref-filter.c, there's 13 lines when initializing the\n>> > `valid_atom` array that are >80 characters, and 20 lines that are >80\n>> > columns (when using 8-space tabs). Line breaking in that block of code\n>> > may be undesirable, so just disable clang-format there. I don't think\n>> > there's a consistent set of penalties you could establish that would\n>> > handle that well without mishandling some other section of code.\n>>\n>> While true, we can quantify if it is better or not:\n>>\n>>       ❯ ci/run-style-check.sh @~50 | wc -l\n>>       4718 (master)\n>>\n>>       ❯ ci/run-style-check.sh @~53 | wc -l\n>>       4475 (with these patches)\n>>\n>> And looking through the other changes, those look like violations which\n>> should have been fixed.\n>>\n>> > It's also not clear what the reason for the overshoot is in many cases.\n>> > - difference between \"80 characters\" and \"80 columns\"?\n>> >     - (1394 >80char lines in *.{h,c}, 4849 >80col lines in the same files)\n>> > - intentional for readability?\n>> > - refactorings pushed originally compliant lines out of compliance?\n>> > - no one caught it and it was just added without any intentional decision?\n>> >\n>>\n>> I agree with your inference here, but I'm not sure there is a smooth way\n>> to have this information. Either we go full in and say we enable the\n>> formatting and every patch must conform to it, or we simply keep the\n>> clang-format as a warning system. Currently we do neither. I'd say we\n>> should be in a state to reach the latter and then we can gradually think\n>> of how to move to the former.\n>>\n>> >> So\n>> >> let's reduce the value for 'PenaltyExcessCharacter' to 10. This means we\n>> >> that we add a penalty of 10 for each character that exceeds the column\n>> >> limit. By itself this is enough to restrict to column limit. Tuning\n>> >> other penalties in relation to this is what is important.\n>> >>\n>> >> The penalty `PenaltyBreakAssignment` talks about the penalty for\n>> >> breaking an assignment operator on to the next line. In our project, we\n>> >> are okay with this, so giving a value of 5, which is below the value for\n>> >> 'PenaltyExcessCharacter' ensures that in the end, even 1 character over\n>> >> the column limit is not worth keeping an assignment on the same line.\n>> >>\n>> >> Similarly set the penalty for breaking before the first call parameter\n>> >> 'PenaltyBreakBeforeFirstCallParameter' and the penalty for breaking\n>> >> comments 'PenaltyBreakComment' and the penalty for breaking string\n>> >> literals 'PenaltyBreakString' also to 5.\n>> >>\n>> >> Finally, we really care about not breaking the return type into its own\n>> >> line and we really care about not breaking before an open parenthesis.\n>> >> This avoids weird formatting like:\n>> >>\n>> >>    static const struct strbuf *\n>> >>           a_really_really_large_function_name(struct strbuf resolved,\n>> >>           const char *path, int flags)\n>> >\n>> > Is this how it'd be indented without the penalties, or would it do\n>> > this, with the function name indented the same amount as the return\n>> > type (which is, in C, probably going to be the 0th column most times):\n>> >\n>> > static const struct strbuf *\n>> > a_really_really_large_function_name(struct strbuf resolved,\n>> >         const char *path, int flags)\n>> >\n>>\n>> It will be indented, so not the 0th column.\n>\n> I'm not getting that behavior when I try it. Is this only indented\n> with your updated penalties?\n>\n> Currently on ef8ce8f3d4344fd3af049c17eeba5cd20d98b69f, git status is\n> clean, added this line (no line breaks, just in case my email client\n> makes a mess of this) to top of path.h (chosen arbitrarily):\n>\n> static const struct strbuf *a_really_really_large_function_name(struct\n> strbuf resolved, const char *path, int flags);\n>\n> and ran `clang-format path.h | head -n20` and got this (where `int\n> flags` is indented to align with the opening `(`, but tabs cause\n> problems yet again):\n>\n> static const struct strbuf *\n> a_really_really_large_function_name(struct strbuf resolved, const char *path,\n>     int flags);\n>\n> `clang-format --version` shows it's a google-internal build, but it\n> still respects the .clang-format file, so this shouldn't matter? I'm\n> assuming it's a relatively recent (within the past 1 month) commit\n> that it's based off of.\n>\n\nYou're absolutely right, this is also what I get. Sorry for the\nconfusion, but I assumed you were talking about the third line, i.e.\n`const char *path, int flags)`.\n\nI also ran it on the CI to make it easier on the eyes (specifically with\nthe tabs): [1]\n\n>>\n>> >>\n>> >> or\n>> >>\n>> >>    static const struct strbuf *a_really_really_large_function_name(\n>> >>             struct strbuf resolved, const char *path, int flags)\n>> >\n>> > Personal opinion: I prefer this over the version that has a single\n>> > argument on the first line. My preference for reading functions is:\n>> >\n>> > return_type func_name(arg1, arg2,\n>> >                       arg3, arg4,\n>> >                       arg5, arg6, ...);\n>> >\n>> > Or\n>> >\n>> > return_type func_name(\n>> >         arg1, arg2, arg3, arg4,\n>> >         arg5, arg6, ...);\n>> >\n>>\n>> I'm mostly basing my changes on the current state of the 'clang-format'\n>> and our code base. I'm happy to change it if everyone agrees on this :)\n>\n> I'm wondering if tabs have caused some confusion here... [thought\n> continued below]\n>\n>>\n>> > or, in some cases, putting every argument on their own line (typically\n>> > when the majority of the arguments are already on their own line, not\n>> > having one \"hiding\" somewhere is preferable, but at this point if\n>> > that's not what my formatter does, I don't fight it).\n>> >\n>> > For functions that accept an obvious first parameter, such as\n>> > `strbuf_add`, maybe having the first parameter on the first line is\n>> > acceptable/desirable, since it's \"obvious\" what it is/does. But for\n>> > many functions that's not the case, and needing to read the end of the\n>> > first line, potentially beyond the 80th column, feels weird.\n>> >\n>> >>\n>> >> to instead have something more readable like:\n>> >>\n>> >>    static const struct strbuf *a_really_really_large_function_name(struct strbuf resolved,\n>> >>           const char *path, int flags)\n>\n> Does this have `const char *path` aligned with the opening `(`? if so,\n> then that matches my first example and I'm fine with it.\n\nYes, it is. Here is a CI job to demonstrate. I hope this makes it\nclearer: [2]\n\n\n> If this is\n> truly \"first argument immediately after (, other arguments indented\n> one indentation level\", then my original comment stands: I don't find\n> this readable at all, and I don't see evidence of this being an\n> acceptable format according to our CodingGuidelines document.\n>\n> I also don't understand how the penalties would produce t\n>\n\nThe penalties define when the linebreak should happen. The alignment is\nhandled by the `AlignAfterOpenBracket: Align` rule we have in\n'.clang-format'.\n\n>> >>\n>> >> This is done by bumping the values of 'PenaltyReturnTypeOnItsOwnLine'\n>> >> and 'PenaltyBreakOpenParenthesis' to 300. This is so that we can allow a\n>> >> few characters above the 80 column limit to make code more readable.\n>> >\n>> > A few examples, such as by formatting the code using the current rules\n>> > (since much of the codebase does not currently comply), and then\n>> > changing the penalties and seeing what changes, might be nice?\n>> >\n>>\n>> You mean apart from the example above?\n>\n> The example above is hypothetical, but I think I was thinking about\n> this incorrectly. Our existing codebase isn't formatted with\n> clang-format, and formatting it first and then adjusting the penalties\n> doesn't really provide much useful information.\n>\n> Setting the penalties as you have them in this patch, and running it\n> on a copy of the line you have there, produces this for me:\n>\n> static const struct strbuf *\n> a_really_really_large_function_name(struct strbuf resolved, const char *path,\n>                                     int flags);\n>\n> The 80 column limit is still _strictly_ adhered to, it won't even go\n> over by 1 character:\n>\n> static const struct strbuf *\n> a_really_really_large_function_named_Ed(struct strbuf resolved,\n>                                         const char *path, int flags);\n>\n> (note: switched tabs to spaces because tabs are difficult to use\n> during discussions like this)\n>\n> Specifically:\n> - 80 column hard limit applied\n> - return type on its own line\n> - continuation arguments are aligned on the next line (which is\n> expected since we have AlignAfterOpenBracket set).\n>\n\nBut this is not what I'm seeing though, even the CI [2] confirms that.\nI'm seeing\n\nstatic const struct strbuf *a_really_really_large_function_name(struct\nstrbuf resolved,\n                                                                const\nchar *path,\n                                                                int flags);\n\nwhere the consecutive lines are aligned on '('.\n\n(note: switched tabs to spaces too)\n\nThanks for the back and forth though, I guess I have some feedback for\nthe next version:\n- Add some examples in a file like Toon suggested, showing how the\nclang-format would work.\n- Clarify the commit message to make it clearer about how the penalties\nwork with other rules.\n\n[snip]\n\n[1]: https://gitlab.com/gitlab-org/git/-/jobs/8105793089\n[2]: https://gitlab.com/gitlab-org/git/-/jobs/8105737945\n"},{"id":"505414","messageId":"cover.1729241030.git.karthik.188@gmail.com","threadId":"62294","inReplyTo":"CAOLa=ZRvFBhageS65uE5enzLBz7H_CAvvnEcPsi_QAi0exRx2w@mail.gmail.com","subject":"[PATCH v4 0/2] Subject: clang-format: fix rules to make the CI job cleaner","fromName":"Karthik Nayak","fromEmail":"karthik.188@gmail.com","sentAt":"2024-10-18T08:46:44Z","receivedAt":"2024-10-18T08:46:50Z","isPatch":true,"sender":{"key":"karthik.188@gmail.com","avatar":"https://avatars.githubusercontent.com/u/1786334?v=4"},"body":"The clang-format CI job is currently cluttered due to too many errors being\nreported. See some of the examples here:\n\n* https://gitlab.com/gitlab-org/git/-/jobs/7854601948\n* https://gitlab.com/gitlab-org/git/-/jobs/7843131109\n\nSo modify the clang-format with the following changes:\n1. Modify the penalties for linebreaks to be more considerate towards\nreadability. The commit goes into detail explaining how/why.  \n2. Align the macro definitions. This is something we follow to keep the macros\nreadable. \n\nI will still keep monitoring the jobs from time to time to ensure we can fine\ntune more as needed, if someone see's something odd, do keep me in the loop.\n\nThanks\n\nChanges over the previous version:\n1. I made the example in the first commit message a bit clearer so it is easier\nto understand.\n2. Removed the third commit, since I was convinced that it is good as-is for now. \n\nKarthik Nayak (2):\n  clang-format: re-adjust line break penalties\n  clang-format: align consecutive macro definitions\n\n .clang-format | 16 ++++++++++------\n 1 file changed, 10 insertions(+), 6 deletions(-)\n\nRange-diff against v3:\n1:  74bbd2f9db ! 1:  a8c8df5d95 clang-format: re-adjust line break penalties\n    @@ Commit message\n         to instead have something more readable like:\n     \n            static const struct strbuf *a_really_really_large_function_name(struct strbuf resolved,\n    -              const char *path, int flags)\n    +                                                                       const char *path,\n    +                                                                       int flags)\n    +\n    +    (note: the tabs here have been replaced by spaces for easier reading)\n     \n         This is done by bumping the values of 'PenaltyReturnTypeOnItsOwnLine'\n         and 'PenaltyBreakOpenParenthesis' to 300. This is so that we can allow a\n2:  1586d53769 = 2:  fcf965ac74 clang-format: align consecutive macro definitions\n3:  36a53299c1 < -:  ---------- clang-format: don't align expressions after linebreaks\n-- \n2.47.0\n\n"},{"id":"505415","messageId":"a8c8df5d95b0defec672ee139acd366219ea3302.1729241030.git.karthik.188@gmail.com","threadId":"62294","inReplyTo":"cover.1729241030.git.karthik.188@gmail.com","subject":"[PATCH v4 1/2] clang-format: re-adjust line break penalties","fromName":"Karthik Nayak","fromEmail":"karthik.188@gmail.com","sentAt":"2024-10-18T08:46:45Z","receivedAt":"2024-10-18T08:46:51Z","isPatch":true,"sender":{"key":"karthik.188@gmail.com","avatar":"https://avatars.githubusercontent.com/u/1786334?v=4"},"body":"In 42efde4c29 (clang-format: adjust line break penalties, 2017-09-29) we\nadjusted the line break penalties to really fine tune what we care about\nwhile doing line breaks. Modify some of those to be more inline with\nwhat we care about in the Git project now.\n\nWe need to understand that the values set to penalties in\n'.clang-format' are relative to each other and do not hold any absolute\nvalue. The penalty arguments take an 'Unsigned' value, so we have some\nliberty over the values we can set.\n\nFirst, in that commit, we decided, that under no circumstances do we\nwant to exceed 80 characters. This seems a bit too strict. We do\novershoot this limit from time to time to prioritize readability. So\nlet's reduce the value for 'PenaltyExcessCharacter' to 10. This means we\nthat we add a penalty of 10 for each character that exceeds the column\nlimit. By itself this is enough to restrict to column limit. Tuning\nother penalties in relation to this is what is important.\n\nThe penalty `PenaltyBreakAssignment` talks about the penalty for\nbreaking an assignment operator on to the next line. In our project, we\nare okay with this, so giving a value of 5, which is below the value for\n'PenaltyExcessCharacter' ensures that in the end, even 1 character over\nthe column limit is not worth keeping an assignment on the same line.\n\nSimilarly set the penalty for breaking before the first call parameter\n'PenaltyBreakBeforeFirstCallParameter' and the penalty for breaking\ncomments 'PenaltyBreakComment' and the penalty for breaking string\nliterals 'PenaltyBreakString' also to 5.\n\nFinally, we really care about not breaking the return type into its own\nline and we really care about not breaking before an open parenthesis.\nThis avoids weird formatting like:\n\n   static const struct strbuf *\n          a_really_really_large_function_name(struct strbuf resolved,\n          const char *path, int flags)\n\nor\n\n   static const struct strbuf *a_really_really_large_function_name(\n   \t    struct strbuf resolved, const char *path, int flags)\n\nto instead have something more readable like:\n\n   static const struct strbuf *a_really_really_large_function_name(struct strbuf resolved,\n                                                                   const char *path,\n                                                                   int flags)\n\n(note: the tabs here have been replaced by spaces for easier reading)\n\nThis is done by bumping the values of 'PenaltyReturnTypeOnItsOwnLine'\nand 'PenaltyBreakOpenParenthesis' to 300. This is so that we can allow a\nfew characters above the 80 column limit to make code more readable.\n\nSigned-off-by: Karthik Nayak <karthik.188@gmail.com>\n---\n .clang-format | 13 +++++++------\n 1 file changed, 7 insertions(+), 6 deletions(-)\n\ndiff --git a/.clang-format b/.clang-format\nindex 41969eca4b..66a2360ae5 100644\n--- a/.clang-format\n+++ b/.clang-format\n@@ -209,13 +209,14 @@ KeepEmptyLinesAtTheStartOfBlocks: false\n \n # Penalties\n # This decides what order things should be done if a line is too long\n-PenaltyBreakAssignment: 10\n-PenaltyBreakBeforeFirstCallParameter: 30\n-PenaltyBreakComment: 10\n+PenaltyBreakAssignment: 5\n+PenaltyBreakBeforeFirstCallParameter: 5\n+PenaltyBreakComment: 5\n PenaltyBreakFirstLessLess: 0\n-PenaltyBreakString: 10\n-PenaltyExcessCharacter: 100\n-PenaltyReturnTypeOnItsOwnLine: 60\n+PenaltyBreakOpenParenthesis: 300\n+PenaltyBreakString: 5\n+PenaltyExcessCharacter: 10\n+PenaltyReturnTypeOnItsOwnLine: 300\n \n # Don't sort #include's\n SortIncludes: false\n-- \n2.47.0\n\n"},{"id":"505416","messageId":"fcf965ac7491a1c4ce980517cddec7365b641cdb.1729241030.git.karthik.188@gmail.com","threadId":"62294","inReplyTo":"cover.1729241030.git.karthik.188@gmail.com","subject":"[PATCH v4 2/2] clang-format: align consecutive macro definitions","fromName":"Karthik Nayak","fromEmail":"karthik.188@gmail.com","sentAt":"2024-10-18T08:46:46Z","receivedAt":"2024-10-18T08:46:52Z","isPatch":true,"sender":{"key":"karthik.188@gmail.com","avatar":"https://avatars.githubusercontent.com/u/1786334?v=4"},"body":"We generally align consecutive macro definitions for better readability:\n\n  #define OUTPUT_ANNOTATE_COMPAT      (1U<<0)\n  #define OUTPUT_LONG_OBJECT_NAME     (1U<<1)\n  #define OUTPUT_RAW_TIMESTAMP        (1U<<2)\n  #define OUTPUT_PORCELAIN            (1U<<3)\n\nover\n\n  #define OUTPUT_ANNOTATE_COMPAT (1U<<0)\n  #define OUTPUT_LONG_OBJECT_NAME (1U<<1)\n  #define OUTPUT_RAW_TIMESTAMP (1U<<2)\n  #define OUTPUT_PORCELAIN (1U<<3)\n\nSo let's add the rule in clang-format to follow this.\n\nSigned-off-by: Karthik Nayak <karthik.188@gmail.com>\n---\n .clang-format | 3 +++\n 1 file changed, 3 insertions(+)\n\ndiff --git a/.clang-format b/.clang-format\nindex 66a2360ae5..9547fe1b77 100644\n--- a/.clang-format\n+++ b/.clang-format\n@@ -32,6 +32,9 @@ AlignConsecutiveAssignments: false\n # double b = 3.14;\n AlignConsecutiveDeclarations: false\n \n+# Align consecutive macro definitions.\n+AlignConsecutiveMacros: true\n+\n # Align escaped newlines as far left as possible\n # #define A   \\\n #   int aaaa; \\\n-- \n2.47.0\n\n"},{"id":"505473","messageId":"ZxLVLiiEEj2A5Iws@nand.local","threadId":"62294","inReplyTo":"cover.1729241030.git.karthik.188@gmail.com","subject":"Re: [PATCH v4 0/2] Subject: clang-format: fix rules to make the CI job cleaner","fromName":"Taylor Blau","fromEmail":"me@ttaylorr.com","sentAt":"2024-10-18T21:37:50Z","receivedAt":"2024-10-18T21:37:54Z","isPatch":true,"sender":{"key":"me@ttaylorr.com","avatar":"https://avatars.githubusercontent.com/u/301000140?v=4"},"body":"On Fri, Oct 18, 2024 at 10:46:44AM +0200, Karthik Nayak wrote:\n> Karthik Nayak (2):\n>   clang-format: re-adjust line break penalties\n>   clang-format: align consecutive macro definitions\n>\n>  .clang-format | 16 ++++++++++------\n>  1 file changed, 10 insertions(+), 6 deletions(-)\n\nThanks, will queue. Are we ready to start merging this one down?\n\nThanks,\nTaylor\n"},{"id":"505535","messageId":"CAOLa=ZSCenJLOg1jF==_uNGJ7GZdLiNd6GB_JO4XyXMdLNT65g@mail.gmail.com","threadId":"62294","inReplyTo":"ZxLVLiiEEj2A5Iws@nand.local","subject":"Re: [PATCH v4 0/2] Subject: clang-format: fix rules to make the CI job cleaner","fromName":"karthik nayak","fromEmail":"karthik.188@gmail.com","sentAt":"2024-10-20T11:17:58Z","receivedAt":"2024-10-20T11:18:00Z","isPatch":true,"sender":{"key":"karthik.188@gmail.com","avatar":"https://avatars.githubusercontent.com/u/1786334?v=4"},"body":"Taylor Blau <me@ttaylorr.com> writes:\n\n> On Fri, Oct 18, 2024 at 10:46:44AM +0200, Karthik Nayak wrote:\n>> Karthik Nayak (2):\n>>   clang-format: re-adjust line break penalties\n>>   clang-format: align consecutive macro definitions\n>>\n>>  .clang-format | 16 ++++++++++------\n>>  1 file changed, 10 insertions(+), 6 deletions(-)\n>\n> Thanks, will queue. Are we ready to start merging this one down?\n>\n\nI'd wait for some reviews :)\n\n> Thanks,\n> Taylor\n"},{"id":"505784","messageId":"ZxbMRACNtMfPiWr2@nand.local","threadId":"62294","inReplyTo":"CAOLa=ZSCenJLOg1jF==_uNGJ7GZdLiNd6GB_JO4XyXMdLNT65g@mail.gmail.com","subject":"Re: [PATCH v4 0/2] Subject: clang-format: fix rules to make the CI job cleaner","fromName":"Taylor Blau","fromEmail":"me@ttaylorr.com","sentAt":"2024-10-21T21:48:52Z","receivedAt":"2024-10-21T21:48:54Z","isPatch":true,"sender":{"key":"me@ttaylorr.com","avatar":"https://avatars.githubusercontent.com/u/301000140?v=4"},"body":"On Sun, Oct 20, 2024 at 06:17:58AM -0500, karthik nayak wrote:\n> Taylor Blau <me@ttaylorr.com> writes:\n>\n> > On Fri, Oct 18, 2024 at 10:46:44AM +0200, Karthik Nayak wrote:\n> >> Karthik Nayak (2):\n> >>   clang-format: re-adjust line break penalties\n> >>   clang-format: align consecutive macro definitions\n> >>\n> >>  .clang-format | 16 ++++++++++------\n> >>  1 file changed, 10 insertions(+), 6 deletions(-)\n> >\n> > Thanks, will queue. Are we ready to start merging this one down?\n>\n> I'd wait for some reviews :)\n\nOK. My impression was that the dust had more or less settled from\nearlier rounds. But let's wait.\n\nThanks,\nTaylor\n"},{"id":"505811","messageId":"CAOLa=ZQA1MkkV5tVq74LWPsueJ8L4UBXr07CF-JXGsh6jS4zTg@mail.gmail.com","threadId":"62294","inReplyTo":"ZxbMRACNtMfPiWr2@nand.local","subject":"Re: [PATCH v4 0/2] Subject: clang-format: fix rules to make the CI job cleaner","fromName":"karthik nayak","fromEmail":"karthik.188@gmail.com","sentAt":"2024-10-22T08:31:37Z","receivedAt":"2024-10-22T08:31:39Z","isPatch":true,"sender":{"key":"karthik.188@gmail.com","avatar":"https://avatars.githubusercontent.com/u/1786334?v=4"},"body":"Taylor Blau <me@ttaylorr.com> writes:\n\n> On Sun, Oct 20, 2024 at 06:17:58AM -0500, karthik nayak wrote:\n>> Taylor Blau <me@ttaylorr.com> writes:\n>>\n>> > On Fri, Oct 18, 2024 at 10:46:44AM +0200, Karthik Nayak wrote:\n>> >> Karthik Nayak (2):\n>> >>   clang-format: re-adjust line break penalties\n>> >>   clang-format: align consecutive macro definitions\n>> >>\n>> >>  .clang-format | 16 ++++++++++------\n>> >>  1 file changed, 10 insertions(+), 6 deletions(-)\n>> >\n>> > Thanks, will queue. Are we ready to start merging this one down?\n>>\n>> I'd wait for some reviews :)\n>\n> OK. My impression was that the dust had more or less settled from\n> earlier rounds. But let's wait.\n>\n> Thanks,\n> Taylor\n\nI'd be happy if it merged down, I'll see if someone from GitLab can help\nwith a review.\n\nThanks,\nKarthik\n"},{"id":"505844","messageId":"ZxfV8fNf5UQxo3A0@nand.local","threadId":"62294","inReplyTo":"CAOLa=ZQA1MkkV5tVq74LWPsueJ8L4UBXr07CF-JXGsh6jS4zTg@mail.gmail.com","subject":"Re: [PATCH v4 0/2] Subject: clang-format: fix rules to make the CI job cleaner","fromName":"Taylor Blau","fromEmail":"me@ttaylorr.com","sentAt":"2024-10-22T16:42:25Z","receivedAt":"2024-10-22T16:42:27Z","isPatch":true,"sender":{"key":"me@ttaylorr.com","avatar":"https://avatars.githubusercontent.com/u/301000140?v=4"},"body":"On Tue, Oct 22, 2024 at 04:31:37AM -0400, karthik nayak wrote:\n> Taylor Blau <me@ttaylorr.com> writes:\n>\n> > On Sun, Oct 20, 2024 at 06:17:58AM -0500, karthik nayak wrote:\n> >> Taylor Blau <me@ttaylorr.com> writes:\n> >>\n> >> > On Fri, Oct 18, 2024 at 10:46:44AM +0200, Karthik Nayak wrote:\n> >> >> Karthik Nayak (2):\n> >> >>   clang-format: re-adjust line break penalties\n> >> >>   clang-format: align consecutive macro definitions\n> >> >>\n> >> >>  .clang-format | 16 ++++++++++------\n> >> >>  1 file changed, 10 insertions(+), 6 deletions(-)\n> >> >\n> >> > Thanks, will queue. Are we ready to start merging this one down?\n> >>\n> >> I'd wait for some reviews :)\n> >\n> > OK. My impression was that the dust had more or less settled from\n> > earlier rounds. But let's wait.\n> >\n> > Thanks,\n> > Taylor\n>\n> I'd be happy if it merged down, I'll see if someone from GitLab can help\n> with a review.\n\nHaving additional reviewer eyes is much appreciated. Let's err on the\nside of that rather than rushing a topic if you don't feel that there is\nconsensus yet.\n\nThanks,\nTaylor\n"},{"id":"506076","messageId":"xefdxe2vctdtmfm3vfanstfz5q2bgcklj7ymio5bdutioyaxmo@ujixbc5jua6m","threadId":"62294","inReplyTo":"a8c8df5d95b0defec672ee139acd366219ea3302.1729241030.git.karthik.188@gmail.com","subject":"Re: [PATCH v4 1/2] clang-format: re-adjust line break penalties","fromName":"Justin Tobler","fromEmail":"jltobler@gmail.com","sentAt":"2024-10-25T02:37:36Z","receivedAt":"2024-10-25T02:39:11Z","isPatch":true,"sender":{"key":"jltobler@gmail.com","avatar":"https://avatars.githubusercontent.com/u/53454972?v=4"},"body":"On 24/10/18 10:46AM, Karthik Nayak wrote:\n> In 42efde4c29 (clang-format: adjust line break penalties, 2017-09-29) we\n> adjusted the line break penalties to really fine tune what we care about\n> while doing line breaks. Modify some of those to be more inline with\n> what we care about in the Git project now.\n\nFrom my understanding, the original motivation for these changes was to\ncut down on the noise from the clang-format CI job. These changes seem\nreasonable for that purpose, but affect the also formatter in general.\n\nOut of curiousity, would it be possible to just configured clang-format\nfor the CI job to behave in this manner? Ultimately, I'm not sure that\nwould be good idea though because having a diverged set of rules may\njust cause more noise.\n\n-Justin\n"},{"id":"506096","messageId":"CAOLa=ZT0h+R83vf7tzSQLw56TU2nW16PpbMGg6tkWoTYYpbLcQ@mail.gmail.com","threadId":"62294","inReplyTo":"xefdxe2vctdtmfm3vfanstfz5q2bgcklj7ymio5bdutioyaxmo@ujixbc5jua6m","subject":"Re: [PATCH v4 1/2] clang-format: re-adjust line break penalties","fromName":"karthik nayak","fromEmail":"karthik.188@gmail.com","sentAt":"2024-10-25T09:48:38Z","receivedAt":"2024-10-25T09:48:40Z","isPatch":true,"sender":{"key":"karthik.188@gmail.com","avatar":"https://avatars.githubusercontent.com/u/1786334?v=4"},"body":"Justin Tobler <jltobler@gmail.com> writes:\n\n> On 24/10/18 10:46AM, Karthik Nayak wrote:\n>> In 42efde4c29 (clang-format: adjust line break penalties, 2017-09-29) we\n>> adjusted the line break penalties to really fine tune what we care about\n>> while doing line breaks. Modify some of those to be more inline with\n>> what we care about in the Git project now.\n>\n> From my understanding, the original motivation for these changes was to\n> cut down on the noise from the clang-format CI job. These changes seem\n> reasonable for that purpose, but affect the also formatter in general.\n>\n\nYes, you're right. Which is the intended affect.\n\n> Out of curiousity, would it be possible to just configured clang-format\n> for the CI job to behave in this manner? Ultimately, I'm not sure that\n> would be good idea though because having a diverged set of rules may\n> just cause more noise.\n>\n\nWe do that in 'ci/run-style-check.sh' already, but here I'd say there is\nno need to diverge. We do want users to apply clang-format to _their_\nchanges, which should be similar to what the CI barfs.\n"}]}