On Fri, 16 Feb 2024 at 11:45, Peter Eisentraut <pe...@eisentraut.org> wrote: > I have committed that one.
Thanks :) > v3-0002-Require-final-newline-in-.po-files.patch > > The .po files are imported from elsewhere, so I'm not sure this is going > to have the desired effect. Perhaps it's worth cleaning up, but it > would require more steps. Okay, yeah that would need to be changed at the source then. Removed this change from the newly attached patchset, as well as updating editorconfig to have "insert_final_newline = unset" for .po files. > v3-0003-Bring-editorconfig-in-line-with-gitattributes.patch > > I question whether we need to add rules to .editorconfig about files > that are generated or imported from elsewhere, since those are not meant > to be edited. I agree that it's not strictly necessary to have .editorconfig match .gitattributes for files that are not meant to be edited by hand. But I don't really see a huge downside either, apart from having a few extra lines it .editorconfig. And adding these lines does have a few benefits: 1. It makes it easy to ensure that .editorconfig and .gitattributes stay in sync 2. If someone opens a file that they are not supposed to edit by hand, and then saves it. Then no changes are made. As opposed to suddenly making some whitespace changes Attached is a new patchset with the first commit split in three separate commits, which configure: 1. Files meant to be edited by hand) 2. Output test files (maybe edited by hand) 3. Imported/autogenerated files The first one is definitely the most useful to me personally.
From 419d2d0e45d40a4cddb942fbc63c3c54f4dd479d Mon Sep 17 00:00:00 2001 From: Jelte Fennema-Nio <jelte.fenn...@microsoft.com> Date: Mon, 19 Feb 2024 16:03:31 +0100 Subject: [PATCH v4 2/5] Include test output files in .editorconfig Most of the time these will be copy pasted from a test run, but if there's a trivial change someone might want to make the change by hand. By adding them to .editorconfig, we make sure that doing so won't mess up the formatting. --- .editorconfig | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/.editorconfig b/.editorconfig index 0e7c2048f9..92a16bd5de 100644 --- a/.editorconfig +++ b/.editorconfig @@ -27,3 +27,12 @@ trim_trailing_whitespace = false [src/backend/catalog/sql_features.txt] trim_trailing_whitespace = false + +# Test output files that contain extra whitespace +[*.out] +trim_trailing_whitespace = false +insert_final_newline = unset + +[src/interfaces/ecpg/test/expected/*] +trim_trailing_whitespace = false +insert_final_newline = unset -- 2.34.1
From b05173b619c45d9ad859da50bfa78d1fc626fe3d Mon Sep 17 00:00:00 2001 From: Jelte Fennema-Nio <jelte.fenn...@microsoft.com> Date: Wed, 14 Feb 2024 17:19:42 +0100 Subject: [PATCH v4 1/5] Handle blank-at-eof/blank-at-eol in .editorconfig too For many files in the repo our .gitattributes file is configured to complain about trailing whitespace at the end of a line, as well as not including a final newline at the end of the file. This updates our .editorconfig file, to make editors and IDEs fix these issues automatically on save in the same way for files that are intended to be edited by hand. --- .editorconfig | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/.editorconfig b/.editorconfig index d69a3d1dc4..0e7c2048f9 100644 --- a/.editorconfig +++ b/.editorconfig @@ -1,5 +1,9 @@ root = true +[*] +trim_trailing_whitespace = true +insert_final_newline = true + [*.{c,h,l,y,pl,pm}] indent_style = tab indent_size = tab @@ -12,3 +16,14 @@ indent_size = 1 [*.xsl] indent_style = space indent_size = 2 + +# Certain data files that contain special whitespace, and other special cases +[*.data] +trim_trailing_whitespace = false +insert_final_newline = unset + +[contrib/pgcrypto/sql/pgp-armor.sql] +trim_trailing_whitespace = false + +[src/backend/catalog/sql_features.txt] +trim_trailing_whitespace = false base-commit: e1b7fde418f2c0ba4ab0d9fbfa801ef62d96397b -- 2.34.1
From 97fe71d7769a3e4191adedbfe4092afec696ea7b Mon Sep 17 00:00:00 2001 From: Jelte Fennema-Nio <jelte.fenn...@microsoft.com> Date: Thu, 15 Feb 2024 10:23:19 +0100 Subject: [PATCH v4 4/5] Add note about keeping .editorconfig and .gitattributes in sync Now that they are in sync, hopefully this reminder makes sure we keep them that way. Automation to detect them being out of sync seems excessive. --- .editorconfig | 1 + .gitattributes | 1 + 2 files changed, 2 insertions(+) diff --git a/.editorconfig b/.editorconfig index c742e0f844..3f5c4e0ef8 100644 --- a/.editorconfig +++ b/.editorconfig @@ -1,3 +1,4 @@ +# IMPORTANT: When updating this file, also update .gitattributes to match. root = true [*] diff --git a/.gitattributes b/.gitattributes index e9ff4a56bd..7923fc3387 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,3 +1,4 @@ +# IMPORTANT: When updating this file, also update .editorconfig to match. * whitespace=space-before-tab,trailing-space *.[chly] whitespace=space-before-tab,trailing-space,indent-with-non-tab,tabwidth=4 *.pl whitespace=space-before-tab,trailing-space,tabwidth=4 -- 2.34.1
From 36163e2377e775d1322ab6b71f2893a4e5c1984f Mon Sep 17 00:00:00 2001 From: Jelte Fennema-Nio <jelte.fenn...@microsoft.com> Date: Mon, 19 Feb 2024 16:06:05 +0100 Subject: [PATCH v4 3/5] Bring .editorconfig fully in sync with .gitattributes This adds the final lines from .gitattributes to .editorconfig. It shouldn't matter for most people, because these lines are for generated or elsewhere maintained files. Still it seems be nice for these files not to be reformated if someone opens them in their editor and then presses save. --- .editorconfig | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/.editorconfig b/.editorconfig index 92a16bd5de..c742e0f844 100644 --- a/.editorconfig +++ b/.editorconfig @@ -9,6 +9,12 @@ indent_style = tab indent_size = tab tab_width = 4 +[*.po] +# This does not provide indent_size since .po files don't have indentation. +# Setting indent_style is only done to prevent accidental insertion of tabs. +indent_style = space +insert_final_newline = unset + [*.{sgml,xml}] indent_style = space indent_size = 1 @@ -36,3 +42,40 @@ insert_final_newline = unset [src/interfaces/ecpg/test/expected/*] trim_trailing_whitespace = false insert_final_newline = unset + +# These files are maintained or generated elsewhere. We take them as is. +[configure] +trim_trailing_whitespace = false +insert_final_newline = unset + +[ppport.h] +trim_trailing_whitespace = false +insert_final_newline = unset + +[src/backend/regex/COPYRIGHT] +trim_trailing_whitespace = false +insert_final_newline = unset + +[src/backend/snowball/libstemmer/*.c] +trim_trailing_whitespace = false +insert_final_newline = unset + +[src/backend/utils/mb/Unicode/*-std.txt] +trim_trailing_whitespace = false +insert_final_newline = unset + +[src/include/snowball/libstemmer/*] +trim_trailing_whitespace = false +insert_final_newline = unset + +[src/timezone/data/*] +trim_trailing_whitespace = false +insert_final_newline = unset + +[src/tools/pg_bsd_indent/*] +trim_trailing_whitespace = false +insert_final_newline = unset + +[src/tools/pg_bsd_indent/tests/*] +trim_trailing_whitespace = false +insert_final_newline = unset -- 2.34.1
From 116c3b9a529c2ccd8d6de9daa5d56d1b313ae213 Mon Sep 17 00:00:00 2001 From: Jelte Fennema-Nio <jelte.fenn...@microsoft.com> Date: Thu, 15 Feb 2024 18:34:42 +0100 Subject: [PATCH v4 5/5] Add indent information about gitattributes to editorconfig The columns in .gitattributes only look nicely alligned when using 8-width tabs. --- .editorconfig | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.editorconfig b/.editorconfig index 3f5c4e0ef8..d6566d1a27 100644 --- a/.editorconfig +++ b/.editorconfig @@ -24,6 +24,11 @@ indent_size = 1 indent_style = space indent_size = 2 +[.gitattributes] +indent_style = tab +indent_size = tab +tab_width = 8 + # Certain data files that contain special whitespace, and other special cases [*.data] trim_trailing_whitespace = false -- 2.34.1