1
1
pgindent'ing the PostgreSQL source tree
2
2
=======================================
3
3
4
- We run this process at least once in each development cycle,
5
- to maintain uniform layout style in our C and Perl code.
4
+ pgindent is used to maintain uniform layout style in our C and Perl code,
5
+ and should be run for every commit. There are additional code beautification
6
+ tasks which should be performed at least once per release cycle.
6
7
7
8
You might find this blog post interesting:
8
9
http://adpgtech.blogspot.com/2015/05/running-pgindent-on-non-core-code-or.html
@@ -25,45 +26,31 @@ PREREQUISITES:
25
26
Or if you have cpanm installed, you can just use:
26
27
cpanm https://cpan.metacpan.org/authors/id/S/SH/SHANCOCK/Perl-Tidy-20230309.tar.gz
27
28
28
- DOING THE INDENT RUN:
29
29
30
- 1) Change directory to the top of the source tree.
31
-
32
- 2) Download the latest typedef file from the buildfarm:
30
+ DOING THE INDENT RUN BEFORE A NORMAL COMMIT:
33
31
34
- wget -O src/tools/pgindent/typedefs.list https://buildfarm.postgresql.org/cgi-bin/typedefs.pl
35
-
36
- (See https://buildfarm.postgresql.org/cgi-bin/typedefs.pl?show_list for a full
37
- list of typedef files, if you want to indent some back branch.)
32
+ 1) Change directory to the top of the source tree.
38
33
39
- 3 ) Run pgindent on the C files:
34
+ 2 ) Run pgindent on the C files:
40
35
41
36
src/tools/pgindent/pgindent .
42
37
43
38
If any files generate errors, restore their original versions with
44
39
"git checkout", and see below for cleanup ideas.
45
40
46
- 4) Indent the Perl code using perltidy:
47
-
48
- src/tools/pgindent/pgperltidy .
49
-
50
- If you want to use some perltidy version that's not in your PATH,
51
- first set the PERLTIDY environment variable to point to it.
52
-
53
- 5) Reformat the bootstrap catalog data files:
54
-
55
- ./configure # "make" will not work in an unconfigured tree
56
- cd src/include/catalog
57
- make reformat-dat-files
58
- cd ../../..
59
-
60
- VALIDATION:
61
-
62
- 1) Check for any newly-created files using "git status"; there shouldn't
41
+ 3) Check for any newly-created files using "git status"; there shouldn't
63
42
be any. (pgindent leaves *.BAK files behind if it has trouble, while
64
43
perltidy leaves *.LOG files behind.)
65
44
66
- 2) Do a full test build:
45
+ 4) If pgindent wants to change anything your commit wasn't touching,
46
+ stop and figure out why. If it is making ugly whitespace changes
47
+ around typedefs your commit adds, you need to add those typedefs
48
+ to src/tools/pgindent/typedefs.list.
49
+
50
+ 5) If you have the patience, it's worth eyeballing the "git diff" output
51
+ for any egregiously ugly changes. See below for cleanup ideas.
52
+
53
+ 6) Do a full test build:
67
54
68
55
make -s clean
69
56
make -s all # look for unexpected warnings, and errors of course
@@ -75,14 +62,38 @@ VALIDATION:
75
62
header files that get copied into ecpg output; if so, adjust the
76
63
expected-files to match.
77
64
78
- 3) If you have the patience, it's worth eyeballing the "git diff" output
79
- for any egregiously ugly changes. See below for cleanup ideas.
80
65
66
+ AT LEAST ONCE PER RELEASE CYCLE:
67
+
68
+ 1) Download the latest typedef file from the buildfarm:
69
+
70
+ wget -O src/tools/pgindent/typedefs.list https://buildfarm.postgresql.org/cgi-bin/typedefs.pl
71
+
72
+ This step resolves any differences between the incrementally updated
73
+ version of the file and a clean, autogenerated one.
74
+ (See https://buildfarm.postgresql.org/cgi-bin/typedefs.pl?show_list for
75
+ a full list of typedef files, if you want to indent some back branch.)
76
+
77
+ 2) Run pgindent as above.
78
+
79
+ 3) Indent the Perl code using perltidy:
80
+
81
+ src/tools/pgindent/pgperltidy .
82
+
83
+ If you want to use some perltidy version that's not in your PATH,
84
+ first set the PERLTIDY environment variable to point to it.
85
+
86
+ 4) Reformat the bootstrap catalog data files:
87
+
88
+ ./configure # "make" will not work in an unconfigured tree
89
+ cd src/include/catalog
90
+ make reformat-dat-files
91
+ cd ../../..
81
92
82
- When you're done, "git commit" everything including the typedefs.list file
83
- you used.
93
+ 5) When you're done, "git commit" everything including the typedefs.list file
94
+ you used.
84
95
85
- 4 ) Add the newly created commits to the .git-blame-ignore-revs file so
96
+ 6 ) Add the newly created commit(s) to the .git-blame-ignore-revs file so
86
97
that "git blame" ignores the commits (for anybody that has opted-in
87
98
to using the ignore file). Follow the instructions that appear at
88
99
the top of the .git-blame-ignore-revs file.
0 commit comments