{"thread":{"id":"49363","subject":"[PATCH] Add an EditorConfig file","startedAt":"2018-09-17T23:03:16Z","lastAt":"2018-09-27T22:34:04Z","messageCount":12,"participants":["brian m. carlson","Taylor Blau","Junio C Hamano","Eric Sunshine","Jeff King"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"358370","messageId":"20180917230307.588334-1-sandals@crustytoothpaste.net","threadId":"49363","inReplyTo":null,"subject":"[PATCH] Add an EditorConfig file","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2018-09-17T23:03:07Z","receivedAt":"2018-09-17T23:03:16Z","isPatch":true,"sender":{"key":"sandals@crustytoothpaste.net","avatar":"https://avatars.githubusercontent.com/u/497054?v=4"},"body":"Contributors to Git use a variety of editors, each with their own\nconfiguration files.  Because C lacks the defined norms on how to indent\nand style code that other languages, such as Ruby and Rust, have, it's\npossible for various contributors, especially new ones, to have\nconfigured their editor to use a style other than the style the Git\ncommunity prefers.\n\nTo make automatically configuring one's editor easier, provide an\nEditorConfig file.  This is an INI-style configuration file that can be\nused to specify editor settings and can be understood by a wide variety\nof editors.  Some editors include this support natively; others require\na plugin.  Regardless, providing such a file allows users to\nautomatically configure their editor of choice with the correct settings\nby default.\n\nProvide global settings to set the character set to UTF-8 and insert a\nfinal newline into files.  Provide language-specific settings for C,\nShell, Perl, and Python files according to what CodingGuidelines already\nspecifies.  Since the indentation of other files varies, especially\ncertain AsciiDoc files, don't provide any settings for them until a\nclear consensus forward emerges.\n\nDon't specify an end of line type.  While the Git community uses\nUnix-style line endings in the repository, some Windows users may use\nGit's auto-conversion support and forcing Unix-style line endings might\ncause problems for those users.\n\nFinally, leave out a root directive, which would prevent reading other\nEditorConfig files higher up in the tree, in case someone wants to set\nthe end of line type for their system in such a file.\n\nSigned-off-by: brian m. carlson <sandals@crustytoothpaste.net>\n---\nI was incentivized to write this when I started using worktrees for\ndevelopment and found that I had inserted spaces into all the work I was\ndoing because I was outside of my normal git.git clone.\n\nThis is the easiest way to set per-repo configuration across editors,\nespecially since people may work on various C codebases with different\nindentation standards.\n\n .editorconfig | 11 +++++++++++\n 1 file changed, 11 insertions(+)\n create mode 100644 .editorconfig\n\ndiff --git a/.editorconfig b/.editorconfig\nnew file mode 100644\nindex 0000000000..8963d83fdb\n--- /dev/null\n+++ b/.editorconfig\n@@ -0,0 +1,11 @@\n+[*]\n+charset = utf-8\n+insert_final_newline = true\n+\n+[*.{c,h,sh,perl}]\n+indent_style = tab\n+tab_width = 8\n+\n+[*.py]\n+indent_style = space\n+indent_size = 4\n"},{"id":"358371","messageId":"20180917231850.GB81083@syl","threadId":"49363","inReplyTo":"20180917230307.588334-1-sandals@crustytoothpaste.net","subject":"Re: [PATCH] Add an EditorConfig file","fromName":"Taylor Blau","fromEmail":"me@ttaylorr.com","sentAt":"2018-09-17T23:18:50Z","receivedAt":"2018-09-17T23:18:55Z","isPatch":true,"sender":{"key":"me@ttaylorr.com","avatar":"https://avatars.githubusercontent.com/u/301000140?v=4"},"body":"Hi brian,\n\nThanks for CC-ing me on this.\n\nI use editorconfig every day via the configuration in my home directory\n[1], and the Vim plugin editorconfig-vim [2]. It's a great piece of\nsoftware, and I've been using it without any issue since around the\nbeginning of 2015.\n\nOn Mon, Sep 17, 2018 at 11:03:07PM +0000, brian m. carlson wrote:\n> Regardless, providing such a file allows users to automatically\n> configure their editor of choice with the correct settings by default.\n\nI think that this is the central argument to be made here for keeping\nthis out of contrib/, and in the root tree. Most editor (all?) plugins\nwill pick this location up automatically, which ought to cut down on\npatches that aren't formatted correctly.\n\n> Provide global settings to set the character set to UTF-8 and insert a\n> final newline into files.  Provide language-specific settings for C,\n> Shell, Perl, and Python files according to what CodingGuidelines already\n> specifies.  Since the indentation of other files varies, especially\n> certain AsciiDoc files, don't provide any settings for them until a\n> clear consensus forward emerges.\n>\n> Don't specify an end of line type.  While the Git community uses\n> Unix-style line endings in the repository, some Windows users may use\n> Git's auto-conversion support and forcing Unix-style line endings might\n> cause problems for those users.\n\nGood. Even the official editorconfig documentation specifies that this\nought to be the responsibility \"of the VCS\" [3], a point on which I\nagree.\n\n> +[*.{c,h,sh,perl}]\n> +indent_style = tab\n> +tab_width = 8\n\nIn all *.[ch] files in git.git, I found a total of 817 lines over 79\ncharacters wide:\n\n  $ for file in $(git ls-files '**/*.[ch]'); do\n      awk 'length > 79' $f;\n    done | wc -l\n\nSo I think that specifying indent_style, and tab_width to be 'tab' and\n'8' respectively is enough. We shouldn't be enforcing a rule about line\nlengths that we are not ourselves consistently following.\n\nHave you thought about including guidelines on COMMIT_EDITMSG? We prefer\n72 characters per line [3], and this is enforceable via the following:\n\n  [COMMIT_EDITMSG]\n  max_line_length = 72\n\nThanks,\nTaylor\n\n[1]: https://github.com/ttaylorr/dotfiles/blob/work-gh/editorconfig/.editorconfig\n[2]: https://github.com/editorconfig/editorconfig-vim\n[3]: http://public-inbox.org/git/20170930070127.xvtn7dfyuoh26mhp@sigill.intra.peff.net\n"},{"id":"358439","messageId":"xmqqtvmm42es.fsf@gitster-ct.c.googlers.com","threadId":"49363","inReplyTo":"20180917230307.588334-1-sandals@crustytoothpaste.net","subject":"Re: [PATCH] Add an EditorConfig file","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2018-09-19T03:00:27Z","receivedAt":"2018-09-19T03:00:32Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"brian m. carlson\" <sandals@crustytoothpaste.net> writes:\n\n> To make automatically configuring one's editor easier, provide an\n> EditorConfig file.  This is an INI-style configuration file that can be\n> used to specify editor settings and can be understood by a wide variety\n> of editors.  Some editors include this support natively; others require\n> a plugin.\n\nGood intentions.  One thing that makes me wonder is how well this\nplays with \"make style\" and how easy will it be to keep their\nrecommendations in sync.  Ideally, if we can generate one from the\nother, or both from a unified source, that would be great.\n"},{"id":"358498","messageId":"20180920000013.GZ432229@genre.crustytoothpaste.net","threadId":"49363","inReplyTo":"xmqqtvmm42es.fsf@gitster-ct.c.googlers.com","subject":"Re: [PATCH] Add an EditorConfig file","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2018-09-20T00:00:14Z","receivedAt":"2018-09-20T00:00:22Z","isPatch":true,"sender":{"key":"sandals@crustytoothpaste.net","avatar":"https://avatars.githubusercontent.com/u/497054?v=4"},"body":"On Tue, Sep 18, 2018 at 08:00:27PM -0700, Junio C Hamano wrote:\n> \"brian m. carlson\" <sandals@crustytoothpaste.net> writes:\n> \n> > To make automatically configuring one's editor easier, provide an\n> > EditorConfig file.  This is an INI-style configuration file that can be\n> > used to specify editor settings and can be understood by a wide variety\n> > of editors.  Some editors include this support natively; others require\n> > a plugin.\n> \n> Good intentions.  One thing that makes me wonder is how well this\n> plays with \"make style\" and how easy will it be to keep their\n> recommendations in sync.  Ideally, if we can generate one from the\n> other, or both from a unified source, that would be great.\n\nI think \"make style\" and the EditorConfig file are complementary.  \"make\nstyle\" autoformats code into a diff.  I agree that if we always used\nclang-format to format code, then this would be a non-issue in the\nEditorConfig file, since we'd just tell people to format their code and\nbe done with it.  However, we don't automatically do that, so I think\nthis still has value.\n\n(I am having trouble getting make style to work, though, because it\nseems to invoke clang-format as a git subcommand, and I don't think that\nworks.  I may send a patch.)\n\nEven if we did that, we couldn't do it for Perl, because the tidy tool\nfor Perl, perltidy, produces different output depending on version.  I\nexpect we'll have little success in trying to standardize on a given\nversion.\n\nThe EditorConfig file applies to a variety of formats and is designed to\nset default editor settings (which users *can* override if they choose).\nIt applies to any file pattern; for example, as Taylor pointed out, we\ncould use it to recommend 72-character lines in commit messages.\n\nI agree that maintaining more files is a hassle, but personally, I think\nit quite unlikely that we're going to change the Git style, so I feel\nthe maintenance is fairly low.\n-- \nbrian m. carlson: Houston, Texas, US\nOpenPGP: https://keybase.io/bk2204\n"},{"id":"358499","messageId":"20180920000559.GA432229@genre.crustytoothpaste.net","threadId":"49363","inReplyTo":"20180917231850.GB81083@syl","subject":"Re: [PATCH] Add an EditorConfig file","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2018-09-20T00:05:59Z","receivedAt":"2018-09-20T00:06:08Z","isPatch":true,"sender":{"key":"sandals@crustytoothpaste.net","avatar":"https://avatars.githubusercontent.com/u/497054?v=4"},"body":"On Mon, Sep 17, 2018 at 07:18:50PM -0400, Taylor Blau wrote:\n> Hi brian,\n> \n> Thanks for CC-ing me on this.\n> \n> I use editorconfig every day via the configuration in my home directory\n> [1], and the Vim plugin editorconfig-vim [2]. It's a great piece of\n> software, and I've been using it without any issue since around the\n> beginning of 2015.\n\nYeah, I noticed it in your dotfiles.\n\n> In all *.[ch] files in git.git, I found a total of 817 lines over 79\n> characters wide:\n> \n>   $ for file in $(git ls-files '**/*.[ch]'); do\n>       awk 'length > 79' $f;\n>     done | wc -l\n> \n> So I think that specifying indent_style, and tab_width to be 'tab' and\n> '8' respectively is enough. We shouldn't be enforcing a rule about line\n> lengths that we are not ourselves consistently following.\n\nI must admit that some of these are my fault.  I think we're moving to\nuse clang-format more as a tool, so hopefully those become less of an\nissue over time.\n\n> Have you thought about including guidelines on COMMIT_EDITMSG? We prefer\n> 72 characters per line [3], and this is enforceable via the following:\n> \n>   [COMMIT_EDITMSG]\n>   max_line_length = 72\n\nThat's an interesting thought.  I know different people have different\nsettings for this: 70, 72, 74.  72 characters is typical for emails, and\nsince our commits end up as emails, I think standardizing on 72 would\nmake sense.\n-- \nbrian m. carlson: Houston, Texas, US\nOpenPGP: https://keybase.io/bk2204\n"},{"id":"358510","messageId":"xmqqk1ng2rdo.fsf@gitster-ct.c.googlers.com","threadId":"49363","inReplyTo":"20180920000013.GZ432229@genre.crustytoothpaste.net","subject":"Re: [PATCH] Add an EditorConfig file","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2018-09-20T14:08:35Z","receivedAt":"2018-09-20T14:08:40Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"brian m. carlson\" <sandals@crustytoothpaste.net> writes:\n\n> I think \"make style\" and the EditorConfig file are complementary.  \"make\n> style\" autoformats code into a diff.  I agree that if we always used\n> clang-format to format code, then this would be a non-issue in the\n> EditorConfig file, since we'd just tell people to format their code and\n> be done with it.  However, we don't automatically do that, so I think\n> this still has value.\n\nOh, we agree on that 100%.  These are complementary.  \n\nMy comment was that it would be confusing if they gave contradicting\nsuggestions to the end user.  After letting EditorConfig to enforce\none style while typing and saving, if \"make style\" suggests to\nformat it differently, it would not be a great user experience.\n\nThe ideal response would have been \"Oh, of course EditorConfig folks\nalready thought about that, which is a natural thing to wish for,\nand they have a tool to generate clang-format configuration from the\nsection for C language in any EditorConfig file---here is a link.\nAfter all, tools like clang-format look like just another editor to\nthem ;-)\".\n\nBut that is a response in a dream-world.  If there is no such tool,\nI am perfectly OK if the plan is to manually keep them (loosely) in\nsync.  I do not think it is good use of our time to try to come up\nwith such a tool (unless somebody is really interested in doing it,\nthat is).\n\nThanks.\n"},{"id":"358553","messageId":"CAPig+cTQuwMDMpHe4inO61=Mq2+q1OdGsEG_hpii+dNmjXHZLg@mail.gmail.com","threadId":"49363","inReplyTo":"20180920000013.GZ432229@genre.crustytoothpaste.net","subject":"Re: [PATCH] Add an EditorConfig file","fromName":"Eric Sunshine","fromEmail":"sunshine@sunshineco.com","sentAt":"2018-09-21T02:26:47Z","receivedAt":"2018-09-21T02:27:00Z","isPatch":true,"sender":{"key":"sunshine@sunshineco.com","avatar":"https://avatars.githubusercontent.com/u/163641?v=4"},"body":"On Wed, Sep 19, 2018 at 8:00 PM brian m. carlson\n<sandals@crustytoothpaste.net> wrote:\n> (I am having trouble getting make style to work, though, because it\n> seems to invoke clang-format as a git subcommand, and I don't think that\n> works.  I may send a patch.)\n\nYou're probably missing this piece:\nhttps://llvm.org/svn/llvm-project/cfe/trunk/tools/clang-format/git-clang-format\n"},{"id":"358555","messageId":"20180921023503.GA29606@sigill.intra.peff.net","threadId":"49363","inReplyTo":"CAPig+cTQuwMDMpHe4inO61=Mq2+q1OdGsEG_hpii+dNmjXHZLg@mail.gmail.com","subject":"Re: [PATCH] Add an EditorConfig file","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2018-09-21T02:35:04Z","receivedAt":"2018-09-21T02:35:08Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Thu, Sep 20, 2018 at 10:26:47PM -0400, Eric Sunshine wrote:\n\n> On Wed, Sep 19, 2018 at 8:00 PM brian m. carlson\n> <sandals@crustytoothpaste.net> wrote:\n> > (I am having trouble getting make style to work, though, because it\n> > seems to invoke clang-format as a git subcommand, and I don't think that\n> > works.  I may send a patch.)\n> \n> You're probably missing this piece:\n> https://llvm.org/svn/llvm-project/cfe/trunk/tools/clang-format/git-clang-format\n\nI've been confused by this, too. In Debian they ship it with the version\nnumber. E.g., /usr/bin/git-clang-format-7, which is a symlink to\n/usr/lib/llvm-7/bin/git-clang-format.\n\nWe might want a Makefile variable to let you override this path (I think\nI just ended up putting another symlink in ~/local/bin).\n\n-Peff\n"},{"id":"358667","messageId":"20180921221918.GB432229@genre.crustytoothpaste.net","threadId":"49363","inReplyTo":"20180921023503.GA29606@sigill.intra.peff.net","subject":"Re: [PATCH] Add an EditorConfig file","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2018-09-21T22:19:18Z","receivedAt":"2018-09-21T22:19:28Z","isPatch":true,"sender":{"key":"sandals@crustytoothpaste.net","avatar":"https://avatars.githubusercontent.com/u/497054?v=4"},"body":"On Thu, Sep 20, 2018 at 10:35:04PM -0400, Jeff King wrote:\n> On Thu, Sep 20, 2018 at 10:26:47PM -0400, Eric Sunshine wrote:\n> \n> > On Wed, Sep 19, 2018 at 8:00 PM brian m. carlson\n> > <sandals@crustytoothpaste.net> wrote:\n> > > (I am having trouble getting make style to work, though, because it\n> > > seems to invoke clang-format as a git subcommand, and I don't think that\n> > > works.  I may send a patch.)\n> > \n> > You're probably missing this piece:\n> > https://llvm.org/svn/llvm-project/cfe/trunk/tools/clang-format/git-clang-format\n\nI am indeed missing that.  I looked for it in git.git, but didn't think\nto look for it as part of clang-format.\n\n> I've been confused by this, too. In Debian they ship it with the version\n> number. E.g., /usr/bin/git-clang-format-7, which is a symlink to\n> /usr/lib/llvm-7/bin/git-clang-format.\n\nI filed a bug report asking Debian to include a symlink in the default\npackage.\n\n> We might want a Makefile variable to let you override this path (I think\n> I just ended up putting another symlink in ~/local/bin).\n\nI may send a patch to do that.\n-- \nbrian m. carlson: Houston, Texas, US\nOpenPGP: https://keybase.io/bk2204\n"},{"id":"358681","messageId":"20180921225039.GC432229@genre.crustytoothpaste.net","threadId":"49363","inReplyTo":"xmqqk1ng2rdo.fsf@gitster-ct.c.googlers.com","subject":"Re: [PATCH] Add an EditorConfig file","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2018-09-21T22:50:40Z","receivedAt":"2018-09-21T22:50:48Z","isPatch":true,"sender":{"key":"sandals@crustytoothpaste.net","avatar":"https://avatars.githubusercontent.com/u/497054?v=4"},"body":"On Thu, Sep 20, 2018 at 07:08:35AM -0700, Junio C Hamano wrote:\n> My comment was that it would be confusing if they gave contradicting\n> suggestions to the end user.  After letting EditorConfig to enforce\n> one style while typing and saving, if \"make style\" suggests to\n> format it differently, it would not be a great user experience.\n\nAh, okay.  I understand your concern better now.\n\n> The ideal response would have been \"Oh, of course EditorConfig folks\n> already thought about that, which is a natural thing to wish for,\n> and they have a tool to generate clang-format configuration from the\n> section for C language in any EditorConfig file---here is a link.\n> After all, tools like clang-format look like just another editor to\n> them ;-)\".\n\nNo, I don't think there's such a tool.  clang-format wants a lot of\nformat settings that aren't in EditorConfig, and EditorConfig wants to\naddress things that are not C source files.\n\n> But that is a response in a dream-world.  If there is no such tool,\n> I am perfectly OK if the plan is to manually keep them (loosely) in\n> sync.  I do not think it is good use of our time to try to come up\n> with such a tool (unless somebody is really interested in doing it,\n> that is).\n\nWould it be helpful if I sent a script that ran during CI to ensure they\nstayed in sync for the couple places where they overlap?  I'm happy to\ndo so if you think it would be useful.\n-- \nbrian m. carlson: Houston, Texas, US\nOpenPGP: https://keybase.io/bk2204\n"},{"id":"358776","messageId":"xmqqefdislto.fsf@gitster-ct.c.googlers.com","threadId":"49363","inReplyTo":"20180921225039.GC432229@genre.crustytoothpaste.net","subject":"Re: [PATCH] Add an EditorConfig file","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2018-09-24T20:05:23Z","receivedAt":"2018-09-24T20:05:28Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"brian m. carlson\" <sandals@crustytoothpaste.net> writes:\n\n>> But that is a response in a dream-world.  If there is no such tool,\n>> I am perfectly OK if the plan is to manually keep them (loosely) in\n>> sync.  I do not think it is good use of our time to try to come up\n>> with such a tool (unless somebody is really interested in doing it,\n>> that is).\n>\n> Would it be helpful if I sent a script that ran during CI to ensure they\n> stayed in sync for the couple places where they overlap?  I'm happy to\n> do so if you think it would be useful.\n\nIt may even be an overkill.\n\nA comment addressed to those who edit one file to look at the other\nfile on both files would be sufficient, I suspect.\n"},{"id":"359157","messageId":"20180927223353.GH432229@genre.crustytoothpaste.net","threadId":"49363","inReplyTo":"xmqqefdislto.fsf@gitster-ct.c.googlers.com","subject":"Re: [PATCH] Add an EditorConfig file","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2018-09-27T22:33:53Z","receivedAt":"2018-09-27T22:34:04Z","isPatch":true,"sender":{"key":"sandals@crustytoothpaste.net","avatar":"https://avatars.githubusercontent.com/u/497054?v=4"},"body":"On Mon, Sep 24, 2018 at 01:05:23PM -0700, Junio C Hamano wrote:\n> > Would it be helpful if I sent a script that ran during CI to ensure they\n> > stayed in sync for the couple places where they overlap?  I'm happy to\n> > do so if you think it would be useful.\n> \n> It may even be an overkill.\n> \n> A comment addressed to those who edit one file to look at the other\n> file on both files would be sufficient, I suspect.\n\nSure.  Let me reroll with that change.\n-- \nbrian m. carlson: Houston, Texas, US\nOpenPGP: https://keybase.io/bk2204\n"}]}