| 1 |
AERC-PATCH(7) |
| 2 |
|
| 3 |
# NAME |
| 4 |
|
| 5 |
aerc-patch - local patch management for *aerc*(1) |
| 6 |
|
| 7 |
# SYNOPSIS |
| 8 |
|
| 9 |
*aerc* provides support for managing local patch sets. In an email-based |
| 10 |
software development workflow, there are usually many different locally applied |
| 11 |
patch series for testing and reviewing. Managing the local repository can thus |
| 12 |
be challenging. With the local patch management system, *aerc* facilitates this |
| 13 |
bookkeeping process. |
| 14 |
|
| 15 |
When applying a patch set, *aerc* creates a tag for those commits. With this |
| 16 |
tag, the patch set can be tracked and later dropped if needed. Patches are |
| 17 |
stored in a project data structure which also keeps track of the directory where |
| 18 |
the repository is. Multiple code bases can be tracked by defining a separate |
| 19 |
project for each. |
| 20 |
|
| 21 |
# COMMANDS |
| 22 |
|
| 23 |
The following *:patch* sub-commands are supported: |
| 24 |
|
| 25 |
*:patch init* [*-f*] [_<project>_] |
| 26 |
Creates a new project _<project>_. If _<project>_ is not defined, *aerc* |
| 27 |
will use the last element of the current directory path. It also |
| 28 |
performs a search for a supported repository in the current directory. |
| 29 |
|
| 30 |
*-f*: Overwrite an existing project. |
| 31 |
|
| 32 |
*:patch list* [*-a*]++ |
| 33 |
*:patch ls* [*-a*] |
| 34 |
Lists the current project with the tracked patch sets. |
| 35 |
|
| 36 |
*-a*: Lists all projects. |
| 37 |
|
| 38 |
*:patch apply* [*-c* _<cmd>_] [*-w* _<commit-ish>_] _<tag>_ |
| 39 |
Applies the selected message(s) to the repository of the current |
| 40 |
project. It uses the *:pipe* command for this and keeps track of the |
| 41 |
applied patch. |
| 42 |
|
| 43 |
Completions for the _<tag>_ are available based on the subject lines of |
| 44 |
the selected or marked messages. |
| 45 |
|
| 46 |
*-c* _<cmd>_: Apply patches with the provided _<cmd>_. Any occurrence of |
| 47 |
'%r' in the command string will be replaced with the root directory of |
| 48 |
the current project. Note that this approach is not recommended in |
| 49 |
general and should only be used for very specific purposes, i.e. when |
| 50 |
a maintainer is applying a patch set via a separate script to deal with |
| 51 |
git trailers. |
| 52 |
|
| 53 |
*aerc* will propose completions for the _<tag>_ based on the subject |
| 54 |
lines of the selected or marked messages. |
| 55 |
|
| 56 |
Example: |
| 57 |
``` |
| 58 |
:patch apply -c "git -C %r am -3" fix_v2 |
| 59 |
``` |
| 60 |
|
| 61 |
*-w* _<commit-ish>_: Create a linked worktree for the current project at |
| 62 |
_<commit-ish>_ and apply the patches to the linked worktree. A new |
| 63 |
project is created to store the worktree information. When this project |
| 64 |
is deleted, the worktree will be deleted as well. |
| 65 |
|
| 66 |
Example: |
| 67 |
``` |
| 68 |
:patch apply -w origin/master fix_v2 |
| 69 |
``` |
| 70 |
|
| 71 |
*:patch drop* _<tag>_ |
| 72 |
Drops the patch _<tag>_ from the repository. |
| 73 |
|
| 74 |
*:patch rebase* [_<commit-ish>_] |
| 75 |
Rebases the patch data on commit _<commit-ish>_. |
| 76 |
|
| 77 |
If the _<commit-ish>_ is omitted, *aerc* will use the base commit of |
| 78 |
the current project for the rebase. |
| 79 |
|
| 80 |
*:patch find* [*-f*] _<commit-hash>_ |
| 81 |
Searches the messages in the current folder of the current account for |
| 82 |
the message associated with this _commit hash_ based on the subject line. |
| 83 |
|
| 84 |
If a Message-ID is linked to a commit (i.e. when *:patch apply* was |
| 85 |
used) then *find* will first perform a search for the Message-ID. |
| 86 |
|
| 87 |
*-f*: Filter the message list instead of just showing the search |
| 88 |
results. Only effective when search for Message-ID was not successful. |
| 89 |
|
| 90 |
*:patch cd* |
| 91 |
Changes the working directory to the root directory of the current |
| 92 |
project. |
| 93 |
|
| 94 |
*:patch term* [_<cmd>_] |
| 95 |
Opens a shell (or runs _<cmd>_) in the working directory of the |
| 96 |
current project. |
| 97 |
|
| 98 |
*:patch switch* _<project>_ |
| 99 |
Switches the context to _<project>_. |
| 100 |
|
| 101 |
*:patch unlink* [_<project>_] |
| 102 |
Deletes all patch tracking data for _<project>_ and unlinks it from |
| 103 |
a repository. If no project is provided, the current project is deleted. |
| 104 |
|
| 105 |
*:patch* |
| 106 |
Root command for patch management. Use it to run the sub-commands. |
| 107 |
|
| 108 |
# GETTING STARTED |
| 109 |
|
| 110 |
Make sure you have an initialized project (see *:patch init*). |
| 111 |
|
| 112 |
Now, there are two ways to get patches under the local patch management system: |
| 113 |
|
| 114 |
- Apply patches with the *:patch apply* command. This will automatically create |
| 115 |
a new tag for the applied commits. |
| 116 |
|
| 117 |
- Use *:patch rebase*. If there are some existing local patches in the commit |
| 118 |
history that should be managed by *aerc*, you can run *:patch rebase |
| 119 |
<commit-ish>* and set the _<commit-ish>_ to the commit before the first patch |
| 120 |
that you want to include. For a *git* repository which has an upstream called |
| 121 |
*origin*, you would run *:patch rebase origin/master*. |
| 122 |
|
| 123 |
# EXAMPLE |
| 124 |
|
| 125 |
The following example demonstrates how to manage the local patch sets. |
| 126 |
|
| 127 |
First, a project needs to be initialized. This is done by changing into the |
| 128 |
working directory where the project's repository is located. For this example, |
| 129 |
let's assume we have a project called _bar_ in the directory |
| 130 |
_/home/user/foo/bar_. |
| 131 |
|
| 132 |
``` |
| 133 |
:cd /home/user/foo/bar |
| 134 |
``` |
| 135 |
|
| 136 |
and then creating a new project with |
| 137 |
|
| 138 |
``` |
| 139 |
:patch init |
| 140 |
``` |
| 141 |
|
| 142 |
If no name is provided to *:patch init*, *aerc* will use the last element of the |
| 143 |
working directory path (here: _bar_). |
| 144 |
|
| 145 |
Now the patch tracking is ready for action. Go to the message list, mark a patch |
| 146 |
series and apply it: |
| 147 |
|
| 148 |
``` |
| 149 |
:patch apply fix_v2 |
| 150 |
``` |
| 151 |
|
| 152 |
This will apply the selected patch set and assigns the _fix_v2_ tag to those |
| 153 |
commits. The tag helps to keep the commits grouped together, and will be helpful |
| 154 |
when we want to drop this exact patch set at a later point. |
| 155 |
|
| 156 |
With *:patch list* you can verify that the patch set was correctly applied. |
| 157 |
|
| 158 |
If there is a change in the underlying repository (e.g. by rebasing to |
| 159 |
upstream), the hashes of the applied local commits can change. *:patch list* can |
| 160 |
detect such a change and will then propose to rebase the internal data. To |
| 161 |
do this, run |
| 162 |
|
| 163 |
``` |
| 164 |
:patch rebase |
| 165 |
``` |
| 166 |
|
| 167 |
This will open an editor where you can adjust the correct tags again. You could |
| 168 |
also change the rebase point by providing an optional argument (e.g. a commit |
| 169 |
hash, or even _HEAD~3_ or _origin/master_, etc.). |
| 170 |
|
| 171 |
To drop a patch set, use the tag that was assigned during applying: |
| 172 |
|
| 173 |
``` |
| 174 |
:patch drop fix_v2 |
| 175 |
``` |
| 176 |
|
| 177 |
And to delete the project data in *aerc*: |
| 178 |
|
| 179 |
``` |
| 180 |
:patch unlink bar |
| 181 |
``` |
| 182 |
|
| 183 |
# SUPPORTED REVISION CONTROL SYSTEMS |
| 184 |
|
| 185 |
The supported revision control systems are currently: *git*. |
| 186 |
|
| 187 |
# SEE ALSO |
| 188 |
|
| 189 |
*aerc*(1) |
| 190 |
|
| 191 |
# AUTHORS |
| 192 |
|
| 193 |
Originally created by Drew DeVault and maintained by Robin Jarry who is assisted |
| 194 |
by other open source contributors. For more information about aerc development, |
| 195 |
see _https://sr.ht/~rjarry/aerc/_. |