Simon Glass | 37c42b7 | 2022-08-09 13:49:57 -0600 | [diff] [blame] | 1 | .. SPDX-License-Identifier: GPL-2.0+ |
| 2 | .. Copyright (c) 2011 The Chromium OS Authors |
| 3 | .. Simon Glass <sjg@chromium.org> |
Maxim Cournoyer | 8c042fb | 2022-12-20 00:28:46 -0500 | [diff] [blame] | 4 | .. Maxim Cournoyer <maxim.cournoyer@savoirfairelinux.com> |
Simon Glass | 37c42b7 | 2022-08-09 13:49:57 -0600 | [diff] [blame] | 5 | .. v1, v2, 19-Oct-11 |
| 6 | .. revised v3 24-Nov-11 |
Simon Glass | 74eaa5c | 2022-08-17 12:47:06 -0600 | [diff] [blame] | 7 | .. revised v4 Independence Day 2020, with Patchwork integration |
Simon Glass | 37c42b7 | 2022-08-09 13:49:57 -0600 | [diff] [blame] | 8 | |
| 9 | Patman patch manager |
| 10 | ==================== |
| 11 | |
| 12 | This tool is a Python script which: |
| 13 | |
| 14 | - Creates patch directly from your branch |
Simon Glass | 37c42b7 | 2022-08-09 13:49:57 -0600 | [diff] [blame] | 15 | - Cleans them up by removing unwanted tags |
Simon Glass | 37c42b7 | 2022-08-09 13:49:57 -0600 | [diff] [blame] | 16 | - Inserts a cover letter with change lists |
Simon Glass | 37c42b7 | 2022-08-09 13:49:57 -0600 | [diff] [blame] | 17 | - Runs the patches through checkpatch.pl and its own checks |
Simon Glass | 37c42b7 | 2022-08-09 13:49:57 -0600 | [diff] [blame] | 18 | - Optionally emails them out to selected people |
| 19 | |
| 20 | It also has some Patchwork features: |
| 21 | |
| 22 | - shows review tags from Patchwork so you can update your local patches |
Simon Glass | 37c42b7 | 2022-08-09 13:49:57 -0600 | [diff] [blame] | 23 | - pulls these down into a new branch on request |
Simon Glass | 37c42b7 | 2022-08-09 13:49:57 -0600 | [diff] [blame] | 24 | - lists comments received on a series |
| 25 | |
| 26 | It is intended to automate patch creation and make it a less |
| 27 | error-prone process. It is useful for U-Boot and Linux work so far, |
| 28 | since they use the checkpatch.pl script. |
| 29 | |
| 30 | It is configured almost entirely by tags it finds in your commits. |
| 31 | This means that you can work on a number of different branches at |
| 32 | once, and keep the settings with each branch rather than having to |
| 33 | git format-patch, git send-email, etc. with the correct parameters |
| 34 | each time. So for example if you put:: |
| 35 | |
| 36 | Series-to: fred.blogs@napier.co.nz |
| 37 | |
| 38 | in one of your commits, the series will be sent there. |
| 39 | |
| 40 | In Linux and U-Boot this will also call get_maintainer.pl on each of your |
| 41 | patches automatically (unless you use -m to disable this). |
| 42 | |
| 43 | |
Simon Glass | 6608acb | 2023-02-23 18:18:23 -0700 | [diff] [blame] | 44 | Installation |
| 45 | ------------ |
| 46 | |
| 47 | You can install patman using:: |
| 48 | |
| 49 | pip install patch-manager |
| 50 | |
| 51 | The name is chosen since patman conflicts with an existing package. |
| 52 | |
| 53 | If you are using patman within the U-Boot tree, it may be easiest to add a |
| 54 | symlink from your local `~/.bin` directory to `/path/to/tools/patman/patman`. |
| 55 | |
Simon Glass | 37c42b7 | 2022-08-09 13:49:57 -0600 | [diff] [blame] | 56 | How to use this tool |
| 57 | -------------------- |
| 58 | |
| 59 | This tool requires a certain way of working: |
| 60 | |
| 61 | - Maintain a number of branches, one for each patch series you are |
| 62 | working on |
Simon Glass | 37c42b7 | 2022-08-09 13:49:57 -0600 | [diff] [blame] | 63 | - Add tags into the commits within each branch to indicate where the |
| 64 | series should be sent, cover letter, version, etc. Most of these are |
| 65 | normally in the top commit so it is easy to change them with 'git |
| 66 | commit --amend' |
Simon Glass | 37c42b7 | 2022-08-09 13:49:57 -0600 | [diff] [blame] | 67 | - Each branch tracks the upstream branch, so that this script can |
| 68 | automatically determine the number of commits in it (optional) |
Simon Glass | 37c42b7 | 2022-08-09 13:49:57 -0600 | [diff] [blame] | 69 | - Check out a branch, and run this script to create and send out your |
| 70 | patches. Weeks later, change the patches and repeat, knowing that you |
| 71 | will get a consistent result each time. |
| 72 | |
| 73 | |
| 74 | How to configure it |
| 75 | ------------------- |
| 76 | |
| 77 | For most cases of using patman for U-Boot development, patman can use the |
| 78 | file 'doc/git-mailrc' in your U-Boot directory to supply the email aliases |
| 79 | you need. To make this work, tell git where to find the file by typing |
| 80 | this once:: |
| 81 | |
| 82 | git config sendemail.aliasesfile doc/git-mailrc |
| 83 | |
Maxim Cournoyer | 8c042fb | 2022-12-20 00:28:46 -0500 | [diff] [blame] | 84 | For both Linux and U-Boot the 'scripts/get_maintainer.pl' handles |
| 85 | figuring out where to send patches pretty well. For other projects, |
| 86 | you may want to specify a different script to be run, for example via |
| 87 | a project-specific `.patman` file:: |
| 88 | |
| 89 | # .patman configuration file at the root of some project |
| 90 | |
| 91 | [settings] |
| 92 | get_maintainer_script: etc/teams.scm get-maintainer |
| 93 | |
| 94 | The `get_maintainer_script` option corresponds to the |
| 95 | `--get-maintainer-script` argument of the `send` command. It is |
| 96 | looked relatively to the root of the current git repository, as well |
| 97 | as on PATH. It can also be provided arguments, as shown above. The |
| 98 | contract is that the script should accept a patch file name and return |
| 99 | a list of email addresses, one per line, like `get_maintainer.pl` |
| 100 | does. |
Simon Glass | 37c42b7 | 2022-08-09 13:49:57 -0600 | [diff] [blame] | 101 | |
| 102 | During the first run patman creates a config file for you by taking the default |
| 103 | user name and email address from the global .gitconfig file. |
| 104 | |
Maxim Cournoyer | 8f8d3f7 | 2022-12-20 00:38:41 -0500 | [diff] [blame] | 105 | To add your own, create a file `~/.patman` like this:: |
Simon Glass | 37c42b7 | 2022-08-09 13:49:57 -0600 | [diff] [blame] | 106 | |
| 107 | # patman alias file |
| 108 | |
| 109 | [alias] |
| 110 | me: Simon Glass <sjg@chromium.org> |
| 111 | |
| 112 | u-boot: U-Boot Mailing List <u-boot@lists.denx.de> |
| 113 | wolfgang: Wolfgang Denk <wd@denx.de> |
| 114 | others: Mike Frysinger <vapier@gentoo.org>, Fred Bloggs <f.bloggs@napier.net> |
| 115 | |
Maxim Cournoyer | 8c042fb | 2022-12-20 00:28:46 -0500 | [diff] [blame] | 116 | As hinted above, Patman will also look for a `.patman` configuration |
| 117 | file at the root of the current project git repository, which makes it |
| 118 | possible to override the `project` settings variable or anything else |
| 119 | in a project-specific way. The values of this "local" configuration |
| 120 | file take precedence over those of the "global" one. |
Maxim Cournoyer | 8f8d3f7 | 2022-12-20 00:38:41 -0500 | [diff] [blame] | 121 | |
Simon Glass | 37c42b7 | 2022-08-09 13:49:57 -0600 | [diff] [blame] | 122 | Aliases are recursive. |
| 123 | |
| 124 | The checkpatch.pl in the U-Boot tools/ subdirectory will be located and |
| 125 | used. Failing that you can put it into your path or ~/bin/checkpatch.pl |
| 126 | |
| 127 | If you want to avoid sending patches to email addresses that are picked up |
| 128 | by patman but are known to bounce you can add a [bounces] section to your |
| 129 | .patman file. Unlike the [alias] section these are simple key: value pairs |
| 130 | that are not recursive:: |
| 131 | |
| 132 | [bounces] |
| 133 | gonefishing: Fred Bloggs <f.bloggs@napier.net> |
| 134 | |
| 135 | |
| 136 | If you want to change the defaults for patman's command-line arguments, |
| 137 | you can add a [settings] section to your .patman file. This can be used |
| 138 | for any command line option by referring to the "dest" for the option in |
| 139 | patman.py. For reference, the useful ones (at the moment) shown below |
| 140 | (all with the non-default setting):: |
| 141 | |
| 142 | [settings] |
| 143 | ignore_errors: True |
| 144 | process_tags: False |
| 145 | verbose: True |
| 146 | smtp_server: /path/to/sendmail |
| 147 | patchwork_server: https://patchwork.ozlabs.org |
| 148 | |
| 149 | If you want to adjust settings (or aliases) that affect just a single |
| 150 | project you can add a section that looks like [project_settings] or |
| 151 | [project_alias]. If you want to use tags for your linux work, you could do:: |
| 152 | |
| 153 | [linux_settings] |
| 154 | process_tags: True |
| 155 | |
| 156 | |
| 157 | How to run it |
| 158 | ------------- |
| 159 | |
| 160 | First do a dry run: |
| 161 | |
| 162 | .. code-block:: bash |
| 163 | |
| 164 | ./tools/patman/patman send -n |
| 165 | |
| 166 | If it can't detect the upstream branch, try telling it how many patches |
| 167 | there are in your series |
| 168 | |
| 169 | .. code-block:: bash |
| 170 | |
| 171 | ./tools/patman/patman -c5 send -n |
| 172 | |
| 173 | This will create patch files in your current directory and tell you who |
| 174 | it is thinking of sending them to. Take a look at the patch files: |
| 175 | |
| 176 | .. code-block:: bash |
| 177 | |
| 178 | ./tools/patman/patman -c5 -s1 send -n |
| 179 | |
| 180 | Similar to the above, but skip the first commit and take the next 5. This |
| 181 | is useful if your top commit is for setting up testing. |
| 182 | |
| 183 | |
| 184 | How to install it |
| 185 | ----------------- |
| 186 | |
| 187 | The most up to date version of patman can be found in the U-Boot sources. |
| 188 | However to use it on other projects it may be more convenient to install it as |
| 189 | a standalone application. A distutils installer is included, this can be used |
| 190 | to install patman: |
| 191 | |
| 192 | .. code-block:: bash |
| 193 | |
| 194 | cd tools/patman && python setup.py install |
| 195 | |
| 196 | |
| 197 | How to add tags |
| 198 | --------------- |
| 199 | |
| 200 | To make this script useful you must add tags like the following into any |
| 201 | commit. Most can only appear once in the whole series. |
| 202 | |
| 203 | Series-to: email / alias |
| 204 | Email address / alias to send patch series to (you can add this |
| 205 | multiple times) |
| 206 | |
| 207 | Series-cc: email / alias, ... |
| 208 | Email address / alias to Cc patch series to (you can add this |
| 209 | multiple times) |
| 210 | |
| 211 | Series-version: n |
| 212 | Sets the version number of this patch series |
| 213 | |
| 214 | Series-prefix: prefix |
| 215 | Sets the subject prefix. Normally empty but it can be RFC for |
| 216 | RFC patches, or RESEND if you are being ignored. The patch subject |
| 217 | is like [RFC PATCH] or [RESEND PATCH]. |
| 218 | In the meantime, git format.subjectprefix option will be added as |
| 219 | well. If your format.subjectprefix is set to InternalProject, then |
| 220 | the patch shows like: [InternalProject][RFC/RESEND PATCH] |
| 221 | |
| 222 | Series-postfix: postfix |
| 223 | Sets the subject "postfix". Normally empty, but can be the name of a |
| 224 | tree such as net or net-next if that needs to be specified. The patch |
| 225 | subject is like [PATCH net] or [PATCH net-next]. |
| 226 | |
| 227 | Series-name: name |
| 228 | Sets the name of the series. You don't need to have a name, and |
| 229 | patman does not yet use it, but it is convenient to put the branch |
| 230 | name here to help you keep track of multiple upstreaming efforts. |
| 231 | |
| 232 | Series-links: [id | version:id]... |
| 233 | Set the ID of the series in patchwork. You can set this after you send |
| 234 | out the series and look in patchwork for the resulting series. The |
| 235 | URL you want is the one for the series itself, not any particular patch. |
| 236 | E.g. for http://patchwork.ozlabs.org/project/uboot/list/?series=187331 |
| 237 | the series ID is 187331. This property can have a list of series IDs, |
| 238 | one for each version of the series, e.g. |
| 239 | |
| 240 | :: |
| 241 | |
| 242 | Series-links: 1:187331 2:188434 189372 |
| 243 | |
| 244 | Patman always uses the one without a version, since it assumes this is |
| 245 | the latest one. When this tag is provided, patman can compare your local |
| 246 | branch against patchwork to see what new reviews your series has |
| 247 | collected ('patman status'). |
| 248 | |
| 249 | Series-patchwork-url: url |
| 250 | This allows specifying the Patchwork URL for a branch. This overrides |
| 251 | both the setting files and the command-line argument. The URL should |
| 252 | include the protocol and web site, with no trailing slash, for example |
| 253 | 'https://patchwork.ozlabs.org/project' |
| 254 | |
| 255 | Cover-letter: |
| 256 | Sets the cover letter contents for the series. The first line |
| 257 | will become the subject of the cover letter:: |
| 258 | |
| 259 | Cover-letter: |
| 260 | This is the patch set title |
| 261 | blah blah |
| 262 | more blah blah |
| 263 | END |
| 264 | |
| 265 | Cover-letter-cc: email / alias |
| 266 | Additional email addresses / aliases to send cover letter to (you |
| 267 | can add this multiple times) |
| 268 | |
| 269 | Series-notes: |
| 270 | Sets some notes for the patch series, which you don't want in |
| 271 | the commit messages, but do want to send, The notes are joined |
| 272 | together and put after the cover letter. Can appear multiple |
| 273 | times:: |
| 274 | |
| 275 | Series-notes: |
| 276 | blah blah |
| 277 | blah blah |
| 278 | more blah blah |
| 279 | END |
| 280 | |
| 281 | Commit-notes: |
| 282 | Similar, but for a single commit (patch). These notes will appear |
| 283 | immediately below the --- cut in the patch file:: |
| 284 | |
| 285 | Commit-notes: |
| 286 | blah blah |
| 287 | blah blah |
| 288 | more blah blah |
| 289 | |
| 290 | Signed-off-by: Their Name <email> |
| 291 | A sign-off is added automatically to your patches (this is |
| 292 | probably a bug). If you put this tag in your patches, it will |
| 293 | override the default signoff that patman automatically adds. |
| 294 | Multiple duplicate signoffs will be removed. |
| 295 | |
| 296 | Tested-by / Reviewed-by / Acked-by |
| 297 | These indicate that someone has tested/reviewed/acked your patch. |
| 298 | When you get this reply on the mailing list, you can add this |
| 299 | tag to the relevant commit and the script will include it when |
| 300 | you send out the next version. If 'Tested-by:' is set to |
| 301 | yourself, it will be removed. No one will believe you. |
| 302 | |
| 303 | Example:: |
| 304 | |
| 305 | Tested-by: Their Name <fred@bloggs.com> |
| 306 | Reviewed-by: Their Name <email> |
| 307 | Acked-by: Their Name <email> |
| 308 | |
| 309 | Series-changes: n |
| 310 | This can appear in any commit. It lists the changes for a |
| 311 | particular version n of that commit. The change list is |
| 312 | created based on this information. Each commit gets its own |
| 313 | change list and also the whole thing is repeated in the cover |
| 314 | letter (where duplicate change lines are merged). |
| 315 | |
| 316 | By adding your change lists into your commits it is easier to |
| 317 | keep track of what happened. When you amend a commit, remember |
| 318 | to update the log there and then, knowing that the script will |
| 319 | do the rest. |
| 320 | |
| 321 | Example:: |
| 322 | |
| 323 | Series-changes: n |
| 324 | - Guinea pig moved into its cage |
| 325 | - Other changes ending with a blank line |
| 326 | <blank line> |
| 327 | |
| 328 | Commit-changes: n |
| 329 | This tag is like Series-changes, except changes in this changelog will |
| 330 | only appear in the changelog of the commit this tag is in. This is |
| 331 | useful when you want to add notes which may not make sense in the cover |
| 332 | letter. For example, you can have short changes such as "New" or |
| 333 | "Lint". |
| 334 | |
| 335 | Example:: |
| 336 | |
| 337 | Commit-changes: n |
| 338 | - This line will not appear in the cover-letter changelog |
| 339 | <blank line> |
| 340 | |
| 341 | Cover-changes: n |
| 342 | This tag is like Series-changes, except changes in this changelog will |
| 343 | only appear in the cover-letter changelog. This is useful to summarize |
| 344 | changes made with Commit-changes, or to add additional context to |
| 345 | changes. |
| 346 | |
| 347 | Example:: |
| 348 | |
| 349 | Cover-changes: n |
| 350 | - This line will only appear in the cover letter |
| 351 | <blank line> |
| 352 | |
| 353 | Patch-cc: Their Name <email> |
| 354 | This copies a single patch to another email address. Note that the |
| 355 | Cc: used by git send-email is ignored by patman, but will be |
| 356 | interpreted by git send-email if you use it. |
| 357 | |
| 358 | Series-process-log: sort, uniq |
| 359 | This tells patman to sort and/or uniq the change logs. Changes may be |
| 360 | multiple lines long, as long as each subsequent line of a change begins |
| 361 | with a whitespace character. For example, |
| 362 | |
| 363 | Example:: |
| 364 | |
| 365 | - This change |
| 366 | continues onto the next line |
| 367 | - But this change is separate |
| 368 | |
| 369 | Use 'sort' to sort the entries, and 'uniq' to include only |
| 370 | unique entries. If omitted, no change log processing is done. |
| 371 | Separate each tag with a comma. |
| 372 | |
| 373 | Change-Id: |
| 374 | This tag is stripped out but is used to generate the Message-Id |
| 375 | of the emails that will be sent. When you keep the Change-Id the |
| 376 | same you are asserting that this is a slightly different version |
| 377 | (but logically the same patch) as other patches that have been |
| 378 | sent out with the same Change-Id. |
| 379 | |
| 380 | Various other tags are silently removed, like these Chrome OS and |
| 381 | Gerrit tags:: |
| 382 | |
| 383 | BUG=... |
| 384 | TEST=... |
| 385 | Review URL: |
| 386 | Reviewed-on: |
| 387 | Commit-xxxx: (except Commit-notes) |
| 388 | |
| 389 | Exercise for the reader: Try adding some tags to one of your current |
| 390 | patch series and see how the patches turn out. |
| 391 | |
| 392 | |
| 393 | Where Patches Are Sent |
| 394 | ---------------------- |
| 395 | |
| 396 | Once the patches are created, patman sends them using git send-email. The |
| 397 | whole series is sent to the recipients in Series-to: and Series-cc. |
| 398 | You can Cc individual patches to other people with the Patch-cc: tag. Tags |
| 399 | in the subject are also picked up to Cc patches. For example, a commit like |
| 400 | this:: |
| 401 | |
| 402 | commit 10212537b85ff9b6e09c82045127522c0f0db981 |
| 403 | Author: Mike Frysinger <vapier@gentoo.org> |
| 404 | Date: Mon Nov 7 23:18:44 2011 -0500 |
| 405 | |
| 406 | x86: arm: add a git mailrc file for maintainers |
| 407 | |
| 408 | This should make sending out e-mails to the right people easier. |
| 409 | |
| 410 | Patch-cc: sandbox, mikef, ag |
| 411 | Patch-cc: afleming |
| 412 | |
| 413 | will create a patch which is copied to x86, arm, sandbox, mikef, ag and |
| 414 | afleming. |
| 415 | |
| 416 | If you have a cover letter it will get sent to the union of the Patch-cc |
| 417 | lists of all of the other patches. If you want to sent it to additional |
| 418 | people you can add a tag:: |
| 419 | |
| 420 | Cover-letter-cc: <list of addresses> |
| 421 | |
| 422 | These people will get the cover letter even if they are not on the To/Cc |
| 423 | list for any of the patches. |
| 424 | |
| 425 | |
| 426 | Patchwork Integration |
| 427 | --------------------- |
| 428 | |
| 429 | Patman has a very basic integration with Patchwork. If you point patman to |
| 430 | your series on patchwork it can show you what new reviews have appeared since |
| 431 | you sent your series. |
| 432 | |
| 433 | To set this up, add a Series-link tag to one of the commits in your series |
| 434 | (see above). |
| 435 | |
| 436 | Then you can type: |
| 437 | |
| 438 | .. code-block:: bash |
| 439 | |
| 440 | patman status |
| 441 | |
| 442 | and patman will show you each patch and what review tags have been collected, |
| 443 | for example:: |
| 444 | |
| 445 | ... |
| 446 | 21 x86: mtrr: Update the command to use the new mtrr |
| 447 | Reviewed-by: Wolfgang Wallner <wolfgang.wallner@br-automation.com> |
| 448 | + Reviewed-by: Bin Meng <bmeng.cn@gmail.com> |
| 449 | 22 x86: mtrr: Restructure so command execution is in |
| 450 | Reviewed-by: Wolfgang Wallner <wolfgang.wallner@br-automation.com> |
| 451 | + Reviewed-by: Bin Meng <bmeng.cn@gmail.com> |
| 452 | ... |
| 453 | |
| 454 | This shows that patch 21 and 22 were sent out with one review but have since |
| 455 | attracted another review each. If the series needs changes, you can update |
| 456 | these commits with the new review tag before sending the next version of the |
| 457 | series. |
| 458 | |
| 459 | To automatically pull into these tags into a new branch, use the -d option: |
| 460 | |
| 461 | .. code-block:: bash |
| 462 | |
| 463 | patman status -d mtrr4 |
| 464 | |
| 465 | This will create a new 'mtrr4' branch which is the same as your current branch |
| 466 | but has the new review tags in it. The tags are added in alphabetic order and |
| 467 | are placed immediately after any existing ack/review/test/fixes tags, or at the |
| 468 | end. You can check that this worked with: |
| 469 | |
| 470 | .. code-block:: bash |
| 471 | |
| 472 | patman -b mtrr4 status |
| 473 | |
| 474 | which should show that there are no new responses compared to this new branch. |
| 475 | |
| 476 | There is also a -C option to list the comments received for each patch. |
| 477 | |
| 478 | |
| 479 | Example Work Flow |
| 480 | ----------------- |
| 481 | |
| 482 | The basic workflow is to create your commits, add some tags to the top |
| 483 | commit, and type 'patman' to check and send them. |
| 484 | |
| 485 | Here is an example workflow for a series of 4 patches. Let's say you have |
| 486 | these rather contrived patches in the following order in branch us-cmd in |
| 487 | your tree where 'us' means your upstreaming activity (newest to oldest as |
| 488 | output by git log --oneline):: |
| 489 | |
| 490 | 7c7909c wip |
| 491 | 89234f5 Don't include standard parser if hush is used |
| 492 | 8d640a7 mmc: sparc: Stop using builtin_run_command() |
| 493 | 0c859a9 Rename run_command2() to run_command() |
| 494 | a74443f sandbox: Rename run_command() to builtin_run_command() |
| 495 | |
| 496 | The first patch is some test things that enable your code to be compiled, |
| 497 | but that you don't want to submit because there is an existing patch for it |
| 498 | on the list. So you can tell patman to create and check some patches |
| 499 | (skipping the first patch) with: |
| 500 | |
| 501 | .. code-block:: bash |
| 502 | |
| 503 | patman -s1 send -n |
| 504 | |
| 505 | If you want to do all of them including the work-in-progress one, then |
| 506 | (if you are tracking an upstream branch): |
| 507 | |
| 508 | .. code-block:: bash |
| 509 | |
| 510 | patman send -n |
| 511 | |
| 512 | Let's say that patman reports an error in the second patch. Then: |
| 513 | |
| 514 | .. code-block:: bash |
| 515 | |
| 516 | git rebase -i HEAD~6 |
| 517 | # change 'pick' to 'edit' in 89234f5 |
| 518 | # use editor to make code changes |
| 519 | git add -u |
| 520 | git rebase --continue |
| 521 | |
| 522 | Now you have an updated patch series. To check it: |
| 523 | |
| 524 | .. code-block:: bash |
| 525 | |
| 526 | patman -s1 send -n |
| 527 | |
| 528 | Let's say it is now clean and you want to send it. Now you need to set up |
| 529 | the destination. So amend the top commit with: |
| 530 | |
| 531 | .. code-block:: bash |
| 532 | |
| 533 | git commit --amend |
| 534 | |
| 535 | Use your editor to add some tags, so that the whole commit message is:: |
| 536 | |
| 537 | The current run_command() is really only one of the options, with |
| 538 | hush providing the other. It really shouldn't be called directly |
| 539 | in case the hush parser is bring used, so rename this function to |
| 540 | better explain its purpose:: |
| 541 | |
| 542 | Series-to: u-boot |
| 543 | Series-cc: bfin, marex |
| 544 | Series-prefix: RFC |
| 545 | Cover-letter: |
| 546 | Unified command execution in one place |
| 547 | |
| 548 | At present two parsers have similar code to execute commands. Also |
| 549 | cmd_usage() is called all over the place. This series adds a single |
| 550 | function which processes commands called cmd_process(). |
| 551 | END |
| 552 | |
| 553 | Change-Id: Ica71a14c1f0ecb5650f771a32fecb8d2eb9d8a17 |
| 554 | |
| 555 | |
| 556 | You want this to be an RFC and Cc the whole series to the bfin alias and |
| 557 | to Marek. Two of the patches have tags (those are the bits at the front of |
| 558 | the subject that say mmc: sparc: and sandbox:), so 8d640a7 will be Cc'd to |
| 559 | mmc and sparc, and the last one to sandbox. |
| 560 | |
| 561 | Now to send the patches, take off the -n flag: |
| 562 | |
| 563 | .. code-block:: bash |
| 564 | |
| 565 | patman -s1 send |
| 566 | |
| 567 | The patches will be created, shown in your editor, and then sent along with |
| 568 | the cover letter. Note that patman's tags are automatically removed so that |
| 569 | people on the list don't see your secret info. |
| 570 | |
| 571 | Of course patches often attract comments and you need to make some updates. |
| 572 | Let's say one person sent comments and you get an Acked-by: on one patch. |
| 573 | Also, the patch on the list that you were waiting for has been merged, |
| 574 | so you can drop your wip commit. |
| 575 | |
| 576 | Take a look on patchwork and find out the URL of the series. This will be |
| 577 | something like `http://patchwork.ozlabs.org/project/uboot/list/?series=187331` |
| 578 | Add this to a tag in your top commit:: |
| 579 | |
| 580 | Series-links: 187331 |
| 581 | |
| 582 | You can use then patman to collect the Acked-by tag to the correct commit, |
| 583 | creating a new 'version 2' branch for us-cmd: |
| 584 | |
| 585 | .. code-block:: bash |
| 586 | |
| 587 | patman status -d us-cmd2 |
| 588 | git checkout us-cmd2 |
| 589 | |
| 590 | You can look at the comments in Patchwork or with: |
| 591 | |
| 592 | .. code-block:: bash |
| 593 | |
| 594 | patman status -C |
| 595 | |
| 596 | Then you can resync with upstream: |
| 597 | |
| 598 | .. code-block:: bash |
| 599 | |
| 600 | git fetch origin # or whatever upstream is called |
| 601 | git rebase origin/master |
| 602 | |
| 603 | and use git rebase -i to edit the commits, dropping the wip one. |
| 604 | |
| 605 | Then update the `Series-cc:` in the top commit to add the person who reviewed |
| 606 | the v1 series:: |
| 607 | |
| 608 | Series-cc: bfin, marex, Heiko Schocher <hs@denx.de> |
| 609 | |
| 610 | and remove the Series-prefix: tag since it it isn't an RFC any more. The |
| 611 | series is now version two, so the series info in the top commit looks like |
| 612 | this:: |
| 613 | |
| 614 | Series-to: u-boot |
| 615 | Series-cc: bfin, marex, Heiko Schocher <hs@denx.de> |
| 616 | Series-version: 2 |
| 617 | Cover-letter: |
| 618 | ... |
| 619 | |
| 620 | Finally, you need to add a change log to the two commits you changed. You |
| 621 | add change logs to each individual commit where the changes happened, like |
| 622 | this:: |
| 623 | |
| 624 | Series-changes: 2 |
| 625 | - Updated the command decoder to reduce code size |
| 626 | - Wound the torque propounder up a little more |
| 627 | |
| 628 | (note the blank line at the end of the list) |
| 629 | |
| 630 | When you run patman it will collect all the change logs from the different |
| 631 | commits and combine them into the cover letter, if you have one. So finally |
| 632 | you have a new series of commits:: |
| 633 | |
| 634 | faeb973 Don't include standard parser if hush is used |
| 635 | 1b2f2fe mmc: sparc: Stop using builtin_run_command() |
| 636 | cfbe330 Rename run_command2() to run_command() |
| 637 | 0682677 sandbox: Rename run_command() to builtin_run_command() |
| 638 | |
| 639 | so to send them: |
| 640 | |
| 641 | .. code-block:: bash |
| 642 | |
| 643 | patman |
| 644 | |
| 645 | and it will create and send the version 2 series. |
| 646 | |
| 647 | |
| 648 | General points |
| 649 | -------------- |
| 650 | |
Simon Glass | 65af8f2 | 2022-08-17 12:47:07 -0600 | [diff] [blame] | 651 | #. When you change back to the us-cmd branch days or weeks later all your |
Simon Glass | 37c42b7 | 2022-08-09 13:49:57 -0600 | [diff] [blame] | 652 | information is still there, safely stored in the commits. You don't need |
| 653 | to remember what version you are up to, who you sent the last lot of patches |
| 654 | to, or anything about the change logs. |
Simon Glass | 65af8f2 | 2022-08-17 12:47:07 -0600 | [diff] [blame] | 655 | #. If you put tags in the subject, patman will Cc the maintainers |
Simon Glass | 37c42b7 | 2022-08-09 13:49:57 -0600 | [diff] [blame] | 656 | automatically in many cases. |
Simon Glass | 65af8f2 | 2022-08-17 12:47:07 -0600 | [diff] [blame] | 657 | #. If you want to keep the commits from each series you sent so that you can |
Simon Glass | 37c42b7 | 2022-08-09 13:49:57 -0600 | [diff] [blame] | 658 | compare change and see what you did, you can either create a new branch for |
| 659 | each version, or just tag the branch before you start changing it: |
| 660 | |
Simon Glass | 65af8f2 | 2022-08-17 12:47:07 -0600 | [diff] [blame] | 661 | .. code-block:: bash |
Simon Glass | 37c42b7 | 2022-08-09 13:49:57 -0600 | [diff] [blame] | 662 | |
| 663 | git tag sent/us-cmd-rfc |
| 664 | # ...later... |
| 665 | git tag sent/us-cmd-v2 |
| 666 | |
Simon Glass | 65af8f2 | 2022-08-17 12:47:07 -0600 | [diff] [blame] | 667 | #. If you want to modify the patches a little before sending, you can do |
Simon Glass | 37c42b7 | 2022-08-09 13:49:57 -0600 | [diff] [blame] | 668 | this in your editor, but be careful! |
Simon Glass | 65af8f2 | 2022-08-17 12:47:07 -0600 | [diff] [blame] | 669 | #. If you want to run git send-email yourself, use the -n flag which will |
Simon Glass | 37c42b7 | 2022-08-09 13:49:57 -0600 | [diff] [blame] | 670 | print out the command line patman would have used. |
Simon Glass | 65af8f2 | 2022-08-17 12:47:07 -0600 | [diff] [blame] | 671 | #. It is a good idea to add the change log info as you change the commit, |
Simon Glass | 37c42b7 | 2022-08-09 13:49:57 -0600 | [diff] [blame] | 672 | not later when you can't remember which patch you changed. You can always |
| 673 | go back and change or remove logs from commits. |
Simon Glass | 65af8f2 | 2022-08-17 12:47:07 -0600 | [diff] [blame] | 674 | #. Some mailing lists have size limits and when we add binary contents to |
Simon Glass | 37c42b7 | 2022-08-09 13:49:57 -0600 | [diff] [blame] | 675 | our patches it's easy to exceed the size limits. Use "--no-binary" to |
| 676 | generate patches without any binary contents. You are supposed to include |
| 677 | a link to a git repository in your "Commit-notes", "Series-notes" or |
| 678 | "Cover-letter" for maintainers to fetch the original commit. |
Simon Glass | 65af8f2 | 2022-08-17 12:47:07 -0600 | [diff] [blame] | 679 | #. Patches will have no changelog entries for revisions where they did not |
Simon Glass | 37c42b7 | 2022-08-09 13:49:57 -0600 | [diff] [blame] | 680 | change. For clarity, if there are no changes for this patch in the most |
| 681 | recent revision of the series, a note will be added. For example, a patch |
| 682 | with the following tags in the commit:: |
| 683 | |
| 684 | Series-version: 5 |
| 685 | Series-changes: 2 |
| 686 | - Some change |
| 687 | |
| 688 | Series-changes: 4 |
| 689 | - Another change |
| 690 | |
Simon Glass | 65af8f2 | 2022-08-17 12:47:07 -0600 | [diff] [blame] | 691 | would have a changelog of::: |
Simon Glass | 37c42b7 | 2022-08-09 13:49:57 -0600 | [diff] [blame] | 692 | |
Simon Glass | 65af8f2 | 2022-08-17 12:47:07 -0600 | [diff] [blame] | 693 | (no changes since v4) |
Simon Glass | 37c42b7 | 2022-08-09 13:49:57 -0600 | [diff] [blame] | 694 | |
Simon Glass | 65af8f2 | 2022-08-17 12:47:07 -0600 | [diff] [blame] | 695 | Changes in v4: |
| 696 | - Another change |
Simon Glass | 37c42b7 | 2022-08-09 13:49:57 -0600 | [diff] [blame] | 697 | |
Simon Glass | 65af8f2 | 2022-08-17 12:47:07 -0600 | [diff] [blame] | 698 | Changes in v2: |
| 699 | - Some change |
Simon Glass | 37c42b7 | 2022-08-09 13:49:57 -0600 | [diff] [blame] | 700 | |
| 701 | |
| 702 | Other thoughts |
| 703 | -------------- |
| 704 | |
| 705 | This script has been split into sensible files but still needs work. |
| 706 | Most of these are indicated by a TODO in the code. |
| 707 | |
| 708 | It would be nice if this could handle the In-reply-to side of things. |
| 709 | |
| 710 | The tests are incomplete, as is customary. Use the 'test' subcommand to run |
| 711 | them: |
| 712 | |
| 713 | .. code-block:: bash |
| 714 | |
| 715 | $ tools/patman/patman test |
| 716 | |
Maxim Cournoyer | 52c1c33 | 2022-12-19 17:32:43 -0500 | [diff] [blame] | 717 | Note that since the test suite depends on data files only available in |
| 718 | the git checkout, the `test` command is hidden unless `patman` is |
| 719 | invoked from the U-Boot git repository. |
| 720 | |
Maxim Cournoyer | f393f59 | 2022-12-19 17:32:44 -0500 | [diff] [blame] | 721 | Alternatively, you can run the test suite via Pytest: |
| 722 | |
| 723 | .. code-block:: bash |
| 724 | |
| 725 | $ cd tools/patman && pytest |
| 726 | |
Simon Glass | 37c42b7 | 2022-08-09 13:49:57 -0600 | [diff] [blame] | 727 | Error handling doesn't always produce friendly error messages - e.g. |
| 728 | putting an incorrect tag in a commit may provide a confusing message. |
| 729 | |
| 730 | There might be a few other features not mentioned in this README. They |
| 731 | might be bugs. In particular, tags are case sensitive which is probably |
| 732 | a bad thing. |