Skip to content

Commit 8376093

Browse files
committed
Merge branch 'jc/doc-log-messages'
Update the contributor-facing documents on proposed log messages. * jc/doc-log-messages: SubmittingPatches: explain why we care about log messages CodingGuidelines: hint why we value clearly written log messages SubmittingPatches: write problem statement in the log in the present tense
2 parents 03bdcfc + cdba029 commit 8376093

File tree

2 files changed

+43
-0
lines changed

2 files changed

+43
-0
lines changed

Documentation/CodingGuidelines

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,13 @@ code. For Git in general, a few rough rules are:
2626
go and fix it up."
2727
Cf. http://lkml.iu.edu/hypermail/linux/kernel/1001.3/01069.html
2828

29+
- Log messages to explain your changes are as important as the
30+
changes themselves. Clearly written code and in-code comments
31+
explain how the code works and what is assumed from the surrounding
32+
context. The log messages explain what the changes wanted to
33+
achieve and why the changes were necessary (more on this in the
34+
accompanying SubmittingPatches document).
35+
2936
Make your code readable and sensible, and don't try to be clever.
3037

3138
As for more concrete guidelines, just imitate the existing code

Documentation/SubmittingPatches

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,35 @@ run `git diff --check` on your changes before you commit.
110110
[[describe-changes]]
111111
=== Describe your changes well.
112112

113+
The log message that explains your changes is just as important as the
114+
changes themselves. Your code may be clearly written with in-code
115+
comment to sufficiently explain how it works with the surrounding
116+
code, but those who need to fix or enhance your code in the future
117+
will need to know _why_ your code does what it does, for a few
118+
reasons:
119+
120+
. Your code may be doing something differently from what you wanted it
121+
to do. Writing down what you actually wanted to achieve will help
122+
them fix your code and make it do what it should have been doing
123+
(also, you often discover your own bugs yourself, while writing the
124+
log message to summarize the thought behind it).
125+
126+
. Your code may be doing things that were only necessary for your
127+
immediate needs (e.g. "do X to directories" without implementing or
128+
even designing what is to be done on files). Writing down why you
129+
excluded what the code does not do will help guide future developers.
130+
Writing down "we do X to directories, because directories have
131+
characteristic Y" would help them infer "oh, files also have the same
132+
characteristic Y, so perhaps doing X to them would also make sense?".
133+
Saying "we don't do the same X to files, because ..." will help them
134+
decide if the reasoning is sound (in which case they do not waste
135+
time extending your code to cover files), or reason differently (in
136+
which case, they can explain why they extend your code to cover
137+
files, too).
138+
139+
The goal of your log message is to convey the _why_ behind your
140+
change to help future developers.
141+
113142
The first line of the commit message should be a short description (50
114143
characters is the soft limit, see DISCUSSION in linkgit:git-commit[1]),
115144
and should skip the full stop. It is also conventional in most cases to
@@ -142,6 +171,13 @@ The body should provide a meaningful commit message, which:
142171

143172
. alternate solutions considered but discarded, if any.
144173

174+
[[present-tense]]
175+
The problem statement that describes the status quo is written in the
176+
present tense. Write "The code does X when it is given input Y",
177+
instead of "The code used to do Y when given input X". You do not
178+
have to say "Currently"---the status quo in the problem statement is
179+
about the code _without_ your change, by project convention.
180+
145181
[[imperative-mood]]
146182
Describe your changes in imperative mood, e.g. "make xyzzy do frotz"
147183
instead of "[This patch] makes xyzzy do frotz" or "[I] changed xyzzy

0 commit comments

Comments
 (0)