1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609
|
=encoding utf8
=head1 NAME
git-publish - Prepare and store patch revisions as git tags
=head1 SYNOPSIS
git-publish [options] -- [common format-patch options]
=head1 DESCRIPTION
git-publish prepares patches and stores them as git tags for future reference.
It works with individual patches as well as patch series. Revision numbering
is handled automatically.
No constraints are placed on git workflow, both vanilla git commands and custom
workflow scripts are compatible with git-publish.
Email sending and pull requests are fully integrated so that publishing patches
can be done in a single command.
Hook scripts are invoked during patch preparation so that custom checks or
test runs can be automated.
=head1 OPTIONS
=over 4
=item B<--version>
Show program's version number and exit.
=item B<-h>
=item B<--help>
Show help message and exit.
=item B<--annotate>
Review and edit each patch email.
=item B<-b BASE>
=item B<--base=BASE>
Branch which this is based off (defaults to master).
=item B<--cc=CC>
Specify a Cc: email recipient.
=item B<--cc-cmd=CC_CMD>
Specify a command add whose output to add the Cc: email recipient list. See L<git-send-email(1)> for details.
=item B<--no-check-url>
Do not check whether the pull request URL is publicly accessible.
=item B<--check-url>
Check whether the pull request URL is publicly accessible. This is the default.
=item B<--edit>
Edit message but do not tag a new version. Use this to draft the cover letter before actually tagging a new version.
=item B<--no-inspect-emails>
Do not prompt for confirmation before sending emails.
=item B<--inspect-emails>
Show confirmation before sending emails.
=item B<-n NUMBER>
=item B<--number=NUMBER>
Explicitly specify the version number (auto-generated by default).
=item B<--no-message>
=item B<--no-cover-letter>
Do not add a message.
=item B<-m>
=item B<--message>
=item B<--cover-letter>
Add a message.
=item B<--no-binary>
Do not output contents of changes in binary files, instead display a
notice that those files changed. Patches generated using this option
cannot be applied properly, but they are still useful for code review.
=item B<-p PROFILE_NAME>
=item B<--profile=PROFILE_NAME>
Select default settings from the given profile.
=item B<--pull-request>
Tag and send as a pull request.
=item B<--sign-pull>
Sign tag when sending pull request.
=item B<--no-sign-pull>
Do not sign tag when sending pull request.
=item B<-k KEYID>
=item B<--keyid=KEYID>
Use the given GPG key to sign tag when sending pull request
=item B<--blurb-template>
Use a pre-defined blurb message for the series HEAD.
=item B<--subject-prefix=PREFIX>
Set the email Subject: header prefix.
=item B<--clear-subject-prefix>
Clear the per-branch subject prefix. The subject prefix persists between
versions by default. Use this option to reset it.
=item B<--setup>
Add git alias in ~/.gitconfig so that the "git publish" git sub-command works.
=item B<-t TOPIC>
=item B<--topic=TOPIC>
Set the topic name (defaults to current branch name).
=item B<--to=TO>
Specify a primary email recipient.
=item B<-s>
=item B<--signoff>
Add Signed-off-by: <self> to commits when emailing.
=item B<--notes>
Append the notes for the commit after the three-dash line. See L<git-notes(1)>
for details.
=item B<--suppress-cc=SUPPRESS_CC>
Override auto-cc when sending email. See L<git-send-email(1)> for details.
=item B<-v>
=item B<--verbose>
Show executed git commands (useful for troubleshooting).
=item B<--forget-cc>
Forget all previous Cc: email addresses.
=item B<--override-to>
Ignore any profile or saved To: email addresses.
=item B<--override-cc>
Ignore any profile or saved Cc: email addresses.
=item B<-R IN_REPLY_TO>
=item B<--in-reply-to=IN_REPLY_TO>
Specify the In-Reply-To: of the cover letter (or the single patch).
=back
=head1 DISCUSSION
=head2 Setup
Run git-publish in setup mode to configure the git alias:
$ git-publish --setup
You can now use 'git publish' like a built-in git command.
=head2 Quickstart
Create a "topic branch" on which to do your work (implement a new feature or fix a bug):
$ git checkout -b add-funny-jokes
...
$ git commit
...
$ git commit
Send a patch series via email:
$ git publish --to patches@example.org --cc maintainer@example.org
Address code review comments and send a new revision:
$ git rebase -i master
...
$ git publish --to patches@example.org --cc maintainer@example.org
Refer back to older revisions:
$ git show add-funny-jokes-v1
This concludes the basic workflow for sending patch series.
=head2 Storing patch revisions
To store the first revision of a patch series:
$ git checkout my-feature
$ git publish
This creates the my-feature-v1 git tag. Running git-publish again at a later
point will create tags with incrementing version numbers:
my-feature-v1
my-feature-v2
my-feature-v3
...
To refer back to a previous version, simply check out that git tag. This way a
record is kept of each patch revision that has been published.
=head3 Overriding the version number
The version number can be set manually. This is handy when starting out with
git-publish on branches that were previously manually versioned:
$ git checkout my-existing-feature
$ git publish --number 7
This creates the my-existing-feature-v7 tag.
=head3 Overriding the branch name
By default git-publish refuses to create a revision for the 'master' branch.
Usually one works with so-called topic branches, one branch for each feature
under development. Using the 'master' branch may indicate that one has
forgotten to switch onto the intended topic branch. It is possible to override
the topic name and even publish on 'master':
$ git checkout branch-a
$ git publish --topic branch-b
This creates branch-b-v1 instead of branch-a-v1 and can be used to skip the
check for 'master'.
=head2 Tag messages
Tag messages have a summary (or subject line) and a description (or blurb).
When send email integration is used the summary is put into the cover letter
Subject: line while the description is put into the body.
When prompting for tag messages on v2, v3, or other incremental revisions, the
previous revision's tag message is used as the starting point. This is handy
for updating the existing description and keeping a changelog of the difference
between revisions.
The L<git-config(1)> format.coverLetter value is honored. The default 'auto'
value adds a cover letter if there is more than 1 patch. The cover letter can
also be forced with 'true' or 'false'.
To insist on creating a tag message:
$ git publish --message
To refrain from creating a tag message:
$ git publish --no-message
For convenience these options are also available as --cover-letter and
--no-cover-letter just like in L<git-format-patch(1)>.
=head3 Editing tag messages without publishing
Sometimes it is useful to edit the tag message before publishing. This can be
used to note down changelog entries as you prepare the next version of a patch
series.
To edit the tag message without publishing:
$ git publish --edit
This does not tag a new version. Instead a -staging tag will be created and
the tag message will be picked up when you publish next time. For example, if
you on branch my-feature and have already published v1 and v2, editing the tag
message will create the tag my-feature-staging. When you publish next time the
my-feature-v3 tag will be created and use the tag message you staged earlier.
=head2 Setting the base branch
git-publish detects whether the branch contains a single commit or multiple
commits by comparing against a base branch ('master' by default). You can
specify the base branch like this:
$ git publish --base my-parent
Most of the time 'master' works fine.
It is also possible to persist which base branch to use. This is useful if you
find yourself often specifying a base branch manually. It can be done globally
for all branches in a reposity or just for a specific branch:
$ git config git-publish.base origin/master # for all branches
$ git config branch.foo.gitpublishbase origin/master # for one branch
=head2 Send email integration
git-publish can call L<git-send-email(1)> after creating a git tag. If there is a
tag message it will be used as the cover letter. Email can be sent like this:
$ git publish --to patches@example.org \
--cc alex@example.org --cc bob@example.org
After the git tag has been created as usual, commits on top of the base branch
are sent as the patch series. The base branch defaults to 'master' and can be
set manually with --base.
The L<git-send-email(1)> aliasesfile feature works since the email addresses are
passed through without interpretation by git-publish.
Patch emails can be manually edited before being sent, these changes only
affect outgoing emails and are not stored permanently:
$ git publish --to patches@example.org --annotate
git-publish can background itself so patch emails can be inspected from the
shell:
$ git publish --to patches@example.org --inspect-emails
Signed-off-by: <self> lines can be applied to patch emails, only outgoing
emails are affected and not the local git commits:
$ git publish --to patches@example.org --signoff
Sending [RFC] series instead of regular [PATCH] series can be done by
customizing the Subject: line:
$ git publish --to patches@example.org --subject-prefix RFC
Using this way, specified "--subject-prefix" will be stored as
per-branch subject prefix, and will be used for the next git-publish
as well.
One can override the stored per-branch subject prefix by providing the
--subject-prefix parameter again, or to clear it permanently, we can use:
$ git publish --clear-subject-prefix
git-publish remembers the list of addresses CC'd on previous revisions
of a patchset by default. To clear that internal list:
$ git publish --to patches@example.org --forget-cc --cc new@example.org
In the above example, new@example.org will be saved to the internal list
for next time.
CC addresses accumulate and cascade. Following the previous example, if we
want to send a new version to both new@example.org and old@example.org:
$ git-publish --cc old@example.org
To temporarily ignore any CCs in the profile or saved list, and send only to
the addresses specified on the CLI:
$ git-publish --override-cc --cc onetime@example.org --to patches@example.org
CCs specified alongside --override-cc are not remembered for future revisions.
$ git publish --to patches@example.org --notes
To include git-notes into a patch.
One can attach notes to a commit with `git notes add <object>`. For having the
notes "following" a commit on rebase operation, you can use
`git config notes.rewriteRef refs/notes/commits`. For more information,
give a look at L<git-notes(1)>.
=head2 Creating profiles for frequently used projects
Instead of providing command-line options each time a patch series is
published, the options can be stored in L<git-config(1)> files:
$ cat >>.git/config
[gitpublishprofile "example"]
prefix = PATCH for-example
to = patches@example.org
cc = maintainer1@example.org
cc = maintainer2@example.org
^D
$ git checkout first-feature
$ git publish --profile example
$ git checkout second-feature
$ git publish --profile example
The "example" profile is equivalent to the following command-line:
$ git publish --subject-prefix 'PATCH for-example' --to patches@example.org --cc maintainer1@example.org --cc maintainer2@example.org
If command-line options are given together with a profile, then the
command-line options take precedence.
The following profile options are available:
[gitpublishprofile "example"]
base = v2.1.0 # same as --base
remote = origin # used if branch.<branch-name>.remote not set
prefix = PATCH # same as --patch
to = patches@example.org # same as --to
cc = maintainer@example.org # same as --cc
suppresscc = all # same as --suppress-cc
message = true # same as --message
signoff = true # same as --signoff
inspect-emails = true # same as --inspect-emails
notes = true # same as --notes
blurb-template = A blurb template # same as --blurb-template
The special "default" profile name is active when no --profile command-line
option was given. The default profile does not set any options but can be
extended in L<git-config(1)> files:
$ cat >>.git/config
[gitpublishprofile "default"]
suppresscc = all # do not auto-cc people
If a file named .gitpublish exists in the repository top-level directory, it is
automatically searched in addition to the L<git-config(1)> .git/config and
~/.gitconfig files. Since the .gitpublish file can be committed into git, this
can be used to provide a default profile for branches that you expect to
repeatedly use as a base for new work.
=head2 Sending pull requests
git-publish can send signed pull requests. Signed tags are pushed to a remote
git repository that must be readable by the person who will merge the pull
request.
Ensure that the branch has a default remote repository saved:
$ git config branch.foo.remote my-public-repo
The remote must be accessible to the person receiving the pull request.
Normally the remote URI should be git:// or https://. If the remote is
configured for ssh:// then L<git-config(1)> can be supplemented with a public url
and private pushurl. This ensures that pull requests always use the public
URI:
[remote "<name>"]
url = https://myhost.com/repo.git
pushurl = me@myhost.com:repo.git
Send a pull request:
$ git publish --pull-request --to patches@example.org --annotate
=head1 CONFIGURATION
There are three possible levels of configuration with the following order of precedence:
=over 4
=item 1. Per-branch options only apply to a specific branch.
=item 2. Per-profile options apply when the profile is enabled with B<--profile>.
=item 3. Global options apply in all cases.
=back
The following configuration options are available:
=over 4
=item B<branch.BRANCHNAME.gitpublishbase>
=item B<gitpublishprofile.PROFILENAME.base>
=item B<git-publish.base>
Same as the B<--base> option.
=item B<branch.BRANCHNAME.gitpublishto>
=item B<gitpublishprofile.PROFILENAME.to>
Same as the B<--to> option.
=item B<branch.BRANCHNAME.gitpublishcc>
=item B<gitpublishprofile.PROFILENAME.cc>
Same as the B<--cc> option.
=item B<branch.BRANCHNAME.gitpublishcccmd>
=item B<gitpublishprofile.PROFILENAME.gitpublishcccmd>
Same as the B<--cc-cmd> option.
=item B<gitpublishprofile.PROFILENAME.remote>
The remote where the pull request tag will be pushed.
=item B<gitpublishprofile.PROFILENAME.message>
Same as the B<--message> option.
=item B<branch.BRANCHNAME.gitpublishprefix>
=item B<gitpublishprofile.PROFILENAME.prefix>
Same as the B<--subject-prefix> option.
=item B<gitpublishprofile.PROFILENAME.suppresscc>
Same as the B<--suppress-cc> option.
=item B<gitpublishprofile.PROFILENAME.signoff>
Same as the B<--signoff> option.
=item B<gitpublishprofile.PROFILENAME.inspect-emails>
Same as the B<--inspect-emails> option.
=item B<gitpublishprofile.PROFILENAME.notes>
Same as the B<--notes> option.
=item B<gitpublishprofile.PROFILENAME.checkUrl>
=item B<git-publish.checkUrl>
Same as the B<--no-check-url> and B<--check-url> options.
=item B<gitpublishprofile.PROFILENAME.signPull>
=item B<git-publish.signPull>
Same as the B<--no-sign-pull> and B<--sign-pull> options.
=item B<git-publish.signingkey>
Same as the B<--keyid> option.
=back
=head1 HOOKS
git-publish supports the L<githooks(5)> mechanism for running user scripts at
important points during the workflow. The script can influence the outcome of
the operation, for example, by rejecting a patch series that is about to be
sent out.
Available hooks include:
=over 4
=item B<pre-publish-send-email>
Invoked before L<git-send-email(1)>. Takes the path to the patches directory
as an argument. If the exit code is non-zero, the series will not be sent.
=item B<pre-publish-tag>
Invoked before creating the -staging tag on current branch. Takes one argument
which refers to the base commit or branch. If the exit code is non-zero,
git-publish will abort.
=back
=head1 SEE ALSO
L<git-format-patch(1)>, L<git-send-email(1)>, L<git-config(1)>, L<git-notes(1)>, L<githooks(5)>
=head1 AUTHOR
Stefan Hajnoczi L<mailto:stefanha@gmail.com>
=head1 COPYRIGHT
Copyright (C) 2011-2018 Stefan Hajnoczi
|