@@ -49,9 +49,110 @@ This edition covers what happened during the month of April 2019.
4949 attendees to explore Munich and get to know each other before the
5050 unconference begins".
5151
52- <!-- -
5352### Reviews
54- -->
53+
54+ * [[ RFC PATCH] * .h: remove extern from function declarations] ( https://public-inbox.org/git/3e3b9d6c8e54b326809b95adabd3be39d2d0770f.1555111963.git.liu.denton@gmail.com/ )
55+
56+ Denton Liu sent a big RFC patch that removes "extern" keywords in
57+ front of function declarations and that affects in big number of
58+ '.h' header files.
59+
60+ He said that he used the following command to remove the keywords:
61+
62+ ```
63+ $ git ls-files '*.h' | xargs sed -i'' -e 's/^\(\s*\)extern \(.*(\)/\1\2/'
64+ ```
65+
66+ And the following one to check the result:
67+
68+ ```
69+ $ git grep -w extern '*.h'
70+ ```
71+
72+ Jeff King, alias Peff, replied that dropping "extern" should not be
73+ done on function pointer declarations though, as a function pointer
74+ is a variable, so its visibility would change if "extern" is removed
75+ in front of it.
76+
77+ Junio agreed with Peff and explained that the reason we avoid
78+ wholesale updates "is because of an unnecessary bug like this one,
79+ not the one-time conflict resolution load that can be subcontracted
80+ out to "rerere" once dealt with ;-)".
81+
82+ Junio also suggested using "a tool more suited for the job
83+ (e.g. spatch)" as it "raises the confidence level of the end result
84+ a lot more than a "sed and then eyeball" rewrite", though we then
85+ have to be careful about possible "bugs in the instructions we give
86+ to the tool".
87+
88+ Denton then sent a
[ second version
] ( https://public-inbox.org/git/[email protected] / ) 89+ of his work. It was now a 3 patch long patch series.
90+
91+ The first patch used the ` spatch ` tool to do most of the "extern"
92+ keyword removals. The second patch still used ` sed ` to do it where
93+ ` spatch ` didn't work, but it made sure to ignore function
94+ variables. The third patch used a Coccinelle script to make sure
95+ that no more "extern" keywords are added to the code base.
96+
97+ Thomas Gummerer replied to the first patch that it "leaves a bunch
98+ of oddly indented parameter lists behind", as when a function has a
99+ larger number of parameters, its declaration often span more than
100+ one line.
101+
102+ Denton then send a
[ third version
] ( https://public-inbox.org/git/[email protected] / ) 103+ of his work, with an additional patch to "manually align parameter
104+ lists that were mangled by the tools".
105+
106+ Peff replied wondering if it was a good thing to modify files in the
107+ compat/ directory as the code there is often "copied from
108+ elsewhere". He also wondered if it was worth keeping the Coccinelle
109+ script as it is expensive to run.
110+
111+ In the
[ fourth version
] ( https://public-inbox.org/git/[email protected] / ) 112+ of his work, Denton decided to keep the Coccinelle script, but
113+ excluded the compat/ directory from the files where "extern" is
114+ removed.
115+
116+ Junio noticed that in a commit message Denton mentioned using:
117+
118+ ```
119+ $ git ls-files \*.{c,h} | \
120+ grep -v ^compat/ | \
121+ xargs sed -i'' -e 's/^\(\s*\)extern \([^(]*([^*]\)/\1\2/'
122+ ```
123+
124+ and then asked him to remove the useless backslashes at the end of
125+ the first 2 lines above, saying:
126+
127+ > Your shell knows its own syntax sufficiently well, and when you end
128+ > a line with a pipe, it knows that you haven't finished speaking to
129+ > it and waits for you to give the command downstream of the pipe,
130+ > without being told that you haven't finished with a backslash.
131+
132+ Unfortunately SZEDER Gábor then found that the Coccinelle script
133+ failed on 'compat/obstack.h' as it is included in a '.c' file
134+ checked by Coccinelle scripts.
135+
136+ Denton replied by proposing to drop the patch that contained his
137+ Coccinelle script, but Johannes Schindelin, alias Dscho, suggested
138+ to exclude certain directories or certain files for certain
139+ Coccinelle scripts.
140+
141+ There was then a long discussion thread involving Peff, Denton,
142+ Jacob Keller, Dscho, Junio and Gábor about what was possible to do
143+ with Coccinelle and spatch and how they are used in the Git
144+ toolchain. This thread eventually resulted in Peff making a small
145+ series of
146+ [ patches
] ( https://public-inbox.org/git/[email protected] / ) ,
147+ based on a previous patch by Jacob, that makes it possible to run
148+ Coccinelle faster on machines with a lot of memory. Peff's patches
149+ have since been merged into the 'master' branch.
150+
151+ Denton in the meantime sent a
[ fifth version
] ( https://public-inbox.org/git/[email protected] / ) 152+ of his work that drops the patch that contained his Coccinelle
153+ script, and loses the useless backslashes. This patch series has
154+ also been merged into the 'master' branch and will be part of Git
155+ v2.22.0 that should be released at the beginning of June 2019.
55156
56157<!-- -
57158### Support
0 commit comments