Skip to content

Commit b4a5ea0

Browse files
committed
Merge tag 'docs-5.18-2' of git://git.lwn.net/linux
Pull more documentation updates from Jonathan Corbet: "Some late-arriving documentation improvements. This is mostly build-system fixes from Mauro and Akira; I also took the liberty of dropping in my 'messy diffstat' document" * tag 'docs-5.18-2' of git://git.lwn.net/linux: docs: Add a document on how to fix a messy diffstat docs: sphinx/requirements: Limit jinja2<3.1 Documentation: kunit: Fix cross-referencing warnings scripts/kernel-doc: change the line number meta info scripts/get_abi: change the file/line number meta info docs: kernel_include.py: add sphinx build dependencies docs: kernel_abi.py: add sphinx build dependencies docs: kernel_feat.py: add build dependencies scripts/get_feat.pl: allow output the parsed file names docs: kfigure.py: Don't warn of missing PDF converter in 'make htmldocs' Documentation: Fix duplicate statement about raw_spinlock_t type
2 parents b8321ed + 022bb49 commit b4a5ea0

13 files changed

Lines changed: 148 additions & 25 deletions

File tree

Documentation/dev-tools/kunit/architecture.rst

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,7 @@ The fundamental unit in KUnit is the test case. The KUnit test cases are
2626
grouped into KUnit suites. A KUnit test case is a function with type
2727
signature ``void (*)(struct kunit *test)``.
2828
These test case functions are wrapped in a struct called
29-
``struct kunit_case``. For code, see:
30-
31-
.. kernel-doc:: include/kunit/test.h
32-
:identifiers: kunit_case
29+
struct kunit_case.
3330

3431
.. note:
3532
``generate_params`` is optional for non-parameterized tests.
@@ -152,18 +149,12 @@ Parameterized Tests
152149
Each KUnit parameterized test is associated with a collection of
153150
parameters. The test is invoked multiple times, once for each parameter
154151
value and the parameter is stored in the ``param_value`` field.
155-
The test case includes a ``KUNIT_CASE_PARAM()`` macro that accepts a
152+
The test case includes a KUNIT_CASE_PARAM() macro that accepts a
156153
generator function.
157154
The generator function is passed the previous parameter and returns the next
158155
parameter. It also provides a macro to generate common-case generators based on
159156
arrays.
160157

161-
For code, see:
162-
163-
.. kernel-doc:: include/kunit/test.h
164-
:identifiers: KUNIT_ARRAY_PARAM
165-
166-
167158
kunit_tool (Command Line Test Harness)
168159
======================================
169160

Documentation/locking/locktypes.rst

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -211,9 +211,6 @@ raw_spinlock_t and spinlock_t
211211
raw_spinlock_t
212212
--------------
213213

214-
raw_spinlock_t is a strict spinning lock implementation regardless of the
215-
kernel configuration including PREEMPT_RT enabled kernels.
216-
217214
raw_spinlock_t is a strict spinning lock implementation in all kernels,
218215
including PREEMPT_RT kernels. Use raw_spinlock_t only in real critical
219216
core code, low-level interrupt handling and places where disabling

Documentation/maintainer/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ additions to this manual.
1212
configure-git
1313
rebasing-and-merging
1414
pull-requests
15+
messy-diffstat
1516
maintainer-entry-profile
1617
modifying-patches
1718

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
.. SPDX-License-Identifier: GPL-2.0
2+
3+
=====================================
4+
Handling messy pull-request diffstats
5+
=====================================
6+
7+
Subsystem maintainers routinely use ``git request-pull`` as part of the
8+
process of sending work upstream. Normally, the result includes a nice
9+
diffstat that shows which files will be touched and how much of each will
10+
be changed. Occasionally, though, a repository with a relatively
11+
complicated development history will yield a massive diffstat containing a
12+
great deal of unrelated work. The result looks ugly and obscures what the
13+
pull request is actually doing. This document describes what is happening
14+
and how to fix things up; it is derived from The Wisdom of Linus Torvalds,
15+
found in Linus1_ and Linus2_.
16+
17+
.. _Linus1: https://lore.kernel.org/lkml/CAHk-=wg3wXH2JNxkQi+eLZkpuxqV+wPiHhw_Jf7ViH33Sw7PHA@mail.gmail.com/
18+
.. _Linus2: https://lore.kernel.org/lkml/CAHk-=wgXbSa8yq8Dht8at+gxb_idnJ7X5qWZQWRBN4_CUPr=eQ@mail.gmail.com/
19+
20+
A Git development history proceeds as a series of commits. In a simplified
21+
manner, mainline kernel development looks like this::
22+
23+
... vM --- vN-rc1 --- vN-rc2 --- vN-rc3 --- ... --- vN-rc7 --- vN
24+
25+
If one wants to see what has changed between two points, a command like
26+
this will do the job::
27+
28+
$ git diff --stat --summary vN-rc2..vN-rc3
29+
30+
Here, there are two clear points in the history; Git will essentially
31+
"subtract" the beginning point from the end point and display the resulting
32+
differences. The requested operation is unambiguous and easy enough to
33+
understand.
34+
35+
When a subsystem maintainer creates a branch and commits changes to it, the
36+
result in the simplest case is a history that looks like::
37+
38+
... vM --- vN-rc1 --- vN-rc2 --- vN-rc3 --- ... --- vN-rc7 --- vN
39+
|
40+
+-- c1 --- c2 --- ... --- cN
41+
42+
If that maintainer now uses ``git diff`` to see what has changed between
43+
the mainline branch (let's call it "linus") and cN, there are still two
44+
clear endpoints, and the result is as expected. So a pull request
45+
generated with ``git request-pull`` will also be as expected. But now
46+
consider a slightly more complex development history::
47+
48+
... vM --- vN-rc1 --- vN-rc2 --- vN-rc3 --- ... --- vN-rc7 --- vN
49+
| |
50+
| +-- c1 --- c2 --- ... --- cN
51+
| /
52+
+-- x1 --- x2 --- x3
53+
54+
Our maintainer has created one branch at vN-rc1 and another at vN-rc2; the
55+
two were then subsequently merged into c2. Now a pull request generated
56+
for cN may end up being messy indeed, and developers often end up wondering
57+
why.
58+
59+
What is happening here is that there are no longer two clear end points for
60+
the ``git diff`` operation to use. The development culminating in cN
61+
started in two different places; to generate the diffstat, ``git diff``
62+
ends up having pick one of them and hoping for the best. If the diffstat
63+
starts at vN-rc1, it may end up including all of the changes between there
64+
and the second origin end point (vN-rc2), which is certainly not what our
65+
maintainer had in mind. With all of that extra junk in the diffstat, it
66+
may be impossible to tell what actually happened in the changes leading up
67+
to cN.
68+
69+
Maintainers often try to resolve this problem by, for example, rebasing the
70+
branch or performing another merge with the linus branch, then recreating
71+
the pull request. This approach tends not to lead to joy at the receiving
72+
end of that pull request; rebasing and/or merging just before pushing
73+
upstream is a well-known way to get a grumpy response.
74+
75+
So what is to be done? The best response when confronted with this
76+
situation is to indeed to do a merge with the branch you intend your work
77+
to be pulled into, but to do it privately, as if it were the source of
78+
shame. Create a new, throwaway branch and do the merge there::
79+
80+
... vM --- vN-rc1 --- vN-rc2 --- vN-rc3 --- ... --- vN-rc7 --- vN
81+
| | |
82+
| +-- c1 --- c2 --- ... --- cN |
83+
| / | |
84+
+-- x1 --- x2 --- x3 +------------+-- TEMP
85+
86+
The merge operation resolves all of the complications resulting from the
87+
multiple beginning points, yielding a coherent result that contains only
88+
the differences from the mainline branch. Now it will be possible to
89+
generate a diffstat with the desired information::
90+
91+
$ git diff -C --stat --summary linus..TEMP
92+
93+
Save the output from this command, then simply delete the TEMP branch;
94+
definitely do not expose it to the outside world. Take the saved diffstat
95+
output and edit it into the messy pull request, yielding a result that
96+
shows what is really going on. That request can then be sent upstream.

Documentation/sphinx/kernel_abi.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@ def runCmd(self, cmd, **kwargs):
128128
return out
129129

130130
def nestedParse(self, lines, fname):
131+
env = self.state.document.settings.env
131132
content = ViewList()
132133
node = nodes.section()
133134

@@ -137,7 +138,7 @@ def nestedParse(self, lines, fname):
137138
code_block += "\n " + l
138139
lines = code_block + "\n\n"
139140

140-
line_regex = re.compile("^#define LINENO (\S+)\#([0-9]+)$")
141+
line_regex = re.compile("^\.\. LINENO (\S+)\#([0-9]+)$")
141142
ln = 0
142143
n = 0
143144
f = fname
@@ -154,6 +155,9 @@ def nestedParse(self, lines, fname):
154155
self.do_parse(content, node)
155156
content = ViewList()
156157

158+
# Add the file to Sphinx build dependencies
159+
env.note_dependency(os.path.abspath(f))
160+
157161
f = new_f
158162

159163
# sphinx counts lines from 0

Documentation/sphinx/kernel_feat.py

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333

3434
import codecs
3535
import os
36+
import re
3637
import subprocess
3738
import sys
3839

@@ -82,7 +83,7 @@ def run(self):
8283

8384
env = doc.settings.env
8485
cwd = path.dirname(doc.current_source)
85-
cmd = "get_feat.pl rest --dir "
86+
cmd = "get_feat.pl rest --enable-fname --dir "
8687
cmd += self.arguments[0]
8788

8889
if len(self.arguments) > 1:
@@ -102,7 +103,22 @@ def run(self):
102103
shell_env["srctree"] = srctree
103104

104105
lines = self.runCmd(cmd, shell=True, cwd=cwd, env=shell_env)
105-
nodeList = self.nestedParse(lines, fname)
106+
107+
line_regex = re.compile("^\.\. FILE (\S+)$")
108+
109+
out_lines = ""
110+
111+
for line in lines.split("\n"):
112+
match = line_regex.search(line)
113+
if match:
114+
fname = match.group(1)
115+
116+
# Add the file to Sphinx build dependencies
117+
env.note_dependency(os.path.abspath(fname))
118+
else:
119+
out_lines += line + "\n"
120+
121+
nodeList = self.nestedParse(out_lines, fname)
106122
return nodeList
107123

108124
def runCmd(self, cmd, **kwargs):

Documentation/sphinx/kernel_include.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ class KernelInclude(Include):
5959
u"""KernelInclude (``kernel-include``) directive"""
6060

6161
def run(self):
62+
env = self.state.document.settings.env
6263
path = os.path.realpath(
6364
os.path.expandvars(self.arguments[0]))
6465

@@ -70,6 +71,8 @@ def run(self):
7071

7172
self.arguments[0] = path
7273

74+
env.note_dependency(os.path.abspath(path))
75+
7376
#return super(KernelInclude, self).run() # won't work, see HINTs in _run()
7477
return self._run()
7578

Documentation/sphinx/kerneldoc.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ def run(self):
130130
result = ViewList()
131131

132132
lineoffset = 0;
133-
line_regex = re.compile("^#define LINENO ([0-9]+)$")
133+
line_regex = re.compile("^\.\. LINENO ([0-9]+)$")
134134
for line in lines:
135135
match = line_regex.search(line)
136136
if match:

Documentation/sphinx/kfigure.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ def setupTools(app):
212212
if convert_cmd:
213213
kernellog.verbose(app, "use convert(1) from: " + convert_cmd)
214214
else:
215-
kernellog.warn(app,
215+
kernellog.verbose(app,
216216
"Neither inkscape(1) nor convert(1) found.\n"
217217
"For SVG to PDF conversion, "
218218
"install either Inkscape (https://inkscape.org/) (preferred) or\n"
@@ -296,8 +296,10 @@ def convert_image(img_node, translator, src_fname=None):
296296

297297
if translator.builder.format == 'latex':
298298
if not inkscape_cmd and convert_cmd is None:
299-
kernellog.verbose(app,
300-
"no SVG to PDF conversion available / include SVG raw.")
299+
kernellog.warn(app,
300+
"no SVG to PDF conversion available / include SVG raw."
301+
"\nIncluding large raw SVGs can cause xelatex error."
302+
"\nInstall Inkscape (preferred) or ImageMagick.")
301303
img_node.replace_self(file2literal(src_fname))
302304
else:
303305
dst_fname = path.join(translator.builder.outdir, fname + '.pdf')
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
1+
# jinja2>=3.1 is not compatible with Sphinx<4.0
2+
jinja2<3.1
13
sphinx_rtd_theme
24
Sphinx==2.4.4

0 commit comments

Comments
 (0)