]> git.ipfire.org Git - thirdparty/git.git/blame - Documentation/SubmittingPatches
Git 2.52-rc1
[thirdparty/git.git] / Documentation / SubmittingPatches
CommitLineData
049e64aa 1Submitting Patches
2==================
3
4== Guidelines
5
fc0825d5
LA
6Here are some guidelines for contributing back to this
7project. There is also a link:MyFirstContribution.html[step-by-step tutorial]
b75a2199 8available which covers many of these same guidelines.
31408251 9
d58848fb 10[[patch-flow]]
120adc7d 11=== A typical life cycle of a patch series
d58848fb 12
120adc7d
JH
13To help us understand the reason behind various guidelines given later
14in the document, first let's understand how the life cycle of a
15typical patch series for this project goes.
d58848fb 16
120adc7d
JH
17. You come up with an itch. You code it up. You do not need any
18 pre-authorization from the project to do so.
19+
20Your patches will be reviewed by other contributors on the mailing
21list, and the reviews will be done to assess the merit of various
22things, like the general idea behind your patch (including "is it
23solving a problem worth solving in the first place?"), the reason
24behind the design of the solution, and the actual implementation.
25The guidelines given here are there to help your patches by making
26them easier to understand by the reviewers.
27
28. You send the patches to the list and cc people who may need to know
29 about the change. Your goal is *not* necessarily to convince others
30 that what you are building is good. Your goal is to get help in
31 coming up with a solution for the "itch" that is better than what
32 you can build alone.
d58848fb 33+
120adc7d
JH
34The people who may need to know are the ones who worked on the code
35you are touching. These people happen to be the ones who are
d58848fb 36most likely to be knowledgeable enough to help you, but
120adc7d
JH
37they have no obligation to help you (i.e. you ask them for help,
38you don't demand). +git log -p {litdd} _$area_you_are_modifying_+ would
d58848fb
JH
39help you find out who they are.
40
120adc7d
JH
41. You get comments and suggestions for improvements. You may even get
42 them in an "on top of your change" patch form. You are expected to
43 respond to them with "Reply-All" on the mailing list, while taking
44 them into account while preparing an updated set of patches.
45
46. Polish, refine, and re-send your patches to the list and to the people
47 who spent their time to improve your patch. Go back to step (2).
48
49. While the above iterations improve your patches, the maintainer may
50 pick the patches up from the list and queue them to the `seen`
51 branch, in order to make it easier for people to play with it
52 without having to pick up and apply the patches to their trees
53 themselves. Being in `seen` has no other meaning. Specifically, it
54 does not mean the patch was "accepted" in any way.
55
56. When the discussion reaches a consensus that the latest iteration of
57 the patches are in good enough shape, the maintainer includes the
58 topic in the "What's cooking" report that are sent out a few times a
59 week to the mailing list, marked as "Will merge to 'next'." This
60 decision is primarily made by the maintainer with help from those
61 who participated in the review discussion.
62
63. After the patches are merged to the 'next' branch, the discussion
64 can still continue to further improve them by adding more patches on
65 top, but by the time a topic gets merged to 'next', it is expected
66 that everybody agrees that the scope and the basic direction of the
67 topic are appropriate, so such an incremental updates are limited to
68 small corrections and polishing. After a topic cooks for some time
69 (like 7 calendar days) in 'next' without needing further tweaks on
70 top, it gets merged to the 'master' branch and wait to become part
71 of the next major release.
72
73In the following sections, many techniques and conventions are listed
74to help your patches get reviewed effectively in such a life cycle.
d58848fb 75
d58848fb 76
b5dbfe28
LA
77[[choose-starting-point]]
78=== Choose a starting point.
d0c26f0f 79
0a02ca23
LA
80As a preliminary step, you must first choose a starting point for your
81work. Typically this means choosing a branch, although technically
82speaking it is actually a particular commit (typically the HEAD, or tip,
83of the branch).
84
85There are several important branches to be aware of. Namely, there are
86four integration branches as discussed in linkgit:gitworkflows[7]:
87
88* maint
89* master
90* next
91* seen
92
93The branches lower on the list are typically descendants of the ones
94that come before it. For example, `maint` is an "older" branch than
95`master` because `master` usually has patches (commits) on top of
96`maint`.
97
98There are also "topic" branches, which contain work from other
99contributors. Topic branches are created by the Git maintainer (in
100their fork) to organize the current set of incoming contributions on
101the mailing list, and are itemized in the regular "What's cooking in
102git.git" announcements. To find the tip of a topic branch, run `git log
103--first-parent master..seen` and look for the merge commit. The second
104parent of this commit is the tip of the topic branch.
105
106There is one guiding principle for choosing the right starting point: in
107general, always base your work on the oldest integration branch that
108your change is relevant to (see "Merge upwards" in
109linkgit:gitworkflows[7]). What this principle means is that for the
110vast majority of cases, the starting point for new work should be the
111latest HEAD commit of `maint` or `master` based on the following cases:
112
113* If you are fixing bugs in the released version, use `maint` as the
114 starting point (which may mean you have to fix things without using
115 new API features on the cutting edge that recently appeared in
369998df 116 `master` but were not available in the released version).
0a02ca23
LA
117
118* Otherwise (such as if you are adding new features) use `master`.
119
369998df
JH
120
121NOTE: In exceptional cases, a bug that was introduced in an old
122version may have to be fixed for users of releases that are much older
123than the recent releases. `git describe --contains X` may describe
124`X` as `v2.30.0-rc2-gXXXXXX` for the commit `X` that introduced the
125bug, and the bug may be so high-impact that we may need to issue a new
126maintenance release for Git 2.30.x series, when "Git 2.41.0" is the
127current release. In such a case, you may want to use the tip of the
128maintenance branch for the 2.30.x series, which may be available in the
129`maint-2.30` branch in https://github.com/gitster/git[the maintainer's
130"broken out" repo].
131
0a02ca23
LA
132This also means that `next` or `seen` are inappropriate starting points
133for your work, if you want your work to have a realistic chance of
f835de52
JH
134graduating to `master`. They are simply not designed to be used as a
135base for new work; they are only there to make sure that topics in
136flight work well together. This is why both `next` and `seen` are
137frequently re-integrated with incoming patches on the mailing list and
138force-pushed to replace previous versions of themselves. A topic that is
139literally built on top of `next` cannot be merged to `master` without
140dragging in all the other topics in `next`, some of which may not be
141ready.
0a02ca23
LA
142
143For example, if you are making tree-wide changes, while somebody else is
144also making their own tree-wide changes, your work may have severe
145overlap with the other person's work. This situation may tempt you to
146use `next` as your starting point (because it would have the other
147person's work included in it), but doing so would mean you'll not only
148depend on the other person's work, but all the other random things from
149other contributors that are already integrated into `next`. And as soon
150as `next` is updated with a new version, all of your work will need to
151be rebased anyway in order for them to be cleanly applied by the
152maintainer.
153
154Under truly exceptional circumstances where you absolutely must depend
155on a select few topic branches that are already in `next` but not in
156`master`, you may want to create your own custom base-branch by forking
9a9fd289 157`master` and merging the required topic branches into it. You could then
0a02ca23
LA
158work on top of this base-branch. But keep in mind that this base-branch
159would only be known privately to you. So when you are ready to send
160your patches to the list, be sure to communicate how you created it in
161your cover letter. This critical piece of information would allow
162others to recreate your base-branch on their end in order for them to
163try out your work.
31408251 164
3423e372
LA
165Finally, note that some parts of the system have dedicated maintainers
166with their own separate source code repositories (see the section
167"Subsystems" below).
168
049e64aa 169[[separate-commits]]
170=== Make separate commits for logically separate changes.
31408251
JH
171
172Unless your patch is really trivial, you should not be sending
173out a patch that was generated between your working tree and
174your commit head. Instead, always make a commit with complete
175commit message and generate a series of patches from your
176repository. It is a good discipline.
177
d0f7dcbf
JH
178Give an explanation for the change(s) that is detailed enough so
179that people can judge if it is good thing to do, without reading
180the actual patch text to determine how well the code does what
181the explanation promises to do.
31408251 182
45d2b286 183If your description starts to get too long, that's a sign that you
31408251 184probably need to split up your commit to finer grained pieces.
47afed5d
SV
185That being said, patches which plainly describe the things that
186help reviewers check the patch, and future maintainers understand
01e60a9a 187the code, are the most beautiful patches. Descriptions that summarize
47afed5d
SV
188the point in the subject well, and describe the motivation for the
189change, the approach taken by the change, and if relevant how this
d0f7dcbf
JH
190differs substantially from the prior version, are all good things
191to have.
31408251 192
54cc5d29 193Make sure that you have tests for the bug you are fixing. See
049e64aa 194`t/README` for guidance.
7d5bf87b 195
049e64aa 196[[tests]]
7d5bf87b 197When adding a new feature, make sure that you have new tests to show
0e5d028a 198the feature triggers the new behavior when it should, and to show the
fdfae830
JH
199feature does not trigger when it shouldn't. After any code change,
200make sure that the entire test suite passes. When fixing a bug, make
201sure you have new tests that break if somebody else breaks what you
202fixed by accident to avoid regression. Also, try merging your work to
203'next' and 'seen' and make sure the tests still pass; topics by others
204that are still in flight may have unexpected interactions with what
205you are trying to do in your topic.
0e5d028a 206
f003a91f
ÆAB
207Pushing to a fork of https://github.com/git/git will use their CI
208integration to test your changes on Linux, Mac and Windows. See the
209<<GHCI,GitHub CI>> section for details.
0e5d028a
LS
210
211Do not forget to update the documentation to describe the updated
212behavior and make sure that the resulting documentation set formats
7a76f5c6
JK
213well (try the Documentation/doc-diff script).
214
215We currently have a liberal mixture of US and UK English norms for
0e5d028a
LS
216spelling and grammar, which is somewhat unfortunate. A huge patch that
217touches the files all over the place only to correct the inconsistency
218is not welcome, though. Potential clashes with other changes that can
219result from such a patch are not worth it. We prefer to gradually
220reconcile the inconsistencies in favor of US English, with small and
221easily digestible patches, as a side effect of doing some other real
222work in the vicinity (e.g. rewriting a paragraph for clarity, while
223turning en_UK spelling to en_US). Obvious typographical fixes are much
224more welcomed ("teh -> "the"), preferably submitted as independent
225patches separate from other documentation changes.
42e0fae9 226
049e64aa 227[[whitespace-check]]
42e0fae9 228Oh, another thing. We are picky about whitespaces. Make sure your
45d2b286 229changes do not trigger errors with the sample pre-commit hook shipped
049e64aa 230in `templates/hooks--pre-commit`. To help ensure this does not happen,
231run `git diff --check` on your changes before you commit.
31408251 232
049e64aa 233[[describe-changes]]
234=== Describe your changes well.
7d5bf87b 235
cdba0295
JH
236The log message that explains your changes is just as important as the
237changes themselves. Your code may be clearly written with in-code
238comment to sufficiently explain how it works with the surrounding
239code, but those who need to fix or enhance your code in the future
240will need to know _why_ your code does what it does, for a few
241reasons:
242
243. Your code may be doing something differently from what you wanted it
244 to do. Writing down what you actually wanted to achieve will help
245 them fix your code and make it do what it should have been doing
246 (also, you often discover your own bugs yourself, while writing the
247 log message to summarize the thought behind it).
248
249. Your code may be doing things that were only necessary for your
250 immediate needs (e.g. "do X to directories" without implementing or
251 even designing what is to be done on files). Writing down why you
252 excluded what the code does not do will help guide future developers.
253 Writing down "we do X to directories, because directories have
254 characteristic Y" would help them infer "oh, files also have the same
255 characteristic Y, so perhaps doing X to them would also make sense?".
256 Saying "we don't do the same X to files, because ..." will help them
257 decide if the reasoning is sound (in which case they do not waste
258 time extending your code to cover files), or reason differently (in
259 which case, they can explain why they extend your code to cover
260 files, too).
261
120adc7d
JH
262The goal of your log message is to convey the _why_ behind your change
263to help future developers. The reviewers will also make sure that
264your proposed log message will serve this purpose well.
cdba0295 265
7d5bf87b 266The first line of the commit message should be a short description (50
049e64aa 267characters is the soft limit, see DISCUSSION in linkgit:git-commit[1]),
268and should skip the full stop. It is also conventional in most cases to
7d5bf87b
JH
269prefix the first line with "area: " where the area is a filename or
270identifier for the general area of the code being modified, e.g.
271
049e64aa 272* doc: clarify distinction between sign-off and pgp-signing
273* githooks.txt: improve the intro section
7d5bf87b 274
049e64aa 275If in doubt which identifier to use, run `git log --no-merges` on the
7d5bf87b
JH
276files you are modifying to see the current conventions.
277
049e64aa 278[[summary-section]]
151b6c2d 279The title sentence after the "area:" prefix omits the full stop at the
3991bb73
JH
280end, and its first word is not capitalized (the omission
281of capitalization applies only to the word after the "area:"
282prefix of the title) unless there is a reason to
151b6c2d
JH
283capitalize it other than because it is the first word in the sentence.
284E.g. "doc: clarify...", not "doc: Clarify...", or "githooks.txt:
285improve...", not "githooks.txt: Improve...". But "refs: HEAD is also
286treated as a ref" is correct, as we spell `HEAD` in all caps even when
287it appears in the middle of a sentence.
2ee00567 288
049e64aa 289[[meaningful-message]]
7d5bf87b
JH
290The body should provide a meaningful commit message, which:
291
049e64aa 292. explains the problem the change tries to solve, i.e. what is wrong
293 with the current code without the change.
7d5bf87b 294
049e64aa 295. justifies the way the change solves the problem, i.e. why the
296 result with the change is better.
7d5bf87b 297
049e64aa 298. alternate solutions considered but discarded, if any.
7d5bf87b 299
fa1101af
JH
300[[present-tense]]
301The problem statement that describes the status quo is written in the
302present tense. Write "The code does X when it is given input Y",
303instead of "The code used to do Y when given input X". You do not
304have to say "Currently"---the status quo in the problem statement is
305about the code _without_ your change, by project convention.
306
049e64aa 307[[imperative-mood]]
7d5bf87b
JH
308Describe your changes in imperative mood, e.g. "make xyzzy do frotz"
309instead of "[This patch] makes xyzzy do frotz" or "[I] changed xyzzy
310to do frotz", as if you are giving orders to the codebase to change
01e60a9a 311its behavior. Try to make sure your explanation can be understood
7d5bf87b
JH
312without external resources. Instead of giving a URL to a mailing list
313archive, summarize the relevant points of the discussion.
314
049e64aa 315[[commit-reference]]
fdfae830
JH
316
317There are a few reasons why you may want to refer to another commit in
318the "more stable" part of the history (i.e. on branches like `maint`,
319`master`, and `next`):
320
321. A commit that introduced the root cause of a bug you are fixing.
322
323. A commit that introduced a feature that you are enhancing.
324
325. A commit that conflicts with your work when you made a trial merge
326 of your work into `next` and `seen` for testing.
327
328When you reference a commit on a more stable branch (like `master`,
329`maint` and `next`), use the format "abbreviated hash (subject,
330date)", like this:
4369523b 331
049e64aa 332....
fb2ffa77 333 Commit f86a374 (pack-bitmap.c: fix a memleak, 2015-03-30)
049e64aa 334 noticed that ...
335....
4369523b 336
d15b8539 337The "Copy commit reference" command of gitk can be used to obtain this
fb2ffa77
DL
338format (with the subject enclosed in a pair of double-quotes), or this
339invocation of `git show`:
175d38ca 340
049e64aa 341....
3798149a
DL
342 git show -s --pretty=reference <commit>
343....
344
345or, on an older version of Git without support for --pretty=reference:
346
049e64aa 347....
fb2ffa77 348 git show -s --date=short --pretty='format:%h (%s, %ad)' <commit>
049e64aa 349....
7d5bf87b 350
4523dc86
ÆAB
351[[sign-off]]
352=== Certify your work by adding your `Signed-off-by` trailer
353
354To improve tracking of who did what, we ask you to certify that you
355wrote the patch or have the right to pass it on under the same license
356as ours, by "signing off" your patch. Without sign-off, we cannot
357accept your patches.
358
359If (and only if) you certify the below D-C-O:
360
361[[dco]]
362.Developer's Certificate of Origin 1.1
363____
364By making a contribution to this project, I certify that:
365
366a. The contribution was created in whole or in part by me and I
367 have the right to submit it under the open source license
368 indicated in the file; or
369
370b. The contribution is based upon previous work that, to the best
371 of my knowledge, is covered under an appropriate open source
372 license and I have the right under that license to submit that
373 work with modifications, whether created in whole or in part
374 by me, under the same open source license (unless I am
375 permitted to submit under a different license), as indicated
376 in the file; or
377
378c. The contribution was provided directly to me by some other
379 person who certified (a), (b) or (c) and I have not modified
380 it.
381
382d. I understand and agree that this project and the contribution
383 are public and that a record of the contribution (including all
384 personal information I submit with it, including my sign-off) is
385 maintained indefinitely and may be redistributed consistent with
386 this project or the open source license(s) involved.
387____
388
389you add a "Signed-off-by" trailer to your commit, that looks like
390this:
391
392....
393 Signed-off-by: Random J Developer <random@developer.example.org>
394....
395
396This line can be added by Git if you run the git-commit command with
397the -s option.
398
399Notice that you can place your own `Signed-off-by` trailer when
400forwarding somebody else's patch with the above rules for
401D-C-O. Indeed you are encouraged to do so. Do not forget to
402place an in-body "From: " line at the beginning to properly attribute
403the change to its true author (see (2) above).
404
405This procedure originally came from the Linux kernel project, so our
406rule is quite similar to theirs, but what exactly it means to sign-off
407your patch differs from project to project, so it may be different
408from that of the project you are accustomed to.
409
410[[real-name]]
1f0fed31 411Please use a known identity in the `Signed-off-by` trailer, since we cannot
412accept anonymous contributions. It is common, but not required, to use some form
413of your real name. We realize that some contributors are not comfortable doing
414so or prefer to contribute under a pseudonym or preferred name and we can accept
415your patch either way, as long as the name and email you use are distinctive,
416identifying, and not misleading.
417
418The goal of this policy is to allow us to have sufficient information to contact
419you if questions arise about your contribution.
4523dc86
ÆAB
420
421[[commit-trailers]]
52acf677 422If you like, you can put extra trailers at the end:
4523dc86
ÆAB
423
424. `Reported-by:` is used to credit someone who found the bug that
425 the patch attempts to fix.
426. `Acked-by:` says that the person who is more familiar with the area
427 the patch attempts to modify liked the patch.
52acf677 428. `Reviewed-by:`, unlike the other trailers, can only be offered by the
4523dc86
ÆAB
429 reviewers themselves when they are completely satisfied with the
430 patch after a detailed analysis.
431. `Tested-by:` is used to indicate that the person applied the patch
432 and found it to have the desired effect.
c771ef6f
JS
433. `Co-authored-by:` is used to indicate that people exchanged drafts
434 of a patch before submitting it.
435. `Helped-by:` is used to credit someone who suggested ideas for
436 changes without providing the precise changes in patch form.
437. `Mentored-by:` is used to credit someone with helping develop a
438 patch as part of a mentorship program (e.g., GSoC or Outreachy).
439. `Suggested-by:` is used to credit someone with suggesting the idea
440 for a patch.
4523dc86 441
ac9fff2b
JS
442While you can also create your own trailer if the situation warrants it, we
443encourage you to instead use one of the common trailers in this project
444highlighted above.
4523dc86 445
52acf677 446Only capitalize the very first letter of the trailer, i.e. favor
08e2e6f8
JS
447"Signed-off-by" over "Signed-Off-By" and "Acked-by:" over "Acked-By".
448
7b0c3795
CC
449[[ai]]
450=== Use of Artificial Intelligence (AI)
451
452The Developer's Certificate of Origin requires contributors to certify
453that they know the origin of their contributions to the project and
454that they have the right to submit it under the project's license.
455It's not yet clear that this can be legally satisfied when submitting
456significant amount of content that has been generated by AI tools.
457
458Another issue with AI generated content is that AIs still often
459hallucinate or just produce bad code, commit messages, documentation
460or output, even when you point out their mistakes.
461
462To avoid these issues, we will reject anything that looks AI
463generated, that sounds overly formal or bloated, that looks like AI
464slop, that looks good on the surface but makes no sense, or that
465senders don’t understand or cannot explain.
466
467We strongly recommend using AI tools carefully and responsibly.
468
469Contributors would often benefit more from AI by using it to guide and
470help them step by step towards producing a solution by themselves
471rather than by asking for a full solution that they would then mostly
472copy-paste. They can also use AI to help with debugging, or with
473checking for obvious mistakes, things that can be improved, things
474that don’t match our style, guidelines or our feedback, before sending
475it to us.
476
049e64aa 477[[git-tools]]
478=== Generate your patch using Git tools out of your commits.
45d2b286 479
2de9b711 480Git based diff tools generate unidiff which is the preferred format.
45d2b286 481
049e64aa 482You do not have to be afraid to use `-M` option to `git diff` or
483`git format-patch`, if your patch involves file renames. The
31408251
JH
484receiving end can handle them just fine.
485
049e64aa 486[[review-patch]]
7d5bf87b
JH
487Please make sure your patch does not add commented out debugging code,
488or include any extra files which do not relate to what your patch
489is trying to achieve. Make sure to review
31408251 490your patch after generating it, to ensure accuracy. Before
b5dbfe28 491sending out, please make sure it cleanly applies to the starting point you
5c98149c
LA
492have chosen in the "Choose a starting point" section.
493
494NOTE: From the perspective of those reviewing your patch, the `master`
495branch is the default expected starting point. So if you have chosen a
496different starting point, please communicate this choice in your cover
497letter.
fdfae830 498
31408251 499
049e64aa 500[[send-patches]]
501=== Sending your patches.
31408251 502
e2663c45
LA
503==== Choosing your reviewers
504
2a00502b
TG
505:security-ml: footnoteref:[security-ml,The Git Security mailing list: git-security@googlegroups.com]
506
01ea2b28 507NOTE: Patches that may be
2a00502b
TG
508security relevant should be submitted privately to the Git Security
509mailing list{security-ml}, instead of the public mailing list.
510
e2663c45
LA
511:contrib-scripts: footnoteref:[contrib-scripts,Scripts under `contrib/` are +
512not part of the core `git` binary and must be called directly. Clone the Git +
513codebase and run `perl contrib/contacts/git-contacts`.]
514
515Send your patch with "To:" set to the mailing list, with "cc:" listing
516people who are involved in the area you are touching (the `git-contacts`
517script in `contrib/contacts/`{contrib-scripts} can help to
518identify them), to solicit comments and reviews. Also, when you made
519trial merges of your topic to `next` and `seen`, you may have noticed
520work by others conflicting with your changes. There is a good possibility
521that these people may know the area you are touching well.
522
61e124bb
LA
523If you are using `send-email`, you can feed it the output of `git-contacts` like
524this:
525
526....
527 git send-email --cc-cmd='perl contrib/contacts/git-contacts' feature/*.patch
528....
529
e2663c45
LA
530:current-maintainer: footnote:[The current maintainer: gitster@pobox.com]
531:git-ml: footnote:[The mailing list: git@vger.kernel.org]
532
533After the list reached a consensus that it is a good idea to apply the
534patch, re-send it with "To:" set to the maintainer{current-maintainer}
535and "cc:" the list{git-ml} for inclusion. This is especially relevant
536when the maintainer did not heavily participate in the discussion and
537instead left the review to trusted others.
538
539Do not forget to add trailers such as `Acked-by:`, `Reviewed-by:` and
540`Tested-by:` lines as necessary to credit people who helped your
541patch, and "cc:" them when sending such a final version for inclusion.
542
bf966145
LA
543==== `format-patch` and `send-email`
544
c8d6a54a 545Learn to use `format-patch` and `send-email` if possible. These commands
b25c4699 546are optimized for the workflow of sending patches, avoiding many ways
97509a34
ŠN
547your existing e-mail client (often optimized for "multipart/*" MIME
548type e-mails) might render your patches unusable.
b25c4699 549
84b91fc4
LA
550NOTE: Here we outline the procedure using `format-patch` and
551`send-email`, but you can instead use GitGitGadget to send in your
552patches (see link:MyFirstContribution.html[MyFirstContribution]).
553
2de9b711 554People on the Git mailing list need to be able to read and
31408251
JH
555comment on the changes you are submitting. It is important for
556a developer to be able to "quote" your changes, using standard
557e-mail tools, so that they may comment on specific portions of
eaa6c987
RS
558your code. For this reason, each patch should be submitted
559"inline" in a separate message.
560
4cf6e7bf
JT
561All subsequent versions of a patch series and other related patches should be
562grouped into their own e-mail thread to help readers find all parts of the
563series. To that end, send them as replies to either an additional "cover
564letter" message (see below), the first patch, or the respective preceding patch.
565Here is a link:MyFirstContribution.html#v2-git-send-email[step-by-step guide] on
566how to submit updated versions of a patch series.
eaa6c987
RS
567
568If your log message (including your name on the
3abd4a67 569`Signed-off-by` trailer) is not writable in ASCII, make sure that
7d5bf87b
JH
570you send off a message in the correct encoding.
571
572WARNING: Be wary of your MUAs word-wrap
45d2b286
JH
573corrupting your patch. Do not cut-n-paste your patch; you can
574lose tabs that way if you are not careful.
31408251 575
45d2b286 576It is a common convention to prefix your subject line with
31408251 577[PATCH]. This lets people easily distinguish patches from other
f6be7edc
AD
578e-mail discussions. Use of markers in addition to PATCH within
579the brackets to describe the nature of the patch is also
580encouraged. E.g. [RFC PATCH] (where RFC stands for "request for
581comments") is often used to indicate a patch needs further
582discussion before being accepted, [PATCH v2], [PATCH v3] etc.
583are often seen when you are sending an update to what you have
584previously sent.
585
1a5f2e44 586The `git format-patch` command follows the best current practice to
31408251
JH
587format the body of an e-mail message. At the beginning of the
588patch should come your commit message, ending with the
3abd4a67 589`Signed-off-by` trailers, and a line that consists of three dashes,
31408251
JH
590followed by the diffstat information and the patch itself. If
591you are forwarding a patch from somebody else, optionally, at
592the beginning of the e-mail message just before the commit
593message starts, you can put a "From: " line to name that person.
f6be7edc
AD
594To change the default "[PATCH]" in the subject to "[<text>]", use
595`git format-patch --subject-prefix=<text>`. As a shortcut, you
596can use `--rfc` instead of `--subject-prefix="RFC PATCH"`, or
597`-v <n>` instead of `--subject-prefix="PATCH v<n>"`.
31408251
JH
598
599You often want to add additional explanation about the patch,
600other than the commit message itself. Place such "cover letter"
86010993
ES
601material between the three-dash line and the diffstat. For
602patches requiring multiple iterations of review and discussion,
603an explanation of changes between each iteration can be kept in
604Git-notes and inserted automatically following the three-dash
605line via `git format-patch --notes`.
31408251 606
d255105c
JH
607[[the-topic-summary]]
608*This is EXPERIMENTAL*.
609
88144515
TB
610When sending a topic, you can optionally propose a topic name and/or a
611one-paragraph summary that should appear in the "What's cooking"
612report when it is picked up to explain the topic. If you choose to do
613so, please write a 2-5 line paragraph that will fit well in our
614release notes (see many bulleted entries in the
615Documentation/RelNotes/* files for examples), and make it the first
616(or second, if including a suggested topic name) paragraph of the
617cover letter. If suggesting a topic name, use the format
618"XX/your-topic-name", where "XX" is a stand-in for the primary
619author's initials, and "your-topic-name" is a brief, dash-delimited
620description of what your topic does. For a single-patch series, use
621the space between the three-dash line and the diffstat, as described
622earlier.
d255105c 623
1a416988
TB
624[[multi-series-efforts]]
625If your patch series is part of a larger effort spanning multiple
626patch series, briefly describe the broader goal, and state where the
627current series fits into that goal. If you are suggesting a topic
628name as in <<the-topic-summary, section above>>, consider
629"XX/the-broader-goal-part-one", "XX/the-broader-goal-part-two", and so
630on.
631
049e64aa 632[[attachment]]
31408251 633Do not attach the patch as a MIME attachment, compressed or not.
e30b217b
JH
634Do not let your e-mail client send quoted-printable. Do not let
635your e-mail client send format=flowed which would destroy
636whitespaces in your patches. Many
31408251
JH
637popular e-mail applications will not always transmit a MIME
638attachment as plain text, making it impossible to comment on
639your code. A MIME attachment also takes a bit more time to
640process. This does not decrease the likelihood of your
641MIME-attached change being accepted, but it makes it more likely
642that it will be postponed.
643
644Exception: If your mailer is mangling patches then someone may ask
9847f7e0 645you to re-send them using MIME, that is OK.
31408251 646
049e64aa 647[[pgp-signature]]
eafd5d94
CW
648Do not PGP sign your patch. Most likely, your maintainer or other people on the
649list would not have your PGP key and would not bother obtaining it anyway.
650Your patch is not judged by who you are; a good patch from an unknown origin
651has a far better chance of being accepted than a patch from a known, respected
652origin that is done poorly or does incorrect things.
9847f7e0
JH
653
654If you really really really really want to do a PGP signed
655patch, format it as "multipart/signed", not a text/plain message
049e64aa 656that starts with `-----BEGIN PGP SIGNED MESSAGE-----`. That is
9847f7e0
JH
657not a text/plain, it's something else.
658
c397ddff
KN
659=== Handling Conflicts and Iterating Patches
660
661When revising changes made to your patches, it's important to
662acknowledge the possibility of conflicts with other ongoing topics. To
663navigate these potential conflicts effectively, follow the recommended
664steps outlined below:
665
666. Build on a suitable base branch, see the <<choose-starting-point, section above>>,
667and format-patch the series. If you are doing "rebase -i" in-place to
668update from the previous round, this will reuse the previous base so
669(2) and (3) may become trivial.
670
671. Find the base of where the last round was queued
672+
673 $ mine='kn/ref-transaction-symref'
674 $ git checkout "origin/seen^{/^Merge branch '$mine'}...master"
675
676. Apply your format-patch result. There are two cases
677.. Things apply cleanly and tests fine. Go to (4).
678.. Things apply cleanly but does not build or test fails, or things do
679not apply cleanly.
680+
681In the latter case, you have textual or semantic conflicts coming from
682the difference between the old base and the base you used to build in
683(1). Identify what caused the breakages (e.g., a topic or two may have
684merged since the base used by (2) until the base used by (1)).
685+
686Check out the latest 'origin/master' (which may be newer than the base
687used by (2)), "merge --no-ff" the topics you newly depend on in there,
688and use the result of the merge(s) as the base, rebuild the series and
689test again. Run format-patch from the last such merges to the tip of
690your topic. If you did
691+
692 $ git checkout origin/master
693 $ git merge --no-ff --into-name kn/ref-transaction-symref fo/obar
694 $ git merge --no-ff --into-name kn/ref-transaction-symref ba/zqux
695 ... rebuild the topic ...
696+
697Then you'd just format your topic above these "preparing the ground"
698merges, e.g.
699+
700 $ git format-patch "HEAD^{/^Merge branch 'ba/zqux'}"..HEAD
701+
702Do not forget to write in the cover letter you did this, including the
703topics you have in your base on top of 'master'. Then go to (4).
704
705. Make a trial merge of your topic into 'next' and 'seen', e.g.
706+
707 $ git checkout --detach 'origin/seen'
708 $ git revert -m 1 <the merge of the previous iteration into seen>
709 $ git merge kn/ref-transaction-symref
710+
711The "revert" is needed if the previous iteration of your topic is
712already in 'seen' (like in this case). You could choose to rebuild
713master..origin/seen from scratch while excluding your previous
714iteration, which may emulate what happens on the maintainers end more
715closely.
716+
717This trial merge may conflict. It is primarily to see what conflicts
718_other_ topics may have with your topic. In other words, you do not
719have to depend on it to make your topic work on 'master'. It may
720become the job of the other topic owners to resolve conflicts if your
721topic goes to 'next' before theirs.
722+
723Make a note on what conflict you saw in the cover letter. You do not
724necessarily have to resolve them, but it would be a good opportunity to
725learn what others are doing in related areas.
726+
727 $ git checkout --detach 'origin/next'
728 $ git merge kn/ref-transaction-symref
729+
730This is to see what conflicts your topic has with other topics that are
731already cooking. This should not conflict if (3)-2 prepared a base on
732top of updated master plus dependent topics taken from 'next'. Unless
733the context is severe (one way to tell is try the same trial merge with
734your old iteration, which may conflict in a similar way), expect that it
735will be handled on maintainers end (if it gets unmanageable, I'll ask to
736rebase when I receive your patches).
737
049e64aa 738== Subsystems with dedicated maintainers
e6da8ee8
JH
739
740Some parts of the system have dedicated maintainers with their own
741repositories.
742
b5935810 743- `git-gui/` comes from the git-gui project, maintained by Johannes Sixt:
e6da8ee8 744
e18ad8eb 745 https://github.com/j6t/git-gui
e6da8ee8 746
b5935810 747 Contibutions should go via the git mailing list.
e6da8ee8 748
b5935810 749- `gitk-git/` comes from the gitk project, maintained by Johannes Sixt:
b014cee8 750
b5935810
AS
751 https://github.com/j6t/gitk
752
753 Contibutions should go via the git mailing list.
e6da8ee8 754
68ed71b5 755- `po/` comes from the localization coordinator, Jiang Xin:
e6da8ee8
JH
756
757 https://github.com/git-l10n/git-po/
758
759Patches to these parts should be based on their trees.
760
558a5b8c
JH
761- The "Git documentation translations" project, led by Jean-Noël
762 Avila, translates our documentation pages. Their work products are
763 maintained separately from this project, not as part of our tree:
764
765 https://github.com/jnavila/git-manpages-l10n/
766
767
edbd9f37 768== GitHub CI[[GHCI]]
0e5d028a 769
f003a91f
ÆAB
770With an account at GitHub, you can use GitHub CI to test your changes
771on Linux, Mac and Windows. See
772https://github.com/git/git/actions/workflows/main.yml for examples of
773recent CI runs.
0e5d028a
LS
774
775Follow these steps for the initial setup:
776
049e64aa 777. Fork https://github.com/git/git to your GitHub account.
778 You can find detailed instructions how to fork here:
779 https://help.github.com/articles/fork-a-repo/
0e5d028a 780
f003a91f 781After the initial setup, CI will run whenever you push new changes
0e5d028a 782to your fork of Git on GitHub. You can monitor the test state of all your
edbd9f37 783branches here: `https://github.com/<Your GitHub handle>/git/actions/workflows/main.yml`
0e5d028a 784
0771a3b5
JS
785If a branch does not pass all test cases then it will be marked with a
786red +x+, instead of a green check. In that case, you can click on the
787failing job and navigate to "ci/run-build-and-tests.sh" and/or
788"ci/print-test-failures.sh". You can also download "Artifacts" which
78189516
JS
789are zip archives containing tarred (or zipped) archives with test data
790relevant for debugging.
f003a91f
ÆAB
791
792Then fix the problem and push your fix to your GitHub fork. This will
793trigger a new CI build to ensure all tests pass.
0e5d028a 794
049e64aa 795[[mua]]
796== MUA specific hints
9740d289 797
d0ea2ca1 798Some of the patches I receive or pick up from the list share common
9740d289 799patterns of breakage. Please make sure your MUA is set up
57756161
JN
800properly not to corrupt whitespaces.
801
049e64aa 802See the DISCUSSION section of linkgit:git-format-patch[1] for hints on
57756161 803checking your patch by mailing it to yourself and applying with
049e64aa 804linkgit:git-am[1].
57756161
JN
805
806While you are at it, check the resulting commit log message from
807a trial run of applying the patch. If what is in the resulting
808commit is not exactly what you would want to see, it is very
809likely that your maintainer would end up hand editing the log
810message when he applies your patch. Things like "Hi, this is my
811first patch.\n", if you really want to put in the patch e-mail,
812should come after the three-dash line that signals the end of the
813commit message.
9847f7e0 814
9740d289 815
049e64aa 816=== Pine
9740d289
JH
817
818(Johannes Schindelin)
819
049e64aa 820....
9740d289
JH
821I don't know how many people still use pine, but for those poor
822souls it may be good to mention that the quell-flowed-text is
823needed for recent versions.
824
825... the "no-strip-whitespace-before-send" option, too. AFAIK it
826was introduced in 4.60.
049e64aa 827....
9740d289
JH
828
829(Linus Torvalds)
830
049e64aa 831....
9740d289
JH
832And 4.58 needs at least this.
833
9740d289
JH
834diff-tree 8326dd8350be64ac7fc805f6563a1d61ad10d32c (from e886a61f76edf5410573e92e38ce22974f9c40f1)
835Author: Linus Torvalds <torvalds@g5.osdl.org>
836Date: Mon Aug 15 17:23:51 2005 -0700
837
838 Fix pine whitespace-corruption bug
839
840 There's no excuse for unconditionally removing whitespace from
841 the pico buffers on close.
842
843diff --git a/pico/pico.c b/pico/pico.c
844--- a/pico/pico.c
845+++ b/pico/pico.c
846@@ -219,7 +219,9 @@ PICO *pm;
a6080a0a
JH
847 switch(pico_all_done){ /* prepare for/handle final events */
848 case COMP_EXIT : /* already confirmed */
849 packheader();
9740d289 850+#if 0
a6080a0a 851 stripwhitespace();
9740d289 852+#endif
a6080a0a
JH
853 c |= COMP_EXIT;
854 break;
049e64aa 855....
9740d289 856
1eb446fa
JH
857(Daniel Barkalow)
858
049e64aa 859....
1eb446fa
JH
860> A patch to SubmittingPatches, MUA specific help section for
861> users of Pine 4.63 would be very much appreciated.
862
863Ah, it looks like a recent version changed the default behavior to do the
864right thing, and inverted the sense of the configuration option. (Either
865that or Gentoo did it.) So you need to set the
866"no-strip-whitespace-before-send" option, unless the option you have is
867"strip-whitespace-before-send", in which case you should avoid checking
868it.
049e64aa 869....
1eb446fa 870
049e64aa 871=== Thunderbird, KMail, GMail
9740d289 872
049e64aa 873See the MUA-SPECIFIC HINTS section of linkgit:git-format-patch[1].
e30b217b 874
049e64aa 875=== Gnus
e30b217b 876
049e64aa 877"|" in the `*Summary*` buffer can be used to pipe the current
e30b217b 878message to an external program, and this is a handy way to drive
049e64aa 879`git am`. However, if the message is MIME encoded, what is
e30b217b 880piped into the program is the representation you see in your
049e64aa 881`*Article*` buffer after unwrapping MIME. This is often not what
291873e5 882you would want for two reasons. It tends to screw up non-ASCII
e30b217b 883characters (most notably in people's names), and also
049e64aa 884whitespaces (fatal in patches). Running "C-u g" to display the
885message in raw form before using "|" to run the pipe can work
e30b217b 886this problem around.