├── .github └── workflows │ └── ci.yml ├── LICENSE ├── README.rst ├── bash_completion ├── doc ├── getting-started.rst ├── images │ ├── Makefile │ ├── umpf-relationships.dia │ └── umpf-relationships.svg ├── inner-workings.rst ├── tips.rst └── what-is-an-umpf.rst ├── meson.build ├── pre-commit ├── tests ├── conflict-failed.ref ├── meson.build ├── prepare-version-branch ├── rr-cache │ └── c9259255a842348141be2aea691c9356907920ee │ │ ├── postimage │ │ └── preimage ├── run-test ├── series-conflict-flags-v2.ref ├── series-conflict-v3.ref ├── series-empty-v2.ref ├── series-format-patch-bb.ref ├── series-format-patch.ref ├── series-merge.ref ├── series-upstreamstatus-v2.ref ├── series-v1.ref ├── series-v2.ref ├── test-git │ ├── HEAD │ ├── config │ ├── description │ ├── info │ │ ├── exclude │ │ └── refs │ ├── objects │ │ ├── info │ │ │ ├── commit-graph │ │ │ └── packs │ │ └── pack │ │ │ ├── pack-308eb06292fe3f86a68fa9e5d6a98201d268f7f9.bitmap │ │ │ ├── pack-308eb06292fe3f86a68fa9e5d6a98201d268f7f9.idx │ │ │ └── pack-308eb06292fe3f86a68fa9e5d6a98201d268f7f9.pack │ ├── packed-refs │ └── refs │ │ └── empty ├── umpf-build-tag ├── umpf-build-tag-identical ├── umpf-build-tag-upstreamstatus ├── umpf-distribute ├── umpf-format-patch ├── umpf-format-patch-bb ├── umpf-init ├── umpf-merge ├── umpf-merge-build ├── umpf-series-build ├── umpf-series-tag ├── umpf-series-tag-continue ├── umpf-series-tag-continue-flags ├── umpf-series-tag-empty ├── umpf-series-tag-rerere ├── umpf-show ├── umpf-versions └── version-files │ ├── ref │ ├── Makefile │ ├── Makefile.conflictfree │ ├── meson.build-gstreamer-1.18.0 │ ├── meson.build-mesa-21.3.0 │ └── meson.build-mesa-23.0.0-rc1 │ └── src │ ├── Makefile │ ├── meson.build-gstreamer-1.18.0 │ ├── meson.build-mesa-21.3.0 │ └── meson.build-mesa-23.0.0-rc1 └── umpf /.github/workflows/ci.yml: -------------------------------------------------------------------------------- 1 | name: CI 2 | 3 | on: 4 | push: 5 | pull_request: 6 | workflow_dispatch: 7 | 8 | jobs: 9 | linux: 10 | runs-on: ubuntu-latest 11 | steps: 12 | - name: Checkout 13 | uses: actions/checkout@v3 14 | 15 | - name: Run shellcheck 16 | run: shellcheck -S warning umpf 17 | 18 | - name: Setup Python 19 | uses: actions/setup-python@v4 20 | with: 21 | python-version: '3.x' 22 | 23 | - name: Install Meson & Ninja 24 | run: pip install meson ninja 25 | 26 | - name: Setup builddir 27 | run: meson setup builddir/ 28 | 29 | - name: Run tests 30 | run: meson test -C builddir/ 31 | 32 | - name: Dump test log 33 | if: failure() 34 | run: cat builddir/meson-logs/testlog.txt 35 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2022 Pengutronix 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.rst: -------------------------------------------------------------------------------- 1 | ========================================= 2 | UMPF - Universal Magic Patch Functionator 3 | ========================================= 4 | 5 | umpf is a tool that helps you manage git branches and combine them into a 6 | software release. It can create tags and export the changes as a patch 7 | stack. umpf was originally designed for the Linux kernel but it can be used 8 | for other projects as well. 9 | 10 | Motivation 11 | ========== 12 | 13 | There are several reasons why commits are split into multiple branches: 14 | 15 | * Some but not all features may be shared among multiple projects. 16 | Separate branches make it possible to avoid unnecessary changes to a 17 | specific release. 18 | 19 | * A set of commits are developed for upstream. Keeping the commits on a 20 | separate branch makes further development and upstreaming easier. 21 | 22 | * A branch may be created from a patch series collected from a mailing 23 | list. Keeping it separate makes it easier to update to a new version. 24 | 25 | So working with multiple branches makes patch handling and further 26 | development easier. But combining those branches to a release can be 27 | tedious and error prone. 28 | 29 | This is where umpf comes in. It automates the process of creating releases. 30 | It creates tags in a reproducible way. And it can create patch series from 31 | those tags. 32 | 33 | Installation 34 | ============ 35 | 36 | umpf is a bash script, so no installation is necessary. It just needs a few 37 | command line tools such as sed, grep and of course git. 38 | 39 | To enable bash completion, make sure umpf is in your ``$PATH``, then:: 40 | 41 | $ mkdir -p ~/.local/share/bash-completion/completions 42 | $ ln -s /path/to/umpf/bash_completion ~/.local/share/bash-completion/completions/umpf 43 | 44 | Documentation 45 | ============= 46 | 47 | ``umpf -h`` gives a basic description of the command line arguments. 48 | More details about umpf can be found in the documentation. 49 | 50 | * `What is an umpf?`_ 51 | * `Getting Started`_ 52 | * `umpf from the Inside`_ 53 | * `Tips and Tricks`_ 54 | 55 | License and Developing 56 | ====================== 57 | 58 | To contribute to umpf please prepare a pull request on Github. To make 59 | is possible to include your modifications it's required that your code 60 | additions are licensed under the same terms as umpf itself. So you are 61 | required to agree to the following document: 62 | 63 | Developer's Certificate of Origin 1.1 64 | 65 | By making a contribution to this project, I certify that: 66 | 67 | (a) The contribution was created in whole or in part by me and I 68 | have the right to submit it under the open source license 69 | indicated in the file; or 70 | 71 | (b) The contribution is based upon previous work that, to the best 72 | of my knowledge, is covered under an appropriate open source 73 | license and I have the right under that license to submit that 74 | work with modifications, whether created in whole or in part 75 | by me, under the same open source license (unless I am 76 | permitted to submit under a different license), as indicated 77 | in the file; or 78 | 79 | (c) The contribution was provided directly to me by some other 80 | person who certified (a), (b) or (c) and I have not modified 81 | it. 82 | 83 | (d) I understand and agree that this project and the contribution 84 | are public and that a record of the contribution (including all 85 | personal information I submit with it, including my sign-off) is 86 | maintained indefinitely and may be redistributed consistent with 87 | this project or the open source license(s) involved. 88 | 89 | Your agreement is expressed by adding a sign-off line to each of your 90 | commits (e.g. using ``git commit -s``) looking as follows: 91 | 92 | Signed-off-by: Random J Developer 93 | 94 | with your identity and email address matching the commit meta data. 95 | 96 | .. _`What is an umpf?`: doc/what-is-an-umpf.rst 97 | .. _`Getting Started`: doc/getting-started.rst 98 | .. _`Tips and Tricks`: doc/tips.rst 99 | .. _`umpf from the Inside`: doc/inner-workings.rst 100 | -------------------------------------------------------------------------------- /bash_completion: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | _umpf_completion() 4 | { 5 | local cmd _umpf_cmd 6 | local -a completion_opts completion_cmds 7 | _umpf_cmd="${COMP_WORDS[0]}" 8 | completion_opts=( $(_parse_help umpf) ) 9 | completion_cmds=( $("${_umpf_cmd}" --help | sed -n 's/^ \([^ -][^ ]*\) .*$/\1/p') ) 10 | _init_completion -s || return 11 | 12 | case "${prev}" in 13 | --patchdir|-p) 14 | _filedir -d 15 | return 0 16 | ;; 17 | --remote|-r) 18 | COMPREPLY+=($( compgen -W "$(git remote) refs/heads" -- $cur ) ) 19 | return 0 20 | ;; 21 | *) 22 | ;; 23 | esac 24 | for (( i=1 ; i<${cword}; i++ )); do 25 | local tmp="${words[i]}" 26 | case "${tmp}" in 27 | -p|-r) 28 | i=$[i+1] 29 | ;; 30 | -*) 31 | ;; 32 | *) 33 | cmd="${tmp}" 34 | ;; 35 | esac 36 | done 37 | case ${cmd} in 38 | "") 39 | COMPREPLY=( $( compgen -W "${completion_cmds[*]} help" -- $cur ) ) 40 | ;; 41 | diff|show|tag|tig|build) 42 | local -a refs 43 | refs=( $( compgen -W "$( git for-each-ref --format='%(refname:short)' refs/tags refs/heads refs/remotes)" -- $cur ) ) 44 | if [ ${#refs[@]} -eq 0 ]; then 45 | COMPREPLY=( $( compgen -f -- $cur ) ) 46 | compopt -o filenames 47 | else 48 | COMPREPLY=( "${refs[@]}" ) 49 | fi 50 | ;; 51 | merge) 52 | COMPREPLY=( $( compgen -W "$( git for-each-ref --format='%(refname:short)' refs/heads refs/remotes)" -- $cur ) ) 53 | ;; 54 | format-patch) 55 | COMPREPLY=( $( compgen -W "$( git for-each-ref --format='%(refname:short)' refs/tags)" -- $cur ) ) 56 | ;; 57 | esac 58 | COMPREPLY+=( $( compgen -W "${completion_opts[*]}" -- $cur ) ) 59 | [[ $COMPREPLY == *= ]] && compopt -o nospace 60 | return 0 61 | } && 62 | complete -F _umpf_completion umpf 63 | -------------------------------------------------------------------------------- /doc/getting-started.rst: -------------------------------------------------------------------------------- 1 | Getting Started 2 | =============== 3 | 4 | For illustration, let's say we have two topic branches which we want to merge 5 | into a release:: 6 | 7 | ~/linux (master) $ git log --graph --oneline v5.0^..v5.0/topic/fixes v5.0^..v5.0/topic/more-fixes 8 | 9 | * 157d32af15330 (HEAD -> v5.0/topic/more-fixes) fix: newer gcc need explicit stdio.h include 10 | * d923fd6c8a01a fix compilation with gcc-8 11 | | * 1ad3cc4c7d974 (v5.0/topic/fixes) drivers: add support for tertiary frobnicated flectrospector 12 | | * 77009bb7be0c9 drivers: net: refactor variable names 13 | |/ 14 | * 1c163f4c7b3f6 (tag: v5.0) Linux 5.0 15 | 16 | We can get to a release tag in two ways: via a *useries* file or via 17 | *umerges*. The way you choose depends on your usual workflow; 18 | 19 | * A BSP developer who is used to work with patch series will likely choose the 20 | *useries* way to start an umpf. 21 | * An upstream developer who is used to work with git merges will likely find 22 | themselves more comfortable with a *umerge*. 23 | 24 | But note that both ways will get you an equivalent result. 25 | 26 | 27 | Starting with a *useries* 28 | ------------------------- 29 | 30 | We start by creating a *useries* file with umpf which describes the name of our 31 | umpf, and the branches we want to merge together. This can be done with 32 | ``umpf init``, an interactive command that will prompt for all the 33 | necessary information:: 34 | 35 | ~/linux (master) $ umpf init useries 36 | 37 | base: v5.0 38 | name: 5.0/special-customer-release 39 | topic: v5.0/topic/fixes 40 | topic: v5.0/topic/more-fixes 41 | topic: 42 | 43 | - *base* specifies the commitish you want all your branches to be based on. 44 | This will most likely be an upstream release tag, so we use ``v5.0`` here. 45 | - *name* is the name of the umpf, which will be used for umpf tags. Make sure 46 | it doesn't conflict with any tags or branches in the repository - especially 47 | the umpf name cannot start with an already existing ref! That is why we use 48 | ``5.0/…`` here instead of ``v5.0/…``. 49 | - *topic* specifies the branches to merge, one by line. End with an empty line. 50 | For illustration, we merge two branches with random fixes, which we already 51 | have created before on top of our base commit. 52 | In reality, these will most probably be independent (possibly long-lived) 53 | feature branches which you want to merge into a release. 54 | It is not important that the branches start at the base, but they should be 55 | mergeable without conflicts. [#without-conflicts]_ 56 | 57 | .. [#without-conflicts] unless you really like solving conflicts during merges… 58 | 59 | umpf now created the file *useries*, as specified on the command line, and 60 | filled it with the information we fed it:: 61 | 62 | ~/linux (master) $ cat useries 63 | 64 | # umpf-base: v5.0 65 | # umpf-name: 5.0/special-customer-release 66 | # umpf-topic: v5.0/topic/fixes 67 | # umpf-topic: v5.0/topic/more-fixes 68 | # umpf-end 69 | 70 | If you ever want to merge additional branches for the release, add them to the 71 | file as new ``umpf-topic:`` lines before ``umpf-end``. 72 | 73 | This form of plain *useries* is an unqualified form of umpf, 74 | and we need to transform it into another form to make it qualified. 75 | 76 | Why is this form of *useries* unqualified? 77 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 78 | 79 | Suppose you want to create a patch stack from the above *useries* file. 80 | Creating a patch stack is done with umpf's *format-patch* command. 81 | But when you try that on your file… 82 | 83 | :: 84 | 85 | ~/linux ((v5.0)) $ umpf format-patch ./useries 86 | 87 | umpf: Cannot run 'format_patch' without a 'topic-range' for each 'topic'! Maybe you need to 'tag' first? 88 | 89 | … umpf refuses to work with it. 90 | 91 | To create a linear patch stack, umpf needs to know two things: 92 | 93 | 1. how to put the commits from your referenced branches into a linear order, 94 | 2. and how to call the result 95 | 96 | Often the first part is more difficult than the second, 97 | as it includes solving possible conflicts between the topic branches. 98 | Therefore we must first preprocess our *useries* into a form that 99 | contains information about the linear commits. 100 | 101 | Transforming a *useries* into a *umerge* 102 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 103 | 104 | From this *useries* file, we can now build a *umerge*:: 105 | 106 | ~/linux (master) $ umpf build ./useries 107 | 108 | umpf: Remote undefined. Choose the branch with the correct remote: 109 | 0) v5.0/topic/fixes 110 | branch number: 0 111 | umpf: Using remote 'refs/heads/'. 112 | umpf: merging 'v5.0/topic/fixes'... 113 | Merge made by the 'recursive' strategy. 114 | drivers/Kconfig | 2 ++ 115 | drivers/Makefile | 2 ++ 116 | drivers/frob/Kconfig | 5 +++++ 117 | drivers/frob/Makefile | 3 +++ 118 | drivers/net/virtio_net.c | 48 ++++++++++++++++++++++++------------------------ 119 | 5 files changed, 36 insertions(+), 24 deletions(-) 120 | create mode 100644 drivers/frob/Kconfig 121 | create mode 100644 drivers/frob/Makefile 122 | umpf: merging 'v5.0/topic/more-fixes'... 123 | Merge made by the 'recursive' strategy. 124 | include/net/ip.h | 7 +++++++ 125 | 1 file changed, 7 insertions(+) 126 | 127 | umpf first asks us which remote we want to use to resolve the topic branch 128 | names specified in the *useries* file. 129 | We assume that we haven't pushed the branches to a remote yet, 130 | and we choose the default (our local repository). 131 | 132 | :: 133 | 134 | ~/linux ((b1e3a4169267a...)) $ git log --graph --oneline v5.0^.. 135 | 136 | * b1e3a4169267a (HEAD) Merge 'v5.0/topic/more-fixes' into 5.0/special-customer-release 137 | |\ 138 | | * 157d32af15330 (v5.0/topic/more-fixes) fix: newer gcc need explicit stdio.h include 139 | | * d923fd6c8a01a fix compilation with gcc-8 140 | * | 600966fede13d Merge 'v5.0/topic/fixes' into 5.0/special-customer-release 141 | |\ \ 142 | | |/ 143 | |/| 144 | | * 1ad3cc4c7d974 (v5.0/topic/fixes) drivers: add support for tertiary frobnicated flectrospector 145 | | * 77009bb7be0c9 drivers: net: refactor variable names 146 | |/ 147 | * 1c163f4c7b3f6 (tag: v5.0) Linux 5.0 148 | 149 | After umpf has finished, we can see that all our topic branches have been 150 | merged in the order they were specified. 151 | You can now give that *umerge* a branch name (``git checkout -b ``) and use 152 | it to develop on top of both feature branches. 153 | If you commit your results and want to have them applied to one of your merged 154 | feature branches, use ``umpf distribute``. 155 | 156 | If you inspect the merge commit, you see that this type of *umerge* is fully 157 | qualified since umpf has saved the info from the *useries* file:: 158 | 159 | ~/linux ((b1e3a4169267a...)) $ git show --notes 160 | 161 | commit b1e3a4169267af89533f2105de69e673c94a80e0 (HEAD) 162 | Merge: 600966fede13d 157d32af15330 163 | Author: Your Name 164 | Date: 2019-03-11 15:35:45 165 | 166 | Merge 'v5.0/topic/more-fixes' into 5.0/special-customer-release 167 | 168 | umpf-merge-topic: v5.0/topic/more-fixes 169 | 170 | Notes: 171 | umpf-build-note: v5.0 5.0/special-customer-release 172 | 173 | Therefore we can directly use that *umerge* to build a *utag* – see below. 174 | 175 | 176 | Starting with a *umerge* 177 | ------------------------ 178 | 179 | Based on the state of our two example topic branches, we can also create a 180 | *umerge* directly without the need for a temporary *useries* file. 181 | For that, we first check out the tag which we want to use as 'base', 182 | and then *umerge* our two topic branches:: 183 | 184 | ~/linux (master) $ git checkout v5.0 185 | 186 | ~/linux ((v5.0)) $ umpf merge v5.0/topic/fixes 187 | 188 | umpf: merging 'v5.0/topic/fixes'... 189 | Merge made by the 'recursive' strategy. 190 | drivers/Kconfig | 2 ++ 191 | drivers/Makefile | 2 ++ 192 | drivers/frob/Kconfig | 5 +++++ 193 | drivers/frob/Makefile | 3 +++ 194 | drivers/net/virtio_net.c | 48 ++++++++++++++++++++++++------------------------ 195 | 5 files changed, 36 insertions(+), 24 deletions(-) 196 | create mode 100644 drivers/frob/Kconfig 197 | create mode 100644 drivers/frob/Makefile 198 | 199 | ~/linux ((e92a0fbd2661a...)) $ umpf merge v5.0/topic/more-fixes 200 | 201 | umpf: merging 'v5.0/topic/more-fixes'... 202 | Merge made by the 'recursive' strategy. 203 | include/net/ip.h | 7 +++++++ 204 | 1 file changed, 7 insertions(+) 205 | 206 | .. note:: 207 | 208 | If the merge failed then you probably don't have a local branch 209 | with that name yet, and intended to merge a remote branch. 210 | ``umpf merge`` works like ``git merge``, that is, you give it a commit-ish 211 | which it should merge. 212 | But when merging, umpf needs to determine the name of the topic branch, 213 | so in that case you have to tell it what the name of the remote is, 214 | so umpf can strip it from the branch name:: 215 | 216 | $ umpf merge --remote=origin origin/v5.0/topic/more-fixes 217 | 218 | If you often merge remote branches from the same remote, 219 | you can configure the default remote in the git config, 220 | and leave out the ``--remote=`` argument:: 221 | 222 | $ git config umpf.fallback-remote origin 223 | 224 | By inspecting the merge commits, you see that umpf has recorded additional info 225 | in the commit message:: 226 | 227 | ~/linux ((7220a1f96a989...)) $ git show 228 | 229 | commit 7220a1f96a9895e6942a753bdf1ab6f375d2fc19 (HEAD) 230 | Merge: e92a0fbd2661a 157d32af15330 231 | Author: Your Name 232 | Date: 2019-03-11 15:42:56 233 | 234 | Merge 'v5.0/topic/more-fixes' 235 | 236 | umpf-merge-topic: v5.0/topic/more-fixes 237 | 238 | Now you can work on top of both branches and develop patches locally. When you 239 | have finished, use ``umpf distribute`` like described above. 240 | 241 | 242 | Building a *utag* 243 | ----------------- 244 | 245 | umpf can build a *utag* from a *umerge* or from a *useries*. 246 | 247 | From a *useries* 248 | ~~~~~~~~~~~~~~~~ 249 | 250 | If we want to build a release tag from a useries file, we use 251 | ``umpf tag`` on the useries file:: 252 | 253 | ~/linux (master) $ umpf tag ./useries 254 | 255 | # umpf-base: v5.0 256 | # umpf-name: 5.0/special-customer-release 257 | # umpf-version: 5.0/special-customer-release/20190311-1 258 | umpf: Remote undefined. Choose the branch with the correct remote: 259 | 0) v5.0/topic/fixes 260 | branch number: 0 261 | umpf: Using remote 'refs/heads/'. 262 | # umpf-topic: v5.0/topic/fixes 263 | # umpf-hashinfo: 1ad3cc4c7d974311f5f5a2e55d69be15fdf917cd 264 | # umpf-topic-range: 1c163f4c7b3f621efff9b28a47abb36f7378d783..1ad3cc4c7d974311f5f5a2e55d69be15fdf917cd 265 | # umpf-topic: v5.0/topic/more-fixes 266 | # umpf-hashinfo: 157d32af153309246d7cc8a4f283299d751d6077 267 | # umpf-topic-range: 1ad3cc4c7d974311f5f5a2e55d69be15fdf917cd..8bae5bbec8cb4599c141405e9755b7c0e42e064f 268 | [detached HEAD 19cdc2b857e6] Release 5.0/special-customer-release/20190311-1 269 | 1 file changed, 1 insertion(+), 1 deletion(-) 270 | # umpf-release: 5.0/special-customer-release/20190311-1 271 | # umpf-topic-range: 8bae5bbec8cb4599c141405e9755b7c0e42e064f..19cdc2b857e662a38c712b41ce610000a5ddc6ae 272 | # umpf-end 273 | 274 | 275 | ~/linux ((5.0/special-customer-release/20190311-1)) $ git log --graph --oneline v5.0^.. 276 | 277 | *-. 7c8644d422d89 (HEAD, tag: 5.0/special-customer-release/20190311-1) 5.0/special-customer-release/20190311-1 278 | |\ \ 279 | | | * 157d32af15330 (v5.0/topic/more-fixes) fix: newer gcc need explicit stdio.h include 280 | | | * d923fd6c8a01a fix compilation with gcc-8 281 | * | | 19cdc2b857e66 (tag: 5.0/special-customer-release/20190311-1-flat) Release 5.0/special-customer-release/20190311-1 282 | * | | 8bae5bbec8cb4 fix: newer gcc need explicit stdio.h include 283 | * | | f521683d6a26c fix compilation with gcc-8 284 | |/ / 285 | * | 1ad3cc4c7d974 (v5.0/topic/fixes) drivers: add support for tertiary frobnicated flectrospector 286 | * | 77009bb7be0c9 drivers: net: refactor variable names 287 | |/ 288 | * 1c163f4c7b3f6 (tag: v5.0) Linux 5.0 289 | 290 | The commit graph now looks a bit more complex: umpf rebases the topic branches 291 | on top of each other in the order the were specified, then creates an octopus 292 | merge commit, and tags that commit with a auto-generated release tag 293 | (``5.0/special-customer-release/20190311-1`` in our case). 294 | The octopus merge records the state of the branches at the time when the *utag* 295 | was built, which makes it possible to build the *umerge* later from the *utag* and 296 | use the identical git commits. 297 | The linear rebase of topic branches onto each other (the ``-flat`` tag) is 298 | important when you want to build a useries back from a *utag* – see below. 299 | 300 | From a *umerge* 301 | ~~~~~~~~~~~~~~~ 302 | 303 | In order to build a *utag* from a *umerge*, you first have to answer 304 | questions about the *base* and the *name* of your tag, 305 | since those information was not specified before, 306 | and umpf cannot infer it automatically:: 307 | 308 | ~/linux ((7220a1f96a989...)) $ umpf tag 309 | 310 | umpf: Creating series from merges... 311 | base: v5.0 312 | name: 5.0/special-customer-release 313 | # umpf-base: v5.0 314 | # umpf-name: 5.0/special-customer-release 315 | # umpf-version: 5.0/special-customer-release/20190311-1 316 | umpf: Remote undefined. Choose the branch with the correct remote: 317 | 0) v5.0/topic/fixes 318 | branch number: 0 319 | umpf: Using remote 'refs/heads/'. 320 | # umpf-topic: v5.0/topic/fixes 321 | # umpf-hashinfo: 1ad3cc4c7d974311f5f5a2e55d69be15fdf917cd 322 | # umpf-topic-range: 1c163f4c7b3f621efff9b28a47abb36f7378d783..1ad3cc4c7d974311f5f5a2e55d69be15fdf917cd 323 | # umpf-topic: v5.0/topic/more-fixes 324 | # umpf-hashinfo: 157d32af153309246d7cc8a4f283299d751d6077 325 | # umpf-topic-range: 1ad3cc4c7d974311f5f5a2e55d69be15fdf917cd..985777b8d1e60d50dbccadee821c6c279ca7e468 326 | [detached HEAD 29e7588b6136] Release 5.0/special-customer-release/20190311-1 327 | 1 file changed, 1 insertion(+), 1 deletion(-) 328 | # umpf-release: 5.0/special-customer-release/20190311-1 329 | # umpf-topic-range: 985777b8d1e60d50dbccadee821c6c279ca7e468..29e7588b6136a81133dad1873c196d0e77ff34d9 330 | # umpf-end 331 | 332 | The *utag* now contains all the info for a fully qualified umpf:: 333 | 334 | ~/linux ((5.0/special-customer-release/20190311-1)) $ git show 335 | 336 | commit d4c8d4fee0d9594e91a51f0b85f4e97f461c5d77 (HEAD, tag: 5.0/special-customer-release/20190311-1) 337 | Merge: 29e7588b6136a 1ad3cc4c7d974 157d32af15330 338 | Author: Your Name 339 | Date: 2019-03-11 15:49:20 340 | 341 | 5.0/special-customer-release/20190311-1 342 | 343 | # umpf-base: v5.0 344 | # umpf-name: 5.0/special-customer-release 345 | # umpf-version: 5.0/special-customer-release/20190311-1 346 | # umpf-topic: v5.0/topic/fixes 347 | # umpf-hashinfo: 1ad3cc4c7d974311f5f5a2e55d69be15fdf917cd 348 | # umpf-topic-range: 1c163f4c7b3f621efff9b28a47abb36f7378d783..1ad3cc4c7d974311f5f5a2e55d69be15fdf917cd 349 | # umpf-topic: v5.0/topic/more-fixes 350 | # umpf-hashinfo: 157d32af153309246d7cc8a4f283299d751d6077 351 | # umpf-topic-range: 1ad3cc4c7d974311f5f5a2e55d69be15fdf917cd..985777b8d1e60d50dbccadee821c6c279ca7e468 352 | # umpf-release: 5.0/special-customer-release/20190311-1 353 | # umpf-topic-range: 985777b8d1e60d50dbccadee821c6c279ca7e468..29e7588b6136a81133dad1873c196d0e77ff34d9 354 | # umpf-end 355 | 356 | 357 | Building a *useries* 358 | -------------------- 359 | 360 | This is now easy, as a *utag* is fully qualified, 361 | and already contains the linear series in its first parent. 362 | Just do an ``umpf format-patch`` on the *utag*:: 363 | 364 | ~/linux ((5.0/special-customer-release/20190311-1)) $ umpf format-patch -p ../my-bsp/patches/linux-5.0/ 365 | 366 | umpf: Using series from commit message... 367 | # umpf-base: v5.0 368 | # umpf-name: 5.0/special-customer-release 369 | # umpf-version: 5.0/special-customer-release/20190311-1 370 | # umpf-topic: v5.0/topic/fixes 371 | # umpf-hashinfo: 1ad3cc4c7d974311f5f5a2e55d69be15fdf917cd 372 | # umpf-topic-range: 1c163f4c7b3f621efff9b28a47abb36f7378d783..1ad3cc4c7d974311f5f5a2e55d69be15fdf917cd 373 | 0001-drivers-net-refactor-variable-names.patch 374 | 0002-drivers-add-support-for-tertiary-frobnicated-flectro.patch 375 | # umpf-topic: v5.0/topic/more-fixes 376 | # umpf-hashinfo: 157d32af153309246d7cc8a4f283299d751d6077 377 | # umpf-topic-range: 1ad3cc4c7d974311f5f5a2e55d69be15fdf917cd..8bae5bbec8cb4599c141405e9755b7c0e42e064f 378 | 0101-fix-compilation-with-gcc-8.patch 379 | 0102-fix-newer-gcc-need-explicit-stdio.h-include.patch 380 | # umpf-release: 5.0/special-customer-release/20190311-1 381 | # umpf-topic-range: 8bae5bbec8cb4599c141405e9755b7c0e42e064f..19cdc2b857e662a38c712b41ce610000a5ddc6ae 382 | 0201-Release-5.0-special-customer-release-20190311-1.patch 383 | # umpf-end 384 | 385 | 386 | ~/linux ((5.0/special-customer-release/20190311-1)) $ ls -l ../my-bsp/patches/linux-5.0/ 387 | 388 | total 28 389 | -rw-r--r-- 1 yna users 6480 Jun 4 18:06 0001-drivers-net-refactor-variable-names.patch 390 | -rw-r--r-- 1 yna users 1609 Jun 4 18:06 0002-drivers-add-support-for-tertiary-frobnicated-flectro.patch 391 | -rw-r--r-- 1 yna users 528 Jun 4 18:06 0101-fix-compilation-with-gcc-8.patch 392 | -rw-r--r-- 1 yna users 485 Jun 4 18:06 0102-fix-newer-gcc-need-explicit-stdio.h-include.patch 393 | -rw-r--r-- 1 yna users 462 Jun 4 18:06 0201-Release-5.0-special-customer-release-20190311-1.patch 394 | -rw-r--r-- 1 yna users 938 Jun 4 18:06 series 395 | 396 | The ``series`` file in that repository is now a fully qualified useries, 397 | and can be used to recreate the *utag* in Git. 398 | 399 | 400 | Updating an *utag* 401 | ------------------ 402 | 403 | Using the metadata from an already existing tag - ``5.0/special-customer-release/190311-1`` for example - 404 | umpf can be instructed to create a fresh *utag* based on the previous metadata:: 405 | 406 | ~/linux ((5.0/special-customer-release/20190311-1)) $ umpf tag 5.0/special-customer-release/190311-1 407 | 408 | # umpf-base: v5.0 409 | # umpf-name: 5.0/special-customer-release 410 | # umpf-version: 5.0/special-customer-release/20230309-1 411 | umpf: Remote undefined. Choose the branch with the correct remote: 412 | 0) v5.0/topic/fixes 413 | branch number: 0 414 | umpf: Using remote 'refs/heads/'. 415 | # umpf-topic: v5.0/topic/fixes 416 | # umpf-hashinfo: 1ad3cc4c7d974311f5f5a2e55d69be15fdf917cd 417 | # umpf-topic-range: 1c163f4c7b3f621efff9b28a47abb36f7378d783..1ad3cc4c7d974311f5f5a2e55d69be15fdf917cd 418 | # umpf-topic: v5.0/topic/more-fixes 419 | # umpf-hashinfo: 157d32af153309246d7cc8a4f283299d751d6077 420 | # umpf-topic-range: 1ad3cc4c7d974311f5f5a2e55d69be15fdf917cd..8bae5bbec8cb4599c141405e9755b7c0e42e064f 421 | [detached HEAD 0b1994336c1a] Release 5.0/special-customer-release/20190311-1 422 | 1 file changed, 1 insertion(+), 1 deletion(-) 423 | # umpf-release: 5.0/special-customer-release/20230309-1 424 | # umpf-topic-range: 8bae5bbec8cb4599c141405e9755b7c0e42e064f..19cdc2b857e662a38c712b41ce610000a5ddc6ae 425 | # umpf-end 426 | 427 | Or tell umpf to rebase onto a new *umpf-base* when creating a fresh *utag*:: 428 | 429 | ~/linux ((5.0/special-customer-release/20190311-1)) $ umpf tag --base=v5.0.42 --version=2 5.0/special-customer-release/190311-1 430 | 431 | # umpf-base: v5.0.42 432 | # umpf-name: 5.0/special-customer-release 433 | # umpf-version: 5.0/special-customer-release/20230309-2 434 | umpf: Remote undefined. Choose the branch with the correct remote: 435 | 0) v5.0/topic/fixes 436 | branch number: 0 437 | umpf: Using remote 'refs/heads/'. 438 | # umpf-topic: v5.0/topic/fixes 439 | # umpf-hashinfo: 1ad3cc4c7d974311f5f5a2e55d69be15fdf917cd 440 | # umpf-topic-range: 1c163f4c7b3f621efff9b28a47abb36f7378d783..1ad3cc4c7d974311f5f5a2e55d69be15fdf917cd 441 | # umpf-topic: v5.0/topic/more-fixes 442 | # umpf-hashinfo: 157d32af153309246d7cc8a4f283299d751d6077 443 | # umpf-topic-range: 1ad3cc4c7d974311f5f5a2e55d69be15fdf917cd..8bae5bbec8cb4599c141405e9755b7c0e42e064f 444 | [detached HEAD e865032e1b9b] Release 5.0/special-customer-release/20190311-2 445 | 1 file changed, 1 insertion(+), 1 deletion(-) 446 | # umpf-release: 5.0/special-customer-release/20230309-2 447 | # umpf-topic-range: 8bae5bbec8cb4599c141405e9755b7c0e42e064f..19cdc2b857e662a38c712b41ce610000a5ddc6ae 448 | # umpf-end 449 | 450 | 451 | Overview 452 | -------- 453 | 454 | Finally here is an overview of *utags*, *umerges*, *useries* and how to get from one 455 | to another: 456 | 457 | .. image:: images/umpf-relationships.svg 458 | -------------------------------------------------------------------------------- /doc/images/Makefile: -------------------------------------------------------------------------------- 1 | IMAGES = images/umpf-relationships.svg 2 | 3 | all: $(IMAGES) 4 | 5 | %.svg: %.dia 6 | dia --export="$@" --filter=svg "$<" 7 | -------------------------------------------------------------------------------- /doc/images/umpf-relationships.dia: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | #A4# 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 | #useries# 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 | #umerge# 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 | #utag# 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 | #useries# 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 | #umerge# 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 | 610 | 611 | 612 | 613 | 614 | 615 | 616 | 617 | 618 | 619 | 620 | 621 | 622 | 623 | 624 | 625 | 626 | 627 | 628 | 629 | 630 | 631 | 632 | 633 | 634 | 635 | 636 | 637 | 638 | #qualified umpf# 639 | 640 | 641 | 642 | 643 | 644 | 645 | 646 | 647 | 648 | 649 | 650 | 651 | 652 | 653 | 654 | 655 | 656 | 657 | 658 | 659 | 660 | 661 | 662 | 663 | 664 | 665 | 666 | 667 | 668 | 669 | 670 | 671 | 672 | 673 | 674 | 675 | 676 | 677 | 678 | 679 | 680 | 681 | 682 | 683 | 684 | 685 | 686 | 687 | 688 | 689 | 690 | 691 | 692 | 693 | 694 | 695 | ## 696 | 697 | 698 | 699 | 700 | 701 | 702 | 703 | 704 | 705 | 706 | 707 | 708 | 709 | 710 | 711 | 712 | 713 | 714 | 715 | 716 | 717 | 718 | 719 | 720 | 721 | 722 | 723 | 724 | 725 | #unqualified umpf# 726 | 727 | 728 | 729 | 730 | 731 | 732 | 733 | 734 | 735 | 736 | 737 | 738 | 739 | 740 | 741 | 742 | 743 | 744 | 745 | 746 | 747 | 748 | 749 | 750 | 751 | 752 | 753 | 754 | 755 | 756 | 757 | 758 | 759 | 760 | 761 | 762 | 763 | 764 | 765 | 766 | 767 | 768 | 769 | 770 | 771 | 772 | 773 | 774 | 775 | 776 | 777 | 778 | 779 | 780 | 781 | 782 | 783 | 784 | 785 | 786 | 787 | 788 | 789 | 790 | 791 | #possible entry point# 792 | 793 | 794 | 795 | 796 | 797 | 798 | 799 | 800 | 801 | 802 | 803 | 804 | 805 | 806 | 807 | 808 | 809 | 810 | 811 | 812 | 813 | 814 | 815 | 816 | 817 | 818 | 819 | 820 | 821 | 822 | 823 | 824 | 825 | 826 | 827 | 828 | 829 | 830 | 831 | 832 | 833 | 834 | 835 | 836 | 837 | 838 | 839 | 840 | 841 | 842 | 843 | 844 | 845 | 846 | 847 | 848 | 849 | 850 | 851 | 852 | 853 | 854 | 855 | 856 | 857 | #commands not asking for input# 858 | 859 | 860 | 861 | 862 | 863 | 864 | 865 | 866 | 867 | 868 | 869 | 870 | 871 | 872 | 873 | 874 | 875 | 876 | 877 | 878 | 879 | 880 | 881 | 882 | 883 | 884 | 885 | 886 | 887 | 888 | 889 | 890 | 891 | 892 | 893 | 894 | 895 | 896 | 897 | 898 | 899 | 900 | 901 | 902 | 903 | 904 | 905 | 906 | 907 | 908 | 909 | 910 | 911 | 912 | 913 | 914 | 915 | 916 | 917 | 918 | 919 | 920 | 921 | 922 | 923 | 924 | 925 | 926 | 927 | 928 | 929 | 930 | 931 | 932 | 933 | 934 | 935 | 936 | 937 | 938 | 939 | 940 | 941 | 942 | 943 | 944 | 945 | 946 | 947 | 948 | 949 | 950 | 951 | 952 | 953 | 954 | 955 | 956 | 957 | 958 | 959 | 960 | 961 | 962 | 963 | 964 | 965 | 966 | 967 | 968 | 969 | 970 | 971 | 972 | 973 | 974 | 975 | 976 | 977 | 978 | 979 | 980 | 981 | 982 | 983 | 984 | 985 | 986 | 987 | 988 | 989 | 990 | 991 | 992 | 993 | 994 | 995 | 996 | 997 | 998 | 999 | 1000 | 1001 | 1002 | 1003 | 1004 | 1005 | 1006 | 1007 | 1008 | 1009 | 1010 | 1011 | 1012 | 1013 | 1014 | 1015 | 1016 | 1017 | 1018 | 1019 | 1020 | 1021 | 1022 | 1023 | 1024 | 1025 | 1026 | 1027 | 1028 | 1029 | 1030 | 1031 | 1032 | 1033 | 1034 | 1035 | 1036 | 1037 | 1038 | 1039 | 1040 | 1041 | 1042 | 1043 | 1044 | 1045 | 1046 | 1047 | 1048 | 1049 | 1050 | 1051 | 1052 | 1053 | 1054 | 1055 | 1056 | 1057 | 1058 | 1059 | 1060 | 1061 | 1062 | 1063 | 1064 | 1065 | 1066 | 1067 | 1068 | 1069 | 1070 | 1071 | 1072 | 1073 | 1074 | 1075 | 1076 | 1077 | 1078 | 1079 | 1080 | 1081 | 1082 | 1083 | 1084 | 1085 | 1086 | 1087 | 1088 | 1089 | 1090 | 1091 | 1092 | 1093 | 1094 | 1095 | 1096 | 1097 | 1098 | 1099 | 1100 | 1101 | 1102 | 1103 | 1104 | 1105 | 1106 | 1107 | 1108 | 1109 | 1110 | 1111 | 1112 | 1113 | 1114 | 1115 | 1116 | 1117 | 1118 | 1119 | 1120 | 1121 | 1122 | 1123 | 1124 | 1125 | 1126 | 1127 | 1128 | 1129 | 1130 | #commands asking for input# 1131 | 1132 | 1133 | 1134 | 1135 | 1136 | 1137 | 1138 | 1139 | 1140 | 1141 | 1142 | 1143 | 1144 | 1145 | 1146 | 1147 | 1148 | 1149 | 1150 | 1151 | 1152 | 1153 | 1154 | 1155 | 1156 | 1157 | 1158 | 1159 | 1160 | 1161 | 1162 | 1163 | 1164 | 1165 | 1166 | 1167 | 1168 | 1169 | 1170 | 1171 | 1172 | 1173 | 1174 | 1175 | 1176 | 1177 | 1178 | 1179 | 1180 | 1181 | 1182 | 1183 | 1184 | 1185 | 1186 | 1187 | 1188 | 1189 | 1190 | 1191 | 1192 | 1193 | 1194 | 1195 | 1196 | 1197 | 1198 | 1199 | 1200 | 1201 | 1202 | #merge# 1203 | 1204 | 1205 | 1206 | 1207 | 1208 | 1209 | 1210 | 1211 | 1212 | 1213 | 1214 | 1215 | 1216 | 1217 | 1218 | 1219 | 1220 | 1221 | 1222 | 1223 | 1224 | 1225 | 1226 | 1227 | 1228 | 1229 | 1230 | 1231 | 1232 | 1233 | 1234 | 1235 | 1236 | 1237 | 1238 | 1239 | 1240 | 1241 | 1242 | 1243 | 1244 | #format-patch# 1245 | 1246 | 1247 | 1248 | 1249 | 1250 | 1251 | 1252 | 1253 | 1254 | 1255 | 1256 | 1257 | 1258 | 1259 | 1260 | 1261 | 1262 | 1263 | 1264 | 1265 | 1266 | 1267 | 1268 | 1269 | 1270 | 1271 | 1272 | 1273 | 1274 | 1275 | 1276 | 1277 | 1278 | 1279 | 1280 | 1281 | 1282 | 1283 | 1284 | 1285 | 1286 | #tag# 1287 | 1288 | 1289 | 1290 | 1291 | 1292 | 1293 | 1294 | 1295 | 1296 | 1297 | 1298 | 1299 | 1300 | 1301 | 1302 | 1303 | 1304 | 1305 | 1306 | 1307 | 1308 | 1309 | 1310 | 1311 | 1312 | 1313 | 1314 | 1315 | 1316 | 1317 | 1318 | 1319 | 1320 | 1321 | 1322 | 1323 | 1324 | 1325 | 1326 | 1327 | 1328 | #tag# 1329 | 1330 | 1331 | 1332 | 1333 | 1334 | 1335 | 1336 | 1337 | 1338 | 1339 | 1340 | 1341 | 1342 | 1343 | 1344 | 1345 | 1346 | 1347 | 1348 | 1349 | 1350 | 1351 | 1352 | 1353 | 1354 | 1355 | 1356 | 1357 | 1358 | 1359 | 1360 | 1361 | 1362 | 1363 | 1364 | 1365 | 1366 | 1367 | 1368 | 1369 | 1370 | #tag# 1371 | 1372 | 1373 | 1374 | 1375 | 1376 | 1377 | 1378 | 1379 | 1380 | 1381 | 1382 | 1383 | 1384 | 1385 | 1386 | 1387 | 1388 | 1389 | 1390 | 1391 | 1392 | 1393 | 1394 | 1395 | 1396 | 1397 | 1398 | 1399 | 1400 | 1401 | 1402 | 1403 | 1404 | 1405 | 1406 | 1407 | 1408 | 1409 | 1410 | 1411 | 1412 | #build# 1413 | 1414 | 1415 | 1416 | 1417 | 1418 | 1419 | 1420 | 1421 | 1422 | 1423 | 1424 | 1425 | 1426 | 1427 | 1428 | 1429 | 1430 | 1431 | 1432 | 1433 | 1434 | 1435 | 1436 | 1437 | 1438 | 1439 | 1440 | 1441 | 1442 | 1443 | 1444 | 1445 | 1446 | 1447 | 1448 | 1449 | 1450 | 1451 | 1452 | 1453 | 1454 | #tag# 1455 | 1456 | 1457 | 1458 | 1459 | 1460 | 1461 | 1462 | 1463 | 1464 | 1465 | 1466 | 1467 | 1468 | 1469 | 1470 | 1471 | 1472 | 1473 | 1474 | 1475 | 1476 | 1477 | 1478 | 1479 | 1480 | 1481 | 1482 | 1483 | 1484 | 1485 | 1486 | 1487 | 1488 | 1489 | 1490 | 1491 | 1492 | 1493 | 1494 | 1495 | 1496 | #edit useries file# 1497 | 1498 | 1499 | 1500 | 1501 | 1502 | 1503 | 1504 | 1505 | 1506 | 1507 | 1508 | 1509 | 1510 | 1511 | 1512 | 1513 | 1514 | 1515 | 1516 | 1517 | 1518 | 1519 | 1520 | 1521 | 1522 | 1523 | 1524 | 1525 | 1526 | 1527 | 1528 | 1529 | 1530 | 1531 | 1532 | 1533 | 1534 | 1535 | 1536 | 1537 | 1538 | #build# 1539 | 1540 | 1541 | 1542 | 1543 | 1544 | 1545 | 1546 | 1547 | 1548 | 1549 | 1550 | 1551 | 1552 | 1553 | 1554 | 1555 | 1556 | 1557 | 1558 | 1559 | 1560 | 1561 | 1562 | 1563 | 1564 | 1565 | 1566 | 1567 | 1568 | 1569 | 1570 | 1571 | 1572 | 1573 | 1574 | 1575 | 1576 | 1577 | 1578 | 1579 | 1580 | #build# 1581 | 1582 | 1583 | 1584 | 1585 | 1586 | 1587 | 1588 | 1589 | 1590 | 1591 | 1592 | 1593 | 1594 | 1595 | 1596 | 1597 | 1598 | 1599 | 1600 | 1601 | 1602 | 1603 | 1604 | 1605 | 1606 | 1607 | 1608 | 1609 | 1610 | 1611 | 1612 | 1613 | 1614 | 1615 | 1616 | 1617 | 1618 | 1619 | 1620 | 1621 | 1622 | #merge# 1623 | 1624 | 1625 | 1626 | 1627 | 1628 | 1629 | 1630 | 1631 | 1632 | 1633 | 1634 | 1635 | 1636 | 1637 | 1638 | 1639 | 1640 | 1641 | 1642 | 1643 | 1644 | 1645 | 1646 | 1647 | 1648 | 1649 | 1650 | 1651 | 1652 | 1653 | 1654 | 1655 | 1656 | 1657 | 1658 | 1659 | 1660 | 1661 | 1662 | 1663 | 1664 | 1665 | 1666 | 1667 | #init ./useries# 1668 | 1669 | 1670 | 1671 | 1672 | 1673 | 1674 | 1675 | 1676 | 1677 | 1678 | 1679 | 1680 | 1681 | 1682 | 1683 | 1684 | 1685 | 1686 | 1687 | 1688 | 1689 | 1690 | 1691 | 1692 | 1693 | 1694 | 1695 | 1696 | 1697 | 1698 | 1699 | 1700 | 1701 | 1702 | 1703 | 1704 | 1705 | 1706 | 1707 | 1708 | 1709 | 1710 | 1711 | 1712 | 1713 | 1714 | 1715 | 1716 | 1717 | 1718 | 1719 | 1720 | 1721 | 1722 | 1723 | 1724 | 1725 | 1726 | 1727 | 1728 | 1729 | 1730 | 1731 | 1732 | 1733 | 1734 | 1735 | 1736 | 1737 | 1738 | 1739 | #tag# 1740 | 1741 | 1742 | 1743 | 1744 | 1745 | 1746 | 1747 | 1748 | 1749 | 1750 | 1751 | 1752 | 1753 | 1754 | 1755 | 1756 | 1757 | 1758 | 1759 | 1760 | 1761 | 1762 | 1763 | 1764 | 1765 | 1766 | 1767 | 1768 | 1769 | 1770 | 1771 | 1772 | 1773 | -------------------------------------------------------------------------------- /doc/images/umpf-relationships.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | useries 16 | 17 | 18 | 19 | 20 | 21 | umerge 22 | 23 | 24 | 25 | 26 | 27 | utag 28 | 29 | 30 | 31 | 32 | 33 | useries 34 | 35 | 36 | 37 | 38 | 39 | umerge 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 | qualified umpf 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | unqualified umpf 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | possible entry point 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | commands not asking for input 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 | commands asking for input 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | merge 151 | 152 | 153 | 154 | 155 | 156 | format-patch 157 | 158 | 159 | 160 | 161 | 162 | tag 163 | 164 | 165 | 166 | 167 | 168 | tag 169 | 170 | 171 | 172 | 173 | 174 | tag 175 | 176 | 177 | 178 | 179 | 180 | build 181 | 182 | 183 | 184 | 185 | 186 | tag 187 | 188 | 189 | 190 | 191 | 192 | edit useries file 193 | 194 | 195 | 196 | 197 | 198 | build 199 | 200 | 201 | 202 | 203 | 204 | build 205 | 206 | 207 | 208 | 209 | 210 | merge 211 | 212 | 213 | 214 | 215 | 216 | init ./useries 217 | 218 | 219 | 220 | 221 | 222 | 223 | 224 | 225 | 226 | tag 227 | 228 | 229 | 230 | 231 | -------------------------------------------------------------------------------- /doc/inner-workings.rst: -------------------------------------------------------------------------------- 1 | umpf from the Inside 2 | ==================== 3 | 4 | Series commands 5 | --------------- 6 | 7 | The following commands are parsed from a ``useries`` file, or the commit 8 | message of a *utag*: 9 | 10 | umpf-base: 11 | Specifies ```` as the base of the umpf, equivalent to the ``--base`` 12 | command line argument. 13 | 14 | Must be the first command in *useries* or *utag*. 15 | 16 | umpf-name: 17 | Specifies ```` as the name of the umpf, equivalent to the ``--name`` 18 | command line argument. 19 | 20 | umpf-version: 21 | The version of the *utag*. It is created from the umpf-name, the date and 22 | a version number (1 or explicitly set with the ``-v`` command line 23 | argument). 24 | 25 | umpf-topic: 26 | A branch that will be added to the umpf. 27 | 28 | umpf-squash-topic: 29 | Similar to umpf-topic but all commits in this branch will be squashed 30 | into a single commit in a *utag*. 31 | 32 | umpf-hashinfo: 33 | Following an *umpf-topic* or *umpf-squash-topic* command, ```` specifies 34 | the commit to which that topic branch pointed when the umpf was created. 35 | 36 | umpf-topic-range: .. 37 | The rebased commits of the branch in a *utag*. This will be used to create 38 | patches. 39 | 40 | umpf-release: 41 | The version is the same as in umpf-version. For supported projects, this 42 | will be followed by an umpf-topic-range that contains a single commit. 43 | It patches the project version to include the version of this *utag*. 44 | 45 | umpf-end 46 | Must be the last command in *useries* or *utag*. 47 | 48 | 49 | The following commands are parsed from the commit messages of a *umerge*: 50 | 51 | umpf-merge-topic: 52 | An indicator which branch was merged here. It allows umpf to find the 53 | correct branch when creating a *utag* (or a new *umerge*) from an existing 54 | *umerge*. 55 | 56 | umpf-squash-topic 57 | An indicator that umpf-squash-topic should be used for this branch 58 | instead of umpf-topic. 59 | 60 | umpf-build-note: 61 | Used to remember the base commit and umpf name in a *umerge*. 62 | 63 | -------------------------------------------------------------------------------- /doc/tips.rst: -------------------------------------------------------------------------------- 1 | Tips and Tricks 2 | =============== 3 | 4 | How do I… 5 | 6 | Let umpf prompt for the remote for every single branch 7 | ------------------------------------------------------ 8 | 9 | Call ``umpf --remote=foo`` where ``foo`` is a remote that does not exist. 10 | This way you can test if some local branch leads to merge conflicts when 11 | umpfed without needing to force-push it to a remote. 12 | Of course, this should only be done to test an umpf run, and should **not** 13 | be the default case – your coworkers will be confused when they try to 14 | reproduce an umpf! 15 | 16 | Use ``--identical`` only for specific branches (but use tip-of-head for others) 17 | ------------------------------------------------------------------------------- 18 | 19 | By default, ``--identical`` will always use the hashinfo for all branches. 20 | This can be overridden case by case with the ``--override`` option. 21 | For example, to use the local state of only the ``v4.19/topic/imx-poweroff`` 22 | branch, but use ``acme`` remote for everything else:: 23 | 24 | umpf --identical --remote acme --override v4.19/topic/imx-poweroff build series 25 | 26 | In cases, where the local branch is named differently, this can be made 27 | explicit:: 28 | 29 | umpf --identical --remote acme --override \ 30 | v4.19/topic/imx-poweroff=v4.19/topic/poweroff-rework build series 31 | 32 | Normally, this state is needed for future umpfs and thus ``--override`` should 33 | be a temporary measure until the remote branches are updated and future 34 | umpfs yield the same result without ``--override``. 35 | 36 | If the topic branches are shared between different project and a branch needs 37 | to be stabilized, a separate branch in the ``vX.Y/customers/`` namespace can 38 | be created pointing at the desired commit. 39 | This can then be referred to in the *useries* file or with ``umpf merge``. 40 | Example (with ``umpf-topic: v4.19/customers/foobar/topic/imx-poweroff``):: 41 | 42 | $ git log --oneline --decorate ${base}^..origin/v4.19/topic/imx-poweroff 43 | * f845a5df665c (origin/v4.19/topic/imx-poweroff) ARM: dts: imx6: RIoTboard provide standby on power off option 44 | * 21f8a3c69a05 (origin/v4.19/customers/foobar/topic/imx-poweroff) regulator: pfuze100-regulator: provide pm_power_off_prepare handler 45 | * 76b9fc78a7b1 regulator: pfuze100: add fsl,pmic-stby-poweroff property 46 | * b2686f99abc5 kernel/reboot.c: export pm_power_off_prepare 47 | * ba0390a910e7 ARM: imx6q: provide documentation for new fsl,pmic-stby-poweroff property 48 | * c63ee2939dc1 (tag: v4.19.85) Linux 4.19.85 49 | 50 | This way renewed umpfs are independent of future updates of the 51 | ``v4.19/topic/imx-poweroff`` topic branch. 52 | 53 | Create branches based on other branches 54 | --------------------------------------- 55 | 56 | Sometimes it is necessary to separate changes from an existing branch into 57 | specfific bits for a single project. These changes should not be applied to all 58 | projects, but are necessary changes for this project to work. Additionally they 59 | are usually based on previous changes from another branch. 60 | 61 | To ensure that ``umpf tag`` is able to resolve the branch dependencies, the 62 | required base branch needs to be merged in via ``umpf merge`` to ensure that the 63 | merge commit contains the correct ``umpf-merge-topic`` line. This way umpf can 64 | rebase your branch correctly during a tag operation. 65 | -------------------------------------------------------------------------------- /doc/what-is-an-umpf.rst: -------------------------------------------------------------------------------- 1 | What is an umpf? 2 | ---------------- 3 | 4 | This is *umpf*, the Universal Magic Patch Functionator. 5 | 6 | The term *umpf* is not only used for the tool itself, but also for the resulting artefacts 7 | built by this tool: 8 | An *umpf* is basically a git branch merged from different topic branches. 9 | It can come in different forms for different use cases, which are described below. 10 | An umpf can be fully qualified, which means that umpf has all information needed to 11 | convert it to any other form of umpf, 12 | but some forms of umpfs are not fully qualified. 13 | 14 | umerge 15 | ~~~~~~ 16 | 17 | A *umerge* is a git branch containing merges from topic branches. 18 | Generally every merged tree can be a *umerge*, but umpf needs additional information to make 19 | a merged tree a fully qualified umpf. 20 | For this reason it is recommended to use ``umpf merge`` rather than ``git merge`` to built 21 | a *umerge*. 22 | 23 | utag 24 | ~~~~ 25 | 26 | A *utag* is a git tag with multiple parents. 27 | The range ``origin/master..utag^1`` contains a linear branch of all topic branches, 28 | whereas ``origin/master..tag^n`` contains the (n-1)th topic branch. 29 | A *utag* by definition is a fully qualified umpf, and it is the highest form 30 | of an umpf, as it not only contains the topic branches but also a linear 31 | branch which can be easily transformed into a *useries*. 32 | 33 | useries 34 | ~~~~~~~ 35 | 36 | A *useries* is a stack of patch files together with a series file. 37 | The series file is a regular series file which contains additional 38 | information for umpf, which can be used to reconstruct the corresponding 39 | *umerge* in git. 40 | *useries* are usually used in BSPs and not in the daily developers workflow. 41 | -------------------------------------------------------------------------------- /meson.build: -------------------------------------------------------------------------------- 1 | project('umpf') 2 | 3 | install_data('umpf', install_dir: get_option('bindir')) 4 | 5 | subdir('tests') 6 | -------------------------------------------------------------------------------- /pre-commit: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # A git pre-commit hook script to make sure no new shellcheck warnings are 4 | # introduced. 5 | 6 | # Redirect output to stderr. 7 | exec 1>&2 8 | 9 | if [ ! -e /usr/bin/shellcheck ]; then 10 | cat <>>>>>> 7 | -------------------------------------------------------------------------------- /tests/run-test: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # Extract the git bundle, prepare the git repository, and run a single test. 4 | # This is intended to be run from the Meson test framework. 5 | # 6 | set -e 7 | 8 | fail() { 9 | echo "$1" 10 | exit 1 11 | } 12 | 13 | TEST="$1" 14 | 15 | if [ -z "$1" ]; then fail "usage: run-test "; fi 16 | if [ -z "${SOURCE_ROOT}" ]; then fail "SOURCE_ROOT not set"; fi 17 | if [ -z "${TEST_DIR}" ]; then fail "TEST_DIR not set"; fi 18 | if [ -z "${BUILD_DIR}" ]; then fail "BUILD_DIR not set"; fi 19 | if [ ! -x "${SOURCE_ROOT}/umpf" ]; then fail "umpf not found in SOURCE_ROOT"; fi 20 | if [ -z "$(command -v git)" ]; then fail "git not found in PATH"; fi 21 | 22 | echo "---------------------------------------- preparing git repository" 23 | rm -rf "${BUILD_DIR:?}/${TEST}" 24 | git clone "${TEST_DIR}/test-git" "${BUILD_DIR}/${TEST}" 25 | cp -r "${TEST_DIR}/rr-cache" "${BUILD_DIR}/${TEST}/.git/" 26 | cd "${BUILD_DIR}/${TEST}" 27 | git config --local user.name "UMPF Test Committer" 28 | git config --local user.email "umpf@example.com" 29 | git config --local advice.detachedHead false 30 | git branch a origin/a 31 | git branch b origin/b 32 | cat > series < series.conflict < series.tag 9 | diff -u ${TEST_DIR}/series-v2.ref series.tag 10 | -------------------------------------------------------------------------------- /tests/umpf-build-tag-identical: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # Test creating an identical umpf tag from an umpf build with modified branches 4 | # with "umpf tag --identical". 5 | # 6 | 7 | git switch a && echo "a2" >> a.txt && git add a.txt && git commit -m "a2" 8 | git switch b && echo "b2" >> b.txt && git add b.txt && git commit -m "b2" 9 | 10 | umpf tag --version=2 umpf-tag --remote=refs/heads --identical --base=base --name=name 11 | 12 | git log --format=%B -n 1 | grep "^# umpf-" > series.tag 13 | diff -u ${TEST_DIR}/series-v2.ref series.tag 14 | -------------------------------------------------------------------------------- /tests/umpf-build-tag-upstreamstatus: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # Test creating an umpf tag from an umpf build with "umpf tag". 4 | # 5 | 6 | umpf tag umpf-build --version=2 --remote=origin --base=base --name=name --flags upstreamstatus=insert 7 | 8 | git log --format=%B -n 1 | grep "^# umpf-" > series.tag 9 | diff -u ${TEST_DIR}/series-upstreamstatus-v2.ref series.tag 10 | -------------------------------------------------------------------------------- /tests/umpf-distribute: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # Test distributing patches on top of an umpf build to local branches with 4 | # "umpf distribute". 5 | # 6 | 7 | git checkout -b work umpf-build 8 | echo "a2" >> a.txt && git add a.txt && git commit -m "a2" 9 | echo "b2" >> b.txt && git add b.txt && git commit -m "b2" 10 | 11 | umpf distribute --remote=refs/heads --base=base < series.merge 10 | 11 | diff -u ${TEST_DIR}/series-merge.ref series.merge 12 | -------------------------------------------------------------------------------- /tests/umpf-merge-build: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # Test creating an umpf build from umpf merged topic branches with "umpf build". 4 | # 5 | 6 | git checkout umpf-merge 7 | umpf build --remote=origin --base=base --name=name 8 | 9 | umpf show > series.build 10 | diff -u ${TEST_DIR}/series-merge.ref series.build 11 | -------------------------------------------------------------------------------- /tests/umpf-series-build: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # Test creating an umpf build from a series file with "umpf build". 4 | # 5 | 6 | umpf build series --remote=origin 7 | 8 | git ls-tree umpf-build > ls-tree.ref 9 | git ls-tree HEAD > ls-tree.build 10 | diff -u ls-tree.ref ls-tree.build 11 | 12 | umpf show HEAD > series.build 13 | diff -u ${TEST_DIR}/series-merge.ref series.build 14 | -------------------------------------------------------------------------------- /tests/umpf-series-tag: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # Test creating an umpf tag from a series file with "umpf tag". 4 | # 5 | 6 | umpf tag --version=2 series --remote=origin 7 | 8 | git log --format=%B -n 1 | grep "^# umpf-" > series.tag 9 | diff -u ${TEST_DIR}/series-v2.ref series.tag 10 | -------------------------------------------------------------------------------- /tests/umpf-series-tag-continue: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # Test creating an umpf tag from a series file with "umpf tag". 4 | # 5 | 6 | umpf tag --version=3 series.conflict --remote=origin || test $? = 1 7 | diff -u ${TEST_DIR}/conflict-failed.ref .git/umpf/failed 8 | git add a.txt 9 | umpf continue 10 | 11 | git log --format=%B -n 1 | grep "^# umpf-" > series.tag 12 | diff -u ${TEST_DIR}/series-conflict-v3.ref series.tag 13 | -------------------------------------------------------------------------------- /tests/umpf-series-tag-continue-flags: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # Test flags propagation across "umpf continue" 4 | # 5 | 6 | ${TEST_DIR}/prepare-version-branch "${TEST_DIR}/version-files/src/Makefile" 7 | 8 | sed -i '/^# umpf-topic: b$/a # umpf-topic: version' series.conflict 9 | export GIT_FALLBACK_REMOTE=refs/heads 10 | 11 | umpf tag --version=2 series.conflict --remote=origin --flags extraversion=conflictfree || test $? = 1 12 | git add a.txt 13 | echo | umpf continue 14 | 15 | diff -u ${TEST_DIR}/version-files/ref/Makefile.conflictfree Makefile 16 | git log --format=%B -n 1 | grep "^# umpf-" > series.tag 17 | diff -u ${TEST_DIR}/series-conflict-flags-v2.ref series.tag 18 | 19 | sed -i '/^# umpf-base: base$/a # umpf-flags: extraversion=conflictfree' series.conflict 20 | umpf tag -f --version=2 series.conflict --remote=origin || test $? = 1 21 | git add a.txt 22 | echo | umpf continue 23 | umpf show 2>&1 24 | 25 | diff -u ${TEST_DIR}/version-files/ref/Makefile.conflictfree Makefile 26 | git log --format=%B -n 1 | grep "^# umpf-" > series.tag 27 | diff -u ${TEST_DIR}/series-conflict-flags-v2.ref series.tag 28 | -------------------------------------------------------------------------------- /tests/umpf-series-tag-empty: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # Test creating an umpf tag from a series file without any topics. 4 | # 5 | 6 | umpf tag --version=2 --base=base --name=name --remote=origin 7 | 8 | git log --format=%B -n 1 | grep "^# umpf-" > series.tag 9 | diff -u ${TEST_DIR}/series-empty-v2.ref series.tag 10 | -------------------------------------------------------------------------------- /tests/umpf-series-tag-rerere: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # Test creating an umpf tag from a series file with "umpf tag". 4 | # 5 | 6 | umpf tag --version=3 series.conflict --remote=origin --auto-rerere 7 | 8 | git log --format=%B -n 1 | grep "^# umpf-" > series.tag 9 | diff -u ${TEST_DIR}/series-conflict-v3.ref series.tag 10 | -------------------------------------------------------------------------------- /tests/umpf-show: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # Test the output of "umpf show". 4 | # 5 | 6 | umpf show umpf-tag > series.show 7 | 8 | diff -u ${TEST_DIR}/series-v1.ref series.show 9 | -------------------------------------------------------------------------------- /tests/umpf-versions: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # Test all the version substitution patterns 4 | # 5 | 6 | check_version() { 7 | src="${1}" 8 | dst="${2}" 9 | ref="${TEST_DIR}/version-files/ref/$(basename ${src})" 10 | 11 | ${TEST_DIR}/prepare-version-branch "${src}" "${dst}" 12 | echo | umpf tag -f --version=2 series --remote=origin 13 | diff -u "${ref}" "${dst}" 14 | } 15 | 16 | sed -i '/^# umpf-topic: b$/a # umpf-topic: version' series 17 | export GIT_FALLBACK_REMOTE=refs/heads 18 | 19 | for file in "${TEST_DIR}/version-files/src/Makefile"*; do 20 | check_version "${file}" "Makefile" 21 | done 22 | for file in "${TEST_DIR}/version-files/src/meson.build"*; do 23 | check_version "${file}" "meson.build" 24 | done 25 | -------------------------------------------------------------------------------- /tests/version-files/ref/Makefile: -------------------------------------------------------------------------------- 1 | # SPDX-License-Identifier: GPL-2.0 2 | VERSION = 6 3 | PATCHLEVEL = 7 4 | SUBLEVEL = 0 5 | EXTRAVERSION = -rc5-20221209-2 6 | NAME = Hurr durr I'ma ninja sloth 7 | 8 | # Read KERNELRELEASE from include/config/kernel.release (if it exists) 9 | KERNELRELEASE = $(call read-file, include/config/kernel.release) 10 | KERNELVERSION = $(VERSION)$(if $(PATCHLEVEL),.$(PATCHLEVEL)$(if $(SUBLEVEL),.$(SUBLEVEL)))$(EXTRAVERSION) 11 | export VERSION PATCHLEVEL SUBLEVEL KERNELRELEASE KERNELVERSION 12 | -------------------------------------------------------------------------------- /tests/version-files/ref/Makefile.conflictfree: -------------------------------------------------------------------------------- 1 | # SPDX-License-Identifier: GPL-2.0 2 | VERSION = 6 3 | PATCHLEVEL = 7 4 | SUBLEVEL = 0 5 | EXTRAVERSION = -rc5 6 | NAME = Hurr durr I'ma ninja sloth 7 | 8 | # Read KERNELRELEASE from include/config/kernel.release (if it exists) 9 | EXTRAVERSION := $(EXTRAVERSION)-20221209-2 10 | KERNELRELEASE = $(call read-file, include/config/kernel.release) 11 | KERNELVERSION = $(VERSION)$(if $(PATCHLEVEL),.$(PATCHLEVEL)$(if $(SUBLEVEL),.$(SUBLEVEL)))$(EXTRAVERSION) 12 | export VERSION PATCHLEVEL SUBLEVEL KERNELRELEASE KERNELVERSION 13 | -------------------------------------------------------------------------------- /tests/version-files/ref/meson.build-gstreamer-1.18.0: -------------------------------------------------------------------------------- 1 | project('gstreamer', 'c', 2 | version : '1.18.0' + '.20221209-2', 3 | meson_version : '>= 0.48', 4 | default_options : [ 'warning_level=1', 5 | 'buildtype=debugoptimized' ]) 6 | 7 | gst_version = meson.project_version() 8 | version_arr = gst_version.split('.') 9 | gst_version_major = version_arr[0].to_int() 10 | gst_version_minor = version_arr[1].to_int() 11 | gst_version_micro = version_arr[2].to_int() 12 | if version_arr.length() == 5 13 | gst_version_nano = version_arr[3].to_int() 14 | else 15 | gst_version_nano = 0 16 | endif 17 | gst_version_is_dev = gst_version_minor % 2 == 1 and gst_version_micro < 90 18 | -------------------------------------------------------------------------------- /tests/version-files/ref/meson.build-mesa-21.3.0: -------------------------------------------------------------------------------- 1 | project( 2 | 'mesa', 3 | ['c', 'cpp'], 4 | version : run_command( 5 | [find_program('python3', 'python'), 'bin/meson_get_version.py'], 6 | check : true 7 | ).stdout() + '.20221209-2', 8 | license : 'MIT', 9 | meson_version : '>= 0.52', 10 | default_options : ['buildtype=debugoptimized', 'b_ndebug=if-release', 'c_std=c11', 'cpp_std=c++14'] 11 | ) 12 | -------------------------------------------------------------------------------- /tests/version-files/ref/meson.build-mesa-23.0.0-rc1: -------------------------------------------------------------------------------- 1 | project( 2 | 'mesa', 3 | ['c', 'cpp'], 4 | version : run_command( 5 | [find_program('python3', 'python'), 'bin/meson_get_version.py', 6 | meson.version().version_compare('>= 0.56') ? meson.project_source_root() : meson.source_root()], 7 | check : true 8 | ).stdout() + '.20221209-2', 9 | license : 'MIT', 10 | meson_version : '>= 0.54', 11 | default_options : ['buildtype=debugoptimized', 'b_ndebug=if-release', 'c_std=c11', 'cpp_std=c++17', 'rust_std=2021'] 12 | ) 13 | -------------------------------------------------------------------------------- /tests/version-files/src/Makefile: -------------------------------------------------------------------------------- 1 | # SPDX-License-Identifier: GPL-2.0 2 | VERSION = 6 3 | PATCHLEVEL = 7 4 | SUBLEVEL = 0 5 | EXTRAVERSION = -rc5 6 | NAME = Hurr durr I'ma ninja sloth 7 | 8 | # Read KERNELRELEASE from include/config/kernel.release (if it exists) 9 | KERNELRELEASE = $(call read-file, include/config/kernel.release) 10 | KERNELVERSION = $(VERSION)$(if $(PATCHLEVEL),.$(PATCHLEVEL)$(if $(SUBLEVEL),.$(SUBLEVEL)))$(EXTRAVERSION) 11 | export VERSION PATCHLEVEL SUBLEVEL KERNELRELEASE KERNELVERSION 12 | -------------------------------------------------------------------------------- /tests/version-files/src/meson.build-gstreamer-1.18.0: -------------------------------------------------------------------------------- 1 | project('gstreamer', 'c', 2 | version : '1.18.0', 3 | meson_version : '>= 0.48', 4 | default_options : [ 'warning_level=1', 5 | 'buildtype=debugoptimized' ]) 6 | 7 | gst_version = meson.project_version() 8 | version_arr = gst_version.split('.') 9 | gst_version_major = version_arr[0].to_int() 10 | gst_version_minor = version_arr[1].to_int() 11 | gst_version_micro = version_arr[2].to_int() 12 | if version_arr.length() == 4 13 | gst_version_nano = version_arr[3].to_int() 14 | else 15 | gst_version_nano = 0 16 | endif 17 | gst_version_is_dev = gst_version_minor % 2 == 1 and gst_version_micro < 90 18 | -------------------------------------------------------------------------------- /tests/version-files/src/meson.build-mesa-21.3.0: -------------------------------------------------------------------------------- 1 | project( 2 | 'mesa', 3 | ['c', 'cpp'], 4 | version : run_command( 5 | [find_program('python3', 'python'), 'bin/meson_get_version.py'], 6 | check : true 7 | ).stdout(), 8 | license : 'MIT', 9 | meson_version : '>= 0.52', 10 | default_options : ['buildtype=debugoptimized', 'b_ndebug=if-release', 'c_std=c11', 'cpp_std=c++14'] 11 | ) 12 | -------------------------------------------------------------------------------- /tests/version-files/src/meson.build-mesa-23.0.0-rc1: -------------------------------------------------------------------------------- 1 | project( 2 | 'mesa', 3 | ['c', 'cpp'], 4 | version : run_command( 5 | [find_program('python3', 'python'), 'bin/meson_get_version.py', 6 | meson.version().version_compare('>= 0.56') ? meson.project_source_root() : meson.source_root()], 7 | check : true 8 | ).stdout(), 9 | license : 'MIT', 10 | meson_version : '>= 0.54', 11 | default_options : ['buildtype=debugoptimized', 'b_ndebug=if-release', 'c_std=c11', 'cpp_std=c++17', 'rust_std=2021'] 12 | ) 13 | -------------------------------------------------------------------------------- /umpf: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env bash 2 | # We ignore the check SC2155 "Declare and assign separately to avoid masking 3 | # return values", as this reduced legibility and return values are ignored. 4 | # shellcheck disable=SC2155 5 | # 6 | # MIT License 7 | # 8 | # Copyright (c) 2022 Pengutronix 9 | # 10 | # Permission is hereby granted, free of charge, to any person obtaining a copy 11 | # of this software and associated documentation files (the "Software"), to deal 12 | # in the Software without restriction, including without limitation the rights 13 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 14 | # copies of the Software, and to permit persons to whom the Software is 15 | # furnished to do so, subject to the following conditions: 16 | # 17 | # The above copyright notice and this permission notice shall be included in all 18 | # copies or substantial portions of the Software. 19 | # 20 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 21 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 22 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 23 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 24 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 25 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 26 | # SOFTWARE. 27 | # 28 | # Universal Magic Patch Functionator 29 | 30 | GIT_RELATIVE="" 31 | GIT_REMOTE="" 32 | GIT_FALLBACK_REMOTE="" 33 | SERIES="" 34 | BASE="" 35 | NAME="" 36 | FLAGS="" 37 | PROJECT="" 38 | PATCH_DIR="umpf-patches" 39 | IDENTICAL=false 40 | STABLE=false 41 | DEFAULT=false 42 | FORCE=false 43 | UPDATE=false 44 | VERBOSE=false 45 | VERSION_SEPARATOR=- 46 | VERSION=1 47 | AUTO_RERERE=false 48 | BLOCK_SIZE=100 49 | BB=false 50 | NIX=false 51 | declare -A OVERRIDES 52 | 53 | # Create a pristine environment to minimize unnecessary fuzz when different 54 | # users use umpf on the same patch stack. That is, don't load any config files, 55 | # and pin down environment variables which could influence git's behaviour or 56 | # patch output. 57 | PRISTINE_GIT_PARAMS=( -c gc.auto=0 -c core.abbrev=12 -c core.editor=: 58 | -c sequence.editor=: ) 59 | # Maybe we need to save name and e-mail from the user config… 60 | # Note from git-commit-tree(1): if set in the user's environment, GIT_AUTHOR_* 61 | # and GIT_COMMITTER_* still take precedence over the user.* config variables. 62 | PRISTINE_GIT_AUTHOR=$(git config --get user.name) 63 | PRISTINE_GIT_EMAIL=$(git config --get user.email) 64 | if [ -n "${PRISTINE_GIT_AUTHOR}" ]; then 65 | PRISTINE_GIT_PARAMS+=( -c user.name="${PRISTINE_GIT_AUTHOR}" ) 66 | fi 67 | if [ -n "${PRISTINE_GIT_EMAIL}" ]; then 68 | PRISTINE_GIT_PARAMS+=( -c user.email="${PRISTINE_GIT_EMAIL}" ) 69 | fi 70 | pristine_git() { 71 | # Notes from the git(1) manpage: 72 | # - GIT_DIFF_OPTS takes takes precedence over -U command line parameter 73 | # - GIT_EDITOR takes precedence over core.editor config variable 74 | HOME=/nonexistent \ 75 | XDG_CONFIG_HOME=/nonexistent \ 76 | GIT_CONFIG_NOSYSTEM=true \ 77 | GIT_DIFF_OPTS="-u3" \ 78 | GIT_EDITOR=: \ 79 | git "${PRISTINE_GIT_PARAMS[@]}" "$@" 80 | } 81 | GIT="pristine_git" 82 | GIT_DIR="${GIT_DIR:-$(${GIT} rev-parse --git-dir 2> /dev/null)}" 83 | GIT_DIR="${GIT_DIR:-.git}" 84 | STATE="${GIT_DIR}/umpf" 85 | 86 | ### flags #### 87 | SUPPORTED_FLAGS=("extraversion" "upstreamstatus") 88 | 89 | declare -A flag_extraversion 90 | 91 | flag_extraversion[val]="replace" 92 | flag_extraversion[values]="replace conflictfree" 93 | 94 | declare -A flag_upstreamstatus 95 | 96 | flag_upstreamstatus[val]="none" 97 | flag_upstreamstatus[values]="none insert" 98 | 99 | ############## 100 | 101 | info() { 102 | if [ -z "$*" ]; then 103 | echo >&2 104 | else 105 | echo "umpf: $*" >&2 106 | fi 107 | } 108 | 109 | bailout() { 110 | if [ -d "${STATE}" ]; then 111 | echo "${line}" > "${STATE}/failed" 112 | cat <<- EOF > "${STATE}/config" 113 | PATCH_DIR="${PATCH_DIR}" 114 | GIT_REMOTE="${GIT_REMOTE}" 115 | SERIES="${SERIES}" 116 | IDENTICAL="${IDENTICAL}" 117 | STABLE="${STABLE}" 118 | PROJECT="${PROJECT}" 119 | UPDATE="${UPDATE}" 120 | FLAGS="${FLAGS}" 121 | VERSION_SEPARATOR="${VERSION_SEPARATOR}" 122 | VERSION="${VERSION}" 123 | EOF 124 | if ${FORCE}; then 125 | echo "FORCE=true" >> "${STATE}/config" 126 | fi 127 | declare -p OVERRIDES >> "${STATE}/config" 128 | for flag in "${SUPPORTED_FLAGS[@]}"; do 129 | declare -p "flag_${flag}" >> "${STATE}/config" 130 | done 131 | fi 132 | 133 | if [ -n "$*" ]; then 134 | info "$*" 135 | info 136 | fi 137 | info "Resolve issues and call 'umpf continue', or call 'umpf abort' to start over." 138 | 139 | exit 1 140 | } 141 | 142 | abort() { 143 | if [ -n "$*" ]; then 144 | info "$*" 145 | fi 146 | 147 | if [[ -d "${GIT_DIR}/rebase-apply" || -d "${GIT_DIR}/rebase-merge" ]]; then 148 | ${GIT} rebase --abort 149 | fi 150 | if [ -f "${GIT_DIR}/CHERRY_PICK_HEAD" ]; then 151 | ${GIT} cherry-pick --abort 152 | fi 153 | if [ -f "${GIT_DIR}/MERGE_HEAD" ]; then 154 | ${GIT} merge --abort 155 | fi 156 | undo_persistent 157 | cleanup 158 | exit 1 159 | } 160 | 161 | cleanup() { 162 | if [ -n "${series_out}" ]; then 163 | exec {series_out}<&- 164 | unset series_out 165 | fi 166 | if [ -n "${series_in}" ]; then 167 | exec {series_in}<&- 168 | unset series_in 169 | fi 170 | rm -rf "${GIT_DIR}/refs/umpf" 171 | rm -rf "${STATE}" 172 | } 173 | 174 | usage() { 175 | cat <<- EOF 176 | usage: $0 [] [--] 177 | 178 | Mandatory arguments to long options are mandatory for short options too. 179 | --default answer interactive prompts with the default option 180 | --auto-rerere automatically try to use rerere after conflicts 181 | --bb with format-patch: write patch series for bitbake 182 | --nix with format-patch: write patch series nix 183 | -h, --help 184 | -f, --force 185 | --flags specify/override umpf-flags 186 | -i, --identical use exact commit hashes, not tip of branches 187 | -s, --stable create a 'stable' tag from a branch based on an 188 | existing tag. Implies '--identical'. 189 | -b, --base specify/override base name [default: merge base] 190 | -n, --name specify/override umpf name 191 | -p, --patchdir with format-patch: write patches to / 192 | --relative create patches relative to 193 | -r, --remote use to resolve branch names 194 | -l, --local use local branches, alias for --remote refs/heads 195 | --override [=] 196 | use commit-ish instead for the topic. May be 197 | specified more than once. If only is 198 | specified, it's interpreted as 199 | =[/] 200 | -u, --update with --patchdir: update existing patches in 201 | -v, --version with tag: overwrite version number [default: 1] 202 | 203 | Commands: 204 | If optional or arguments are unspecified, HEAD is used. 205 | 206 | diff [|] show patches not in any topic branch (not 207 | upstream) and patches missing locally 208 | show [|] show an useries file from an umpf 209 | tig [] browse an umpf interactively, showing state of 210 | local, remote and remote-tracking topic branches 211 | 212 | tag [|] generate a utag from a useries or umerge 213 | or commits stacked on top of an umpf 214 | format-patch [] generate a useries file and patch stack 215 | from a utag 216 | 217 | merge []merge one topic branches into current 218 | head, like git merge, but umpf compatible. 219 | Use as topic name if specified. 220 | Otherwise must be the correct 221 | topic name. The remote is removed if necessary. 222 | build build an umerge from another umpf 223 | distribute push patches not yet in any topic branch 224 | upstream 225 | 226 | continue continue a previously interrupted umpf command 227 | abort abort a previously started umpf command 228 | 229 | init manually create an umpf series file by 230 | answering questions 231 | EOF 232 | } 233 | 234 | ### setup ### 235 | 236 | setup() { 237 | local tmp args o l topic commitish 238 | if tmp="$(git config umpf.patch-dir)"; then 239 | PATCH_DIR="${tmp}" 240 | fi 241 | if tmp="$(git config umpf.block-size)"; then 242 | BLOCK_SIZE="${tmp}" 243 | fi 244 | if tmp="$(git config umpf.remote)"; then 245 | GIT_REMOTE="${tmp}" 246 | fi 247 | if tmp="$(git config umpf.fallback-remote)"; then 248 | GIT_FALLBACK_REMOTE="${tmp}" 249 | fi 250 | 251 | o="fhilsub:n:p:r:v:" 252 | l="auto-rerere,bb,nix,flags:,default,force,help,identical,stable,update,base:,name:,patchdir:,relative:,override:,remote:,local,version:" 253 | if ! args="$(getopt -n umpf -o "${o}" -l "${l}" -- "${@}")"; then 254 | usage 255 | exit 1 256 | fi 257 | eval set -- ${args} 258 | while [ ${#} -gt 0 ]; do 259 | OPT="${1}" 260 | shift 261 | case "${OPT}" in 262 | --auto-rerere) 263 | if [[ "$(${GIT} config --get rerere.enabled)" = "true" || -d "$(${GIT} rev-parse --git-common-dir)/rr-cache" ]]; then 264 | AUTO_RERERE=true 265 | else 266 | bailout "--auto-rerere is given, but rerere is not enabled in current repo." 267 | fi 268 | ;; 269 | --bb) 270 | BB=true 271 | ;; 272 | --nix) 273 | NIX=true 274 | ;; 275 | --default) 276 | DEFAULT=true 277 | ;; 278 | -f|--force) 279 | FORCE=true 280 | ;; 281 | --flags) 282 | FLAGS="${1}" 283 | shift 284 | ;; 285 | -h|--help) 286 | usage 287 | exit 288 | ;; 289 | -i|--identical) 290 | IDENTICAL=true 291 | ;; 292 | -s|--stable) 293 | STABLE=true 294 | IDENTICAL=true 295 | ;; 296 | -u|--update) 297 | UPDATE=true 298 | ;; 299 | -b|--base) 300 | BASE="${1}" 301 | shift 302 | ;; 303 | -n|--name) 304 | NAME="${1}" 305 | shift 306 | ;; 307 | -p|--patchdir) 308 | PATCH_DIR="${1}" 309 | shift 310 | ;; 311 | --relative) 312 | GIT_RELATIVE="${1}" 313 | shift 314 | ;; 315 | -r|--remote) 316 | GIT_REMOTE="${1}" 317 | shift 318 | ;; 319 | -l|--local) 320 | GIT_REMOTE="refs/heads" 321 | ;; 322 | --override) 323 | IFS="=" read -r topic commitish <<< "${1}" 324 | if [ -n "${commitish}" ]; then 325 | OVERRIDES[$topic]="${commitish}" 326 | else 327 | OVERRIDES[$topic]="" 328 | fi 329 | shift 330 | ;; 331 | -v|--version) 332 | VERSION="${1}" 333 | shift 334 | ;; 335 | --) 336 | break 337 | ;; 338 | esac 339 | done 340 | COMMAND="${1}" 341 | shift 342 | ARGS=( "${@}" ) 343 | 344 | if [[ -n "${GIT_RELATIVE}" && ! "${COMMAND}" =~ ^(init|build|tag)$ ]]; then 345 | bailout "--relative is only valid for 'init', 'build' and 'tag'" 346 | fi 347 | 348 | test -n "${PATCH_DIR}" || bailout "Patch directory not defined" 349 | if [ "${PATCH_DIR}" == "${PATCH_DIR#/}" ]; then 350 | PATCH_DIR="$PWD/${PATCH_DIR}" 351 | fi 352 | PATCH_DIR="${PATCH_DIR%/}" 353 | 354 | if [ -n "${GIT_REMOTE}" ]; then 355 | GIT_REMOTE="${GIT_REMOTE}/" 356 | fi 357 | if [ -n "${GIT_FALLBACK_REMOTE}" ]; then 358 | GIT_FALLBACK_REMOTE="${GIT_FALLBACK_REMOTE}/" 359 | fi 360 | 361 | for topic in "${!OVERRIDES[@]}"; do 362 | local rev 363 | 364 | if [ -z "${OVERRIDES[$topic]}" ]; then 365 | OVERRIDES[$topic]="${GIT_REMOTE}${topic}" 366 | fi 367 | 368 | if ! rev="$(${GIT} rev-parse "${OVERRIDES[$topic]}^{}" 2> /dev/null)"; then 369 | echo "Revision '${OVERRIDES[$topic]}' not found for topic '${topic}'" 370 | exit 1 371 | fi 372 | 373 | OVERRIDES[$topic]="${rev}" 374 | done 375 | } 376 | 377 | prepare() { 378 | [ -d "${GIT_DIR}" ] || bailout "Not a git repository." 379 | 380 | SERIES="${1:-HEAD}" 381 | } 382 | 383 | prepare_series() { 384 | local s 385 | if [ -f "${SERIES}" ]; then 386 | cp "${SERIES}" "${STATE}/series" 387 | return 388 | fi 389 | if ${GIT} rev-parse --verify -q "${SERIES}" > /dev/null; then 390 | import_series "${SERIES}" && 391 | return 392 | fi 393 | if ! s="$(${GIT} tag | sort -r | grep -m1 "^${SERIES}/[0-9]\{8\}$")"; then 394 | abort "Unknown file or revision '${SERIES}'" 395 | fi 396 | import_series "${s}" 397 | } 398 | 399 | prepare_persistent() { 400 | prepare "${2}" 401 | 402 | test -d "${STATE}" && bailout "umpf in progress!" 403 | 404 | mkdir "${STATE}" 405 | echo "${1}" > "${STATE}/command" 406 | prepare_series 407 | check_series 408 | (${GIT} symbolic-ref -q --short HEAD || ${GIT} rev-parse HEAD) > "${STATE}/head-name" 409 | } 410 | 411 | undo_persistent() { 412 | if test -e "${STATE}/head-name"; then 413 | head_name=$(<"${STATE}/head-name") 414 | ${GIT} checkout -q "${head_name}" 415 | fi 416 | } 417 | 418 | ### helper ### 419 | 420 | nice_branch() { 421 | read -r -a replies < <(sed -r -n 's,^(remotes/([^/]*)/|heads/)?(.*),\3 \2,p' <<< "${1}") 422 | } 423 | 424 | read_interactive() { 425 | local prompt="${1}" def="${2}" 426 | if ${DEFAULT} && [ -n "${def}" ]; then 427 | echo "${prompt}: ${def}" 428 | choice="${def}" 429 | else 430 | read -e -i "${def}" -p "${prompt}: " choice 431 | fi 432 | } 433 | 434 | find_branch_rev() { 435 | local name branch remote 436 | local -a branches replies 437 | name="${1}" 438 | if [ -n "${OVERRIDES[$name]}" ]; then 439 | reply="${OVERRIDES[$name]}" 440 | return 441 | fi 442 | if ${IDENTICAL}; then 443 | reply="${2}" 444 | return 445 | fi 446 | remote="${GIT_REMOTE}" 447 | mapfile -t branches < <(${GIT} show-ref | sed -n -r "s:[^ ]* refs/((heads|remotes/[^ ]*)/${name})\$:\1:p" | sort -r) 448 | 449 | while [ -z "${GIT_REMOTE}" ] || ! reply="$(${GIT} rev-parse "${remote}${name}^{}" 2> /dev/null)"; do 450 | if [ "${#branches[@]}" -eq 0 ]; then 451 | break 452 | fi 453 | if [ -z "${GIT_REMOTE}" ]; then 454 | info "Remote undefined. Choose the branch with the correct remote:" 455 | else 456 | info "Branch not found for '${remote}'. Choose alternative branch:" 457 | fi 458 | local i=0 def=0 choice 459 | for branch in "${branches[@]}"; do 460 | nice_branch "${branch}" 461 | echo "${i}) ${replies[1]:+${replies[1]}/}${replies[0]}" 462 | if [ "${GIT_FALLBACK_REMOTE}" == "${replies[1]}/" ]; then 463 | def="${i}" 464 | fi 465 | i=$((i+1)) 466 | done 467 | read_interactive "branch number" "${def}" 468 | nice_branch "${branches[${choice}]}" 469 | remote="${replies[1]:-refs/heads}/" 470 | if [ -z "${GIT_REMOTE}" ]; then 471 | GIT_REMOTE="${remote}" 472 | info "Using remote '${GIT_REMOTE}'." 473 | fi 474 | done 475 | if [ -z "${reply}" ]; then 476 | if [ "$(${GIT} rev-parse "${name}")" == "${name}" ]; then 477 | reply="${name}" 478 | fi 479 | fi 480 | if [ -z "${reply}" ]; then 481 | bailout "Failed to find '${name}'" 482 | fi 483 | for branch in "${branches[@]}"; do 484 | local choice b="$(${GIT} rev-parse --verify "${branch}^{}")" 485 | if [ "${reply}" == "${b}" ]; then 486 | continue 487 | fi 488 | if [ "$(${GIT} merge-base "${reply}" "${branch}")" == "${reply}" ]; then 489 | info "Warning: The following commits are in '${branch}' but not in '${remote}${name}':" 490 | GIT_PAGER="" ${GIT} log --oneline "${reply}...${b}" 491 | if tty -s; then 492 | read_interactive "Use ${branch} instead? [y/n]" "n" 493 | if [ "${choice}" == "y" ]; then 494 | reply="${b}" 495 | fi 496 | fi 497 | fi 498 | done 499 | } 500 | 501 | list_branch_names() { 502 | rev="${1}" 503 | filter="${2}" 504 | ${GIT} show-ref --head | sed -n -r -e "s:${rev} refs/(${filter}):\1:p" 505 | } 506 | 507 | find_branch_name() { 508 | local head merge mergelog candidate choice 509 | local -a branches replies 510 | head="${1}" 511 | merge="${2}" 512 | mergelog=$(${GIT} log --oneline -1 "${head}") 513 | name="$(${GIT} log -1 ${head} | sed -n -r 's,^ umpf-merge-topic: (.*)$,\1,p')" 514 | if [ -n "${name}" ]; then 515 | if ${GIT} log -1 ${head} | grep -q '^ umpf-squash-topic$' ; then 516 | squash=1 517 | fi 518 | return 519 | fi 520 | if [ -n "${GIT_REMOTE}" ]; then 521 | mapfile -t branches < <(list_branch_names "${merge}" "remotes/${GIT_REMOTE}") 522 | fi 523 | if [ ${#branches[@]} -ne 1 ]; then 524 | mapfile -t branches < <(list_branch_names "${merge}") 525 | fi 526 | case "${#branches[@]}" in 527 | 0) 528 | info "No branch found for ${mergelog}" 529 | candidate=$(sed -n "s/^[0-9a-f]* Merge.* '\([^ ]*\)' .*/\1/p" <<< "${mergelog}") 530 | read_interactive "topic" "${candidate}" 531 | name="${choice}" 532 | ;; 533 | 1) 534 | nice_branch "${branches[0]}" 535 | name="${replies[0]}" 536 | ;; 537 | *) 538 | info "Multiple branches found for $mergelog" 539 | local i=0 540 | for branch in "${branches[@]}"; do 541 | nice_branch "${branch}" 542 | info "${i}) ${replies[1]:+[${replies[1]}]} ${replies[0]}" 543 | i=$((i+1)) 544 | done 545 | while [ -z "${name}" ]; do 546 | read -e -p "branch number: " i 547 | nice_branch "${branches[$i]}" 548 | name="${replies[0]}" 549 | done 550 | if [ -z "${GIT_REMOTE}" ]; then 551 | GIT_REMOTE="${replies[1]:-refs/heads}/" 552 | info "Using remote '${GIT_REMOTE}'." 553 | fi 554 | esac 555 | } 556 | 557 | # 558 | # needs ${branches[@]} and ${branch_names[@]} 559 | # 560 | show_diff() { 561 | local head base i 562 | local -a all 563 | head="${1}" 564 | base="${2}" 565 | 566 | all=( "${head}" "^${base}" "${branches[@]/#/^}" ) 567 | if [ -n "$(${GIT} rev-list --no-merges "${all[@]}")" ]; then 568 | info 569 | info "These patches are not in any topic branch:" 570 | ${GIT} rev-list --no-merges --oneline "${all[@]}" 571 | ${GIT} rev-list --no-merges --reverse "${all[@]}" > "${STATE}/diff" 572 | info 573 | fi 574 | 575 | for i in $(seq 0 $((${#branches[@]}-1))); do 576 | all=( "^${head}" "^${base}" "${branches[i]}" ) 577 | if [ -n "$(${GIT} rev-list --no-merges "${all[@]}")" ]; then 578 | info 579 | info "These patches are in ${branch_names[i]} but not in '${head}':" 580 | ${GIT} rev-list --no-merges --oneline "${all[@]}" 581 | info 582 | fi 583 | done 584 | } 585 | 586 | topic_from_rev() { 587 | local rev="$(${GIT} rev-parse --symbolic-full-name "${1}")" 588 | if [ -z "${rev}" ]; then 589 | # not a branch name, so try to find one 590 | rev="$(${GIT} describe --all "${1}")" 591 | rev="$(${GIT} rev-parse --symbolic-full-name "${rev}")" 592 | fi 593 | local -a remotes 594 | mapfile -t remotes < <(${GIT} remote) 595 | remotes=( "${remotes[@]/#/refs\/remotes\/}" "refs/heads" ) 596 | local pattern="${remotes[*]}" 597 | pattern="^(${pattern// /|})/" 598 | sed -r "s,${pattern},," <<< "${rev}" || echo "${1}" 599 | } 600 | 601 | import_series() { 602 | local series="${STATE}/series" 603 | local import="${1}" 604 | local names base_rev 605 | local -A tmp_branches 606 | 607 | for base_rev in $(${GIT} rev-parse ${import}) $(${GIT} rev-list --merges -1 "${import}"); do 608 | ${GIT} log -1 "${base_rev}" | sed -n '/^ # umpf-base/,/^ # umpf-end/p' > "${series}" 609 | if [ "$(wc -l < "${series}")" -gt 2 ]; then 610 | break 611 | fi 612 | done 613 | if [ "$(wc -l < "${series}")" -gt 2 ]; then 614 | info "Using series from commit message..." 615 | ${GIT} log -1 --format='%b' "${base_rev}" | sed '$d' > "${series}" 616 | if ${STABLE}; then 617 | local topic rev 618 | rev="$(${GIT} rev-parse ${import})" 619 | if ! topic="$(${GIT} symbolic-ref -q --short "${import}")"; then 620 | topic="$(topic_from_rev "${import}")" 621 | fi 622 | s="# umpf-topic: ${topic}\n# umpf-hashinfo: ${rev}\n" 623 | sed -i "s;^# umpf-end;${s}\0;" "${series}" 624 | fi 625 | ${GIT} rev-parse "${base_rev}^" > "${STATE}/flat" 626 | if ${VERBOSE}; then 627 | info 628 | cat "${series}" 629 | fi 630 | return 631 | fi 632 | info "Creating series from merges..." 633 | 634 | local -a merges branches branch_names 635 | local -A branch_squashes 636 | 637 | base_rev="$(${GIT} merge-base "${base_rev}^1" "${base_rev}^2")" 638 | exec {revlistfd}< <(${GIT} rev-list --merges --topo-order --parents "${base_rev}...${import}") 639 | while read head base merges <&${revlistfd}; do 640 | local magic base name 641 | exec {localfd}< <(${GIT} notes show "${head}" 2>/dev/null) 642 | # Reading git notes must be in sync with run_build() 643 | while read magic value <&${localfd}; do 644 | case "${magic}" in 645 | umpf-build-note:) 646 | BASE="${BASE:-${value% *}}" 647 | NAME="${NAME:-${value#* }}" 648 | ;; 649 | umpf-build-flags:) 650 | FLAGS="${FLAGS:-${value}}" 651 | ;; 652 | umpf-build-relative:) 653 | GIT_RELATIVE="${GIT_RELATIVE:-${value}}" 654 | ;; 655 | esac 656 | done 657 | exec {localfd}<&- 658 | if [[ -n "${BASE}" && -n "${NAME}" ]]; then 659 | break 660 | fi 661 | done 662 | exec {revlistfd}<&- 663 | 664 | if [ -z "${BASE}" ]; then 665 | BASE="$(${GIT} describe "${base_rev}" 2>/dev/null)" 666 | local choice 667 | read_interactive "base" "${BASE}" 668 | BASE="${choice}" 669 | fi 670 | echo "# umpf-base: ${BASE}" >> "${series}" 671 | if [ -n "${GIT_RELATIVE}" ]; then 672 | echo "# umpf-relative: ${GIT_RELATIVE}" >> "${series}" 673 | fi 674 | if [ -z "${NAME}" ]; then 675 | if ! NAME="$(${GIT} symbolic-ref -q --short "${import}")"; then 676 | if ${GIT} show-ref --tags --heads -q "${import}"; then 677 | NAME="${import}" 678 | fi 679 | fi 680 | NAME="${NAME##${GIT_REMOTE}}" 681 | if [ -z "${NAME}" ]; then 682 | read -e -p "name: " NAME 683 | fi 684 | fi 685 | echo "# umpf-name: ${NAME}" >> "${series}" 686 | mapfile -t merges < <(${GIT} rev-list --merges --reverse --topo-order --parents "${BASE}...${import}" | { 687 | while read head base merges; do 688 | for merge in ${merges}; do 689 | echo "${head}:${merge}" 690 | done 691 | done } ) 692 | names="#" 693 | for merge in "${merges[@]}"; do 694 | local squash= 695 | head="${merge%:*}" 696 | branch="${merge#*:}" 697 | find_branch_name "${head}" "${branch}" 698 | test -z "${name}" && continue 699 | if ! grep -q "#${name}#" <<< "${names}"; then 700 | branch_names[${#branch_names[@]}]="${name}" 701 | branch_squashes[${name}]="${squash}" 702 | names="${names}${name}#" 703 | tmp_branches[${name}]="${branch}" 704 | fi 705 | done 706 | for name in "${branch_names[@]}"; do 707 | branch="${tmp_branches[${name}]}" 708 | if [ "${branch_squashes[${name}]}" = 1 ]; then 709 | echo "# umpf-squash-topic: ${name}" >> "${series}" 710 | else 711 | echo "# umpf-topic: ${name}" >> "${series}" 712 | fi 713 | echo "# umpf-hashinfo: ${branch}" >> "${series}" 714 | branches[${#branches[@]}]="${branch}" 715 | done 716 | echo "# umpf-end" >> "${series}" 717 | if ${VERBOSE}; then 718 | info 719 | cat "${series}" 720 | show_diff "${import}" "${BASE}" 721 | fi 722 | } 723 | 724 | merge() { 725 | local rev topic into squash_topic 726 | rev="${1}" 727 | topic="${2}" 728 | if [ -z "${topic}" ]; then 729 | topic="$(topic_from_rev "${rev}")" 730 | fi 731 | if [ -z "${topic}" ]; then 732 | info "Failed to derive topic name from '${rev}'" 733 | if [ "${COMMAND}" = "merge" ]; then 734 | info 735 | info "Use 'umpf merge ' to specify the topic name". 736 | info 737 | fi 738 | return 1 739 | fi 740 | if [ -f "${STATE}/name" ]; then 741 | into=" into $(<${STATE}/name)" 742 | elif ! into=" into $(${GIT} symbolic-ref -q --short HEAD)"; then 743 | into="" 744 | fi 745 | if [ "${squash}" = 1 ]; then 746 | squash_topic="umpf-squash-topic" 747 | fi 748 | info "merging '${topic}'..." 749 | ${GIT} merge --no-ff -m " 750 | Merge '${topic}'${into} 751 | 752 | umpf-merge-topic: ${topic} 753 | ${squash_topic} 754 | " "${rev}" 755 | if [ $? -ne 0 ]; then 756 | ${AUTO_RERERE} && 757 | info "merge failed. Trying to continue with rerere solutions..." && 758 | test -z "$(${GIT} rerere remaining)" && 759 | info "Looks like rerere was successful." && 760 | ${GIT} add -u && 761 | ${GIT} commit 762 | fi 763 | } 764 | 765 | ### namespace: check ### 766 | 767 | verify_topic() { 768 | if [ ! -e "${STATE}/check" ]; then 769 | return 770 | fi 771 | if ${IDENTICAL} && ! grep -q hashinfo "${STATE}/check"; then 772 | abort "Cannot run identical '$(<${STATE}/command)' without 'hashinfo' (${line})!" 773 | fi 774 | if [ "$(<${STATE}/command)" = "format_patch" ] && ! grep -q topic-range "${STATE}/check"; then 775 | abort "Cannot run '$(<${STATE}/command)' without a 'topic-range' for each 'topic'!" \ 776 | "Maybe you need to 'tag' first?" 777 | fi 778 | } 779 | 780 | check_topic() { 781 | verify_topic 782 | echo "topic" > "${STATE}/check" 783 | 784 | } 785 | 786 | check_release() { 787 | verify_topic 788 | echo "release" > "${STATE}/check" 789 | # release has no hashinfo. Add it to satisfy verify_topic in check_end 790 | echo "hashinfo" >> "${STATE}/check" 791 | } 792 | 793 | check_hashinfo() { 794 | if [ ! -e "${STATE}/check" ] || grep -q hashinfo "${STATE}/check"; then 795 | abort "'hashinfo' without 'topic'!" 796 | fi 797 | echo "hashinfo" >> "${STATE}/check" 798 | } 799 | 800 | check_topic_range() { 801 | if [ ! -e "${STATE}/check" ] || grep -q topic-range "${STATE}/check"; then 802 | abort "'topic-range' without 'topic'!" 803 | fi 804 | echo "topic-range" >> "${STATE}/check" 805 | } 806 | 807 | verify_flag() { 808 | local flag validval=0 809 | 810 | flag=flag_$flagname 811 | declare -p ${flag} &>/dev/null || abort "Unknown umpf-flag: ${flagname} (supported flags: ${SUPPORTED_FLAGS[*]})" 812 | 813 | declare -n flag 814 | for v in ${flag[values]}; do 815 | [ "${v}" != "${flagval}" ] && continue 816 | 817 | # shellcheck disable=SC2154 818 | flag[val]="${v}" 819 | validval=1 820 | done 821 | 822 | [ ${validval} -eq 1 ] || abort "Invalid umpf-flag value: ${flagval} (allowed values: ${flag[values]})!" 823 | } 824 | 825 | check_flags() { 826 | local flagval flagname 827 | 828 | for keyval in ${content}; do 829 | flagname=${keyval%%=*} 830 | flagval=${keyval#*=} 831 | 832 | verify_flag 833 | done 834 | } 835 | 836 | check_end() { 837 | verify_topic 838 | echo "end" > "${STATE}/check" 839 | } 840 | 841 | check_series() { 842 | mv "${STATE}/series" "${STATE}/series.in" 843 | parse_series check "${STATE}/series.in" 844 | if [ ! -f "${STATE}/check" ]; then 845 | abort "Empty series!" 846 | fi 847 | if ! grep -q end "${STATE}/check"; then 848 | echo "# umpf-end" >> "${STATE}/done" 849 | fi 850 | # done contains the series with name/base fixups 851 | cp "${STATE}/done" "${STATE}/series" 852 | rm -f "${STATE}/check" "${STATE}/series.in" 853 | # cleanup so parse_series can be run again 854 | rm -f "${STATE}/name" "${STATE}/version" "${STATE}/tag" "${STATE}/base" "${STATE}/done" 855 | } 856 | 857 | ### parse ### 858 | 859 | parse_setup() { 860 | line="$1" 861 | 862 | cmd="$(sed -n -r "s/# umpf-([a-z-]*)(:.*)?\$/\1/p" <<< "$line")" 863 | content="$(sed -n -r "s/# umpf-[a-z-]*: *(.*)\$/\1/p" <<< "$line")" 864 | } 865 | 866 | do_exec() { 867 | local func="${namespace}_${1}" 868 | shift 869 | if declare -F | grep " ${func}$" &>/dev/null; then 870 | "${func}" "${@}" 871 | fi 872 | } 873 | 874 | parse() { 875 | local line cmd content 876 | 877 | parse_setup "$@" 878 | 879 | grep -q "^${line}$" "${STATE}/done" 2> /dev/null && return 880 | 881 | if [ -e "${STATE}/base" ]; then 882 | has_base=true 883 | else 884 | has_base=false 885 | fi 886 | if grep -q "^${line}$" "${STATE}/failed" 2>/dev/null; then 887 | has_failed=true 888 | else 889 | has_failed=false 890 | fi 891 | case "$cmd" in 892 | "") 893 | do_exec other 894 | ;; 895 | base) 896 | local reply baserev 897 | ${has_base} && bailout "duplicate base line" 898 | content="${BASE:-${content}}" 899 | line="# umpf-base: ${content}" 900 | test -n "${content}" || bailout "${cmd} line without value" 901 | echo "${content}" > "${STATE}/base-name" 902 | if ! baserev="$(${GIT} rev-parse --verify -q "refs/tags/${content}^{}" 2>/dev/null)"; then 903 | find_branch_rev "${content}" || abort "invalid base: '${content}'" 904 | baserev="${reply}" 905 | fi 906 | echo "${baserev}" > "${STATE}/base" 907 | 908 | do_exec base 909 | 910 | if [ -n "${GIT_RELATIVE}" ]; then 911 | echo "${line}" >> "${STATE}/done" 912 | content="${GIT_RELATIVE}" 913 | line="# umpf-relative: ${content}" 914 | do_exec relative 915 | fi 916 | 917 | if [ -n "${FLAGS}" ]; then 918 | echo "${line}" >> "${STATE}/done" 919 | content="${FLAGS}" 920 | line="# umpf-flags: ${content}" 921 | do_exec flags 922 | fi 923 | ;; 924 | flags) 925 | ${has_base} || bailout "${cmd} before base" 926 | test -n "${content}" || bailout "${cmd} line without value" 927 | if [ -z "${FLAGS}" ]; then 928 | do_exec flags 929 | fi 930 | ;; 931 | relative) 932 | ${has_base} || bailout "${cmd} before base" 933 | test -n "${content}" || bailout "${cmd} line without value" 934 | if [ -z "${GIT_RELATIVE}" ]; then 935 | GIT_RELATIVE="${content}" 936 | do_exec relative 937 | fi 938 | ;; 939 | name) 940 | ${has_base} || bailout "${cmd} before base" 941 | content="${NAME:-${content}}" 942 | line="# umpf-name: ${content}" 943 | test -n "${content}" || bailout "${cmd} line without value" 944 | test -e "${STATE}/name" && bailout "duplicate name line" 945 | local version="$(date +%Y%m%d ${SOURCE_DATE_EPOCH:+--date=@${SOURCE_DATE_EPOCH}})${VERSION_SEPARATOR}${VERSION}" 946 | local name="${content}" 947 | local tagname="${name}/${version}" 948 | echo "${name}" > "${STATE}/name" 949 | echo "${version}" > "${STATE}/version" 950 | echo "${tagname}" > "${STATE}/tag" 951 | 952 | do_exec name 953 | ;; 954 | version) 955 | ${has_base} || bailout "${cmd} before base" 956 | test -n "${content}" || bailout "${cmd} line without value" 957 | if ${STABLE}; then 958 | local name="$(<"${STATE}/name")" 959 | local version="$(sed "s;${name}/\([0-9]\{8\}\)${VERSION_SEPARATOR}.*;\1${VERSION_SEPARATOR}${VERSION};" <<< "${content}")" 960 | local tagname="${name}/${version}" 961 | echo "${version}" > "${STATE}/version" 962 | echo "${tagname}" > "${STATE}/tag" 963 | fi 964 | do_exec version 965 | ;; 966 | release) 967 | ${has_base} || bailout "${cmd} before base" 968 | test -n "${content}" || bailout "${cmd} line without value" 969 | do_exec release 970 | ;; 971 | topic|squash-topic) 972 | case $cmd in 973 | topic) squash= ;; 974 | squash-topic) squash=1;; 975 | esac 976 | ${has_base} || bailout "${cmd} before base" 977 | test -n "${content}" || bailout "${cmd} line without value" 978 | do_exec topic 979 | ;; 980 | hashinfo) 981 | ${has_base} || bailout "${cmd} before base" 982 | test -n "${content}" || bailout "${cmd} line without value" 983 | do_exec hashinfo 984 | ;; 985 | topic-range) 986 | ${has_base} || bailout "${cmd} before base" 987 | test -n "${content}" || bailout "${cmd} line without value" 988 | do_exec topic_range 989 | ;; 990 | end) 991 | ${has_base} || bailout "${cmd} before base" 992 | do_exec end 993 | rm "${STATE}/base" 994 | ;; 995 | esac 996 | 997 | rm -f "${STATE}/failed" 998 | echo "${line}" >> "${STATE}/done" 999 | } 1000 | 1001 | parse_series() { 1002 | local namespace="${1}" 1003 | local series="${2}" 1004 | local squash 1005 | exec {series_in}< "${series}" 1006 | while read line <&${series_in}; do 1007 | parse "$line" 1008 | done 1009 | exec {series_in}<&- 1010 | unset series_in 1011 | } 1012 | 1013 | ### namespace: rebase ### 1014 | 1015 | rebase_other() { 1016 | if $has_base; then 1017 | : # skip 1018 | else 1019 | printf "%s\n" "$line" >&${series_out} 1020 | fi 1021 | } 1022 | 1023 | rebase_base() { 1024 | echo "$line" >&${series_out} 1025 | echo 1 > "${STATE}/num" 1026 | ${GIT} checkout -q "${baserev}" || abort "checkout '${content}' failed" 1027 | if grep -sq "project('libcamera'," "meson.build"; then 1028 | PROJECT="libcamera" 1029 | VERSION_SEPARATOR="." 1030 | fi 1031 | } 1032 | 1033 | rebase_name() { 1034 | echo "$line" >&${series_out} 1035 | if ! ${STABLE}; then 1036 | rebase_version_impl 1037 | fi 1038 | } 1039 | 1040 | rebase_version_impl() { 1041 | echo "# umpf-version: ${tagname}" >&${series_out} 1042 | 1043 | if ! ${FORCE} && ${GIT} show-ref --tags -q "${tagname}"; then 1044 | abort "Tag '${tagname}' already exists!" 1045 | fi 1046 | if ! ${FORCE} && ${GIT} show-ref --tags -q "${tagname}-flat"; then 1047 | abort "Tag '${tagname}-flat' already exists!" 1048 | fi 1049 | } 1050 | 1051 | rebase_version() { 1052 | if ${STABLE}; then 1053 | rebase_version_impl 1054 | fi 1055 | } 1056 | 1057 | rebase_relative() { 1058 | echo "$line" >&${series_out} 1059 | } 1060 | 1061 | rebase_try_continue() { 1062 | if ${GIT} diff-index --quiet HEAD --; then 1063 | info "rebase failed. Skipping empty commit..." && 1064 | (${GIT} rebase --skip || rebase_try_continue) 1065 | else 1066 | ${AUTO_RERERE} && 1067 | info "rebase failed. Trying to continue with rerere solutions..." && 1068 | test -z "$(${GIT} rerere remaining)" && 1069 | info "Looks like rerere was successful." && 1070 | ${GIT} add -u && 1071 | (${GIT} rebase --continue || rebase_try_continue) 1072 | fi 1073 | } 1074 | 1075 | rebase_branch() { 1076 | local name="${1}" 1077 | local hash="${2}" 1078 | if ${has_failed}; then 1079 | if [[ -d "${GIT_DIR}/rebase-apply" || -d "${GIT_DIR}/rebase-merge" ]]; then 1080 | ${GIT} rebase --continue || bailout "'rebase --continue' failed" 1081 | fi 1082 | else 1083 | local reply topicrev base args 1084 | find_branch_rev "${name}" "${hash}" 1085 | topicrev="${reply}" 1086 | base="$(${GIT} rev-list -n1 --merges ${topicrev} "^$(cat ${STATE}/base)")" 1087 | if [ -n "${base}" ]; then 1088 | if ${GIT} log -1 "${base}" | grep -q '^ umpf-merge-topic:'; then 1089 | : # stop at the umpf merge 1090 | elif [ "$(${GIT} log -1 "${base}" | sed -n '/^ # umpf-base/,/^ # umpf-end/p' | wc -l)" -gt 2 ]; then 1091 | : # stop at the umpf tag 1092 | else 1093 | base= 1094 | fi 1095 | fi 1096 | if [ -z "${base}" ]; then 1097 | local -a topics 1098 | mapfile -t topics < <(cat ${STATE}/topics 2>/dev/null) 1099 | base="$(${GIT} merge-base ${topicrev} "$(cat ${STATE}/base 2>/dev/null)" "${topics[@]}")" 1100 | fi 1101 | echo "${topicrev}" >> "${STATE}/topics" 1102 | 1103 | if [ "${squash}" = 1 ]; then 1104 | echo "# umpf-squash-topic: ${name}" >&${series_out} 1105 | else 1106 | echo "# umpf-topic: ${name}" >&${series_out} 1107 | fi 1108 | echo "# umpf-hashinfo: ${topicrev}" >&${series_out} 1109 | 1110 | ${GIT} rev-parse HEAD > "${STATE}/prev_head" 1111 | if ${GIT} log --oneline "${base}..${topicrev}" | grep -q '\(amend\|fixup\|squash\)!'; then 1112 | args="-i --autosquash" 1113 | fi 1114 | if ! ${GIT} rebase -q ${args} --no-keep-empty --onto HEAD "${base}" "${topicrev}" >&2; then 1115 | if ! rebase_try_continue; then 1116 | bailout "rebase failed" 1117 | fi 1118 | fi 1119 | fi 1120 | if [ "${squash}" = 1 ]; then 1121 | local commit1 tree next 1122 | commit1="$(git rev-list "$(<"${STATE}/prev_head").." | tail -n1)" 1123 | tree="$(${GIT} log -1 --format="%T")" 1124 | next="$(${GIT} commit-tree "${tree}" -p "$(<"${STATE}/prev_head")" -m "tmp")" && 1125 | ${GIT} checkout -q "${next}" && 1126 | ${GIT} commit -q --amend -C "${commit1}" 1127 | if [ $? -ne 0 ]; then 1128 | bailout "failed to squash topic branch." 1129 | fi 1130 | fi 1131 | # Fix the committer date to get a reproducible result. Traditionally 1132 | # git rebase --committer-date-is-author-date was used here, but that 1133 | # yielded histories with non-monotonic commit dates which confuses git 1134 | # in some situations. See 1135 | # https://lore.kernel.org/git/20200325053039.GA651138@coredump.intra.peff.net/ 1136 | # for some details. So we're cloning the committer date of the base commit. 1137 | committerdate="$(${GIT} for-each-ref --format="%(taggerdate:raw)" "refs/tags/$(<"${STATE}/base-name")")" 1138 | if [ -z "${committerdate}" ]; then 1139 | committerdate="$(${GIT} log -1 --format=%cd --date=raw "$(<"${STATE}/base")")" 1140 | fi 1141 | 1142 | declare -a msg_filter 1143 | if [ "${flag_upstreamstatus[val]}" = "insert" ]; then 1144 | msg_filter=( 1145 | --msg-filter 1146 | "awk ' 1147 | /^Upstream-Status:/ { 1148 | done=1 1149 | } 1150 | /^[^\s]*-by:/ { 1151 | if (!done) { 1152 | print \"Upstream-Status: Pending\n\" 1153 | done=1 1154 | } 1155 | } 1156 | { 1157 | print \$0 1158 | } 1159 | END { 1160 | if (!done) 1161 | print \"\nUpstream-Status: Pending\" 1162 | }'" ) 1163 | fi 1164 | 1165 | if ! FILTER_BRANCH_SQUELCH_WARNING=1 "${GIT}" filter-branch -f "${msg_filter[@]}" --env-filter "GIT_COMMITTER_DATE='$committerdate'; GIT_COMMITTER_NAME=umpf; GIT_COMMITTER_EMAIL=entwicklung@pengutronix.de" "$(<"${STATE}/prev_head").."; then 1166 | bailout "rewrite for reproducible commit-ish failed." 1167 | fi 1168 | echo "# umpf-topic-range: $(<"${STATE}/prev_head")..$(${GIT} rev-parse HEAD)" >&${series_out} 1169 | } 1170 | 1171 | rebase_topic() { 1172 | if ${IDENTICAL}; then 1173 | if [ -n "${EXPORT_TOPIC}" ]; then 1174 | bailout "Identical export requires series with 'hashinfo'" 1175 | fi 1176 | EXPORT_TOPIC="${content}" 1177 | else 1178 | rebase_branch "${content}" 1179 | fi 1180 | } 1181 | rebase_hashinfo() { 1182 | if ${IDENTICAL}; then 1183 | rebase_branch "${EXPORT_TOPIC}" "${content}" 1184 | EXPORT_TOPIC= 1185 | fi 1186 | } 1187 | 1188 | rebase_flags() { 1189 | echo "$line" >&${series_out} 1190 | } 1191 | 1192 | rebase_end() { 1193 | local version="$(<"${STATE}/version")" 1194 | local version_file 1195 | local meson_build 1196 | local meson_extra 1197 | ${GIT} rev-parse HEAD > "${STATE}/prev_head" 1198 | if grep -sq '^EXTRAVERSION =' Makefile; then 1199 | 1200 | if [ ${flag_extraversion[val]} == "conflictfree" ]; then 1201 | sed -i -r "s;^(KERNELRELEASE =.*)\$;EXTRAVERSION := \$(EXTRAVERSION)-${version}\n\1;" Makefile 1202 | else 1203 | sed -i -r "s:^(EXTRAVERSION =.*)\$:\1-${version}:" Makefile 1204 | fi 1205 | git add Makefile 1206 | elif grep -sq '^VERSION_STRING\s*:=' Makefile; then 1207 | 1208 | sed -i -r "s;^(VERSION_STRING\s*:=.*)\$;\1-${version};" Makefile 1209 | git add Makefile 1210 | fi 1211 | if version_file="$(grep -l AC_INIT configure.* 2>/dev/null)"; then 1212 | perl -0777 -i -p -e "s/\b(AC_INIT\()(\[[^\]]*\]|[^),]*)(\s*,\s*)(\[[^\]]*|[^,]*)(\]?[^)]*\))/\1\2\3\4.${version}\5/" "${version_file}" 1213 | git add "${version_file}" 1214 | fi 1215 | meson_build=${GIT_RELATIVE:+${GIT_RELATIVE}/}meson.build 1216 | if [ -e units/systemd-journald.socket ]; then 1217 | # for systemd fixup GIT_VERSION 1218 | # the project version is used in library names 1219 | sed -i "s/@VCS_TAG@/\0.${version}/" src/version/version.h.in && 1220 | git add src/version/version.h.in 1221 | elif grep -sq "'gallium-@0@'.format(meson.project_version())" src/gallium/targets/dri/meson.build; then 1222 | # for Mesa >= 24.2.0 fixup PACKAGE_VERSION 1223 | # the project version is used in library names 1224 | sed -i "s/-DPACKAGE_VERSION=\"@0@/\0.${version}/" meson.build && 1225 | git add meson.build 1226 | elif [ -e "${meson_build}" ]; then 1227 | case "${PROJECT}" in 1228 | libcamera) 1229 | meson_extra="+${version}" 1230 | ;; 1231 | *) 1232 | meson_extra=".${version}" 1233 | ;; 1234 | esac 1235 | prog="$(cat <<- EOF 1236 | s{ 1237 | \b(project\( 1238 | (? 1239 | (? 1240 | ( 1241 | (?\s* 1242 | ( (?[a-zA-Z0-9_]++) # an identifier 1243 | | ' [^']*+ ' # a non-nested single quoted string 1244 | | " [^"]*+ " # double 1245 | | \[ (?&expr_comma)*(?&expr) \] # list of expressions 1246 | | \( (?&expr_comma)* 1247 | ( (?&expr) # function arguments 1248 | | (? 1249 | (?\s* 1250 | (?&identifier)\s*:(?&expr) 1251 | ) 1252 | ,\s*)* 1253 | (?&named_arg) # named function arguments 1254 | ) \) 1255 | | \. # struct members etc. 1256 | )* # function name + arguments etc. 1257 | \s*) 1258 | | (?&expr_noternary) \? (?&expr_noternary) : (?&expr) 1259 | ) 1260 | ),\s* 1261 | )*+ 1262 | ( 1263 | (?!version[\s:]) 1264 | (?&identifier)*\s*:(?&expr)\s*,\s* 1265 | )*+ # all named arguments except 'version' 1266 | version\s*:\s(?(?&expr)) # 'version' argument 1267 | ) 1268 | }{\1 + '${meson_extra}'}x 1269 | EOF 1270 | )" 1271 | version_arg="$(perl -0777 -n -e "${prog} && print $+{version}" "${meson_build}")" 1272 | version_file="$(sed -n "s/^files('\(.*\)')$/\1/p" <<<${version_arg})" 1273 | if [ -e "${version_file}" ]; then 1274 | sed -i "s/$/.${version}/" "${version_file}" 1275 | git add "${version_file}" 1276 | else 1277 | perl -0777 -i -p -e "${prog}" "${meson_build}" 1278 | if grep -q 'gst_version_nano' "${meson_build}"; then 1279 | # our extra version is not the nano version 1280 | sed -i 's/\(if version_arr.length() ==\) 4/\1 5/' "${meson_build}" 1281 | fi 1282 | git add "${meson_build}" 1283 | fi 1284 | local doap_script=${GIT_RELATIVE:+${GIT_RELATIVE}/}scripts/extract-release-date-from-doap-file.py 1285 | local doap=( ${GIT_RELATIVE:+${GIT_RELATIVE}/}*.doap ) 1286 | if [ -e "${doap_script}" ] && ls "${doap[@]}" &>/dev/null; then 1287 | local base_rev="$(<"${STATE}/base")" 1288 | local BASE="$(${GIT} describe --abbrev=0 "${base_rev}" 2>/dev/null)" 1289 | local revision="${BASE}.${version}" 1290 | # create the release date string from the version 1291 | local created="$(echo ${version} | sed "s/\([0-9]\{4\}\)\([0-9]\{2\}\)\([0-9]\{2\}\).*/\1-\2-\3/")" 1292 | sed -i '1,//s,.*.*, '"${revision}${created}\n\n&," "${doap[@]}" 1293 | git add "${doap[@]}" 1294 | fi 1295 | fi 1296 | if ! ${GIT} diff-index --cached --quiet HEAD --; then 1297 | local tagname="$(<"${STATE}/tag")" 1298 | local extra_message 1299 | if [ "${flag_upstreamstatus[val]}" = "insert" ]; then 1300 | extra_message=" 1301 | 1302 | Upstream-Status: Inappropriate [autogenerated]" 1303 | fi 1304 | ${GIT} commit --no-verify -m "Release ${tagname}${extra_message}" 1305 | echo "# umpf-release: ${tagname}" >&${series_out} 1306 | echo "# umpf-topic-range: $(<"${STATE}/prev_head")..$(${GIT} rev-parse HEAD)" >&${series_out} 1307 | fi 1308 | echo "$line" >&${series_out} 1309 | } 1310 | 1311 | ### command: export/continue ### 1312 | 1313 | create_tag() { 1314 | local args tagname parents tree topic 1315 | local -a topics 1316 | 1317 | if [ ! -e "${STATE}/tag" ]; then 1318 | return 1319 | fi 1320 | tagname="$(<"${STATE}/tag")" 1321 | 1322 | if ${FORCE}; then 1323 | args="-f" 1324 | fi 1325 | 1326 | tree="$(${GIT} log -1 --format="%T")" 1327 | if [ -e "${STATE}/topics" ]; then 1328 | mapfile -t topics < "${STATE}/topics" 1329 | for topic in "${topics[@]}"; do 1330 | parents="${parents} -p ${topic}" 1331 | done 1332 | fi 1333 | commit=$(${GIT} commit-tree "${tree}" -p HEAD ${parents} -m "${tagname}" -F "${STATE}/series.next") 1334 | 1335 | if ${GIT} tag ${args} --cleanup=verbatim -F "${STATE}/series.next" "${tagname}" "${commit}" >&2; then 1336 | if ${GIT} tag ${args} --cleanup=verbatim -F "${STATE}/series.next" "${tagname}-flat" >&2; then 1337 | ${GIT} checkout -q "${tagname}" 1338 | else 1339 | ${GIT} tag -d "${tagname}" >&2 1340 | ${GIT} checkout -q "${commit}" 1341 | bailout "Could not create tag '${tagname}-flat'" 1342 | fi 1343 | else 1344 | ${GIT} checkout -q "${commit}" 1345 | bailout "Could not create tag '${tagname}'" 1346 | fi 1347 | } 1348 | 1349 | run_tag() { 1350 | set -e 1351 | 1352 | exec {series_out}> >(tee -a "${STATE}/series.next") 1353 | 1354 | parse_series rebase "${STATE}/series" 1355 | 1356 | if [ -e "${STATE}/failed" ] && [ "$(<"${STATE}/failed")" != "create_tag" ]; then 1357 | abort "unexpected failure while parsing '${STATE}/series'" 1358 | fi 1359 | exec {series_out}<&- 1360 | unset series_out 1361 | 1362 | # series was parsed completely, but if create_tag bails out, signal 1363 | # this failure to ourselves if the user continues later. 1364 | line="create_tag" 1365 | create_tag 1366 | 1367 | cleanup 1368 | } 1369 | 1370 | do_tag() { 1371 | prepare_persistent tag "${@}" 1372 | run_tag 1373 | } 1374 | 1375 | ### namespace: format_patch ### 1376 | 1377 | format_patch_other() { 1378 | if $has_base; then 1379 | : # skip 1380 | else 1381 | if [[ "${line}" =~ 'git-ptx-patches magic' ]]; then 1382 | local md5="$(cat "${STATE}/series.next"|md5sum)" 1383 | echo "# ${md5} git-ptx-patches magic" >&${series_out} 1384 | else 1385 | printf "%s\n" "$line" >&${series_out} 1386 | fi 1387 | fi 1388 | } 1389 | 1390 | format_patch_base() { 1391 | echo "$line" >&${series_out} 1392 | echo 1 > "${STATE}/num" 1393 | } 1394 | 1395 | format_patch_name() { 1396 | echo "$line" >&${series_out} 1397 | } 1398 | 1399 | format_patch_version() { 1400 | local name="$(<"${STATE}/name")" 1401 | local version="${content#${name}/}" 1402 | echo "${version}" > "${STATE}/version" 1403 | echo "${content}" > "${STATE}/tag" 1404 | echo "$line" >&${series_out} 1405 | if ${NIX}; then 1406 | echo "[" >&${series_out} 1407 | fi 1408 | } 1409 | 1410 | format_patch_release() { 1411 | echo "$line" >&${series_out} 1412 | } 1413 | 1414 | format_patch_relative() { 1415 | echo "$line" >&${series_out} 1416 | } 1417 | 1418 | format_patch_topic() { 1419 | echo "$line" >&${series_out} 1420 | } 1421 | 1422 | format_patch_hashinfo() { 1423 | echo "$line" >&${series_out} 1424 | } 1425 | 1426 | filter_patches() { 1427 | if ${BB}; then 1428 | echo 'SRC_URI += "\' 1429 | sed "s,^${STATE}/\(.*\)$, file://\1 \\\\," 1430 | echo ' "' 1431 | elif ${NIX}; then 1432 | sed "s,^${STATE}/patches/\(.*\)$, ./\1," 1433 | else 1434 | sed "s,^${STATE}/patches/,," 1435 | fi 1436 | } 1437 | 1438 | format_patch_topic_range() { 1439 | echo "$line" >&${series_out} 1440 | local range="${content}" 1441 | local num="$(<"${STATE}/num")" 1442 | local relative=${GIT_RELATIVE+--relative=${GIT_RELATIVE}} 1443 | ${GIT} format-patch --indent-heuristic --no-renames -N --no-signature ${relative} --start-number ${num} --summary --stat=80 -o "${STATE}/patches" --notes "${range}" | 1444 | filter_patches >&${series_out} 1445 | num="$((num + $(${GIT} rev-list "${range}" | wc -l)))" 1446 | num="$((((num-2)/${BLOCK_SIZE}+1)*${BLOCK_SIZE}+1))" 1447 | echo "${num}" > "${STATE}/num" 1448 | } 1449 | 1450 | format_patch_flags() { 1451 | echo "$line" >&${series_out} 1452 | } 1453 | 1454 | format_patch_end() { 1455 | if ${NIX}; then 1456 | echo "]" >&${series_out} 1457 | fi 1458 | if ${BB}; then 1459 | local base_name="$(<"${STATE}/base-name")" 1460 | echo "UMPF_BASE = \"${base_name//v/}\"" >&${series_out} 1461 | echo "UMPF_VERSION = \"$(<"${STATE}/version")\"" >&${series_out} 1462 | echo "UMPF_PV = \"\${UMPF_BASE}-\${UMPF_VERSION}\"" >&${series_out} 1463 | if [ "$(head -n 1 README 2>/dev/null)" = "Linux kernel" ]; then 1464 | echo "LINUX_VERSION ?= \"\${UMPF_BASE}\"" >&${series_out} 1465 | fi 1466 | fi 1467 | echo "$line" >&${series_out} 1468 | } 1469 | 1470 | 1471 | ### command: format_patch ### 1472 | 1473 | remove_patches() { 1474 | local line cmd content 1475 | 1476 | parse_setup "$@" 1477 | case "${cmd}" in 1478 | base) 1479 | begin=1 1480 | ;; 1481 | end) 1482 | begin= 1483 | ;; 1484 | esac 1485 | if ${BB}; then 1486 | line="$(sed -n -r "s,file://patches/(.*) \\\\$,\1,p" <<< "$line")" 1487 | fi 1488 | case "${line}" in 1489 | [0-9][0-9][0-9][0-9]-*) 1490 | [ -z "${begin}" ] && return 1491 | [ ! -e "${PATCH_DIR}/${line}" ] && return 1492 | info "deleting '${line}'..." 1493 | rm "${PATCH_DIR}/${line}" 1494 | ;; 1495 | esac 1496 | } 1497 | 1498 | run_format_patch() { 1499 | exec {series_out}> >(tee -a "${STATE}/series.next") 1500 | 1501 | parse_series format_patch "${STATE}/series" 1502 | 1503 | if [ -e "${STATE}/failed" ]; then 1504 | bailout "unexpected failure while parsing '${STATE}/series'" 1505 | fi 1506 | 1507 | exec {series_out}<&- 1508 | unset series_out 1509 | 1510 | mkdir -p "${PATCH_DIR}" || bailout "Failed to create patch dir" 1511 | for patch in "${STATE}/patches/"*; do 1512 | tail -n+2 "${patch}" > "${PATCH_DIR}/$(basename "${patch}")" 1513 | done 1514 | if ${BB}; then 1515 | cp "${STATE}/series.next" "${PATCH_DIR}/series.inc" 1516 | if [ "${flag_upstreamstatus[val]}" != "insert" ]; then 1517 | info 1518 | info "Note: Patches are created without Upstream-Status!" 1519 | info 1520 | fi 1521 | elif ${NIX}; then 1522 | cp "${STATE}/series.next" "${PATCH_DIR}/series.nix" 1523 | else 1524 | cp "${STATE}/series.next" "${PATCH_DIR}/series" 1525 | fi 1526 | 1527 | cleanup 1528 | } 1529 | 1530 | do_format_patch() { 1531 | prepare_persistent format_patch "${@}" 1532 | 1533 | if ${UPDATE}; then 1534 | if [ ! -d "${PATCH_DIR}" ]; then 1535 | abort "update without existing patch dir makes no sense" 1536 | fi 1537 | SERIES="${SERIES:-${PATCH_DIR}/series}" 1538 | if ${BB}; then 1539 | OLD_SERIES="${PATCH_DIR}/series.inc" 1540 | elif ${NIX}; then 1541 | OLD_SERIES="${PATCH_DIR}/series.nix" 1542 | else 1543 | OLD_SERIES="${PATCH_DIR}/series" 1544 | fi 1545 | if [ ! -f "${OLD_SERIES}" ]; then 1546 | abort "'${OLD_SERIES}' is missing!" 1547 | fi 1548 | while read -r line; do 1549 | remove_patches "${line}" 1550 | done < "${OLD_SERIES}" 1551 | elif ${FORCE} && [ -d "${PATCH_DIR}" ]; then 1552 | rm -r "${PATCH_DIR}" || abort "Failed to remove old patch dir" 1553 | elif [ -d "${PATCH_DIR}" ]; then 1554 | abort "patch dir '${PATCH_DIR}' exists!" 1555 | fi 1556 | 1557 | run_format_patch 1558 | } 1559 | 1560 | 1561 | ### namespace: build ### 1562 | 1563 | build_base() { 1564 | touch "${STATE}/merge" 1565 | ${GIT} checkout -q "${baserev}" || abort "checkout '${content}' failed" 1566 | } 1567 | 1568 | build_branch() { 1569 | local name="${1}" 1570 | local hash="${2}" 1571 | if ${has_failed}; then 1572 | if ! ${GIT} diff-index --quiet --cached HEAD; then 1573 | if ! ${GIT} commit --no-verify; then 1574 | bailout "Merging '${name}' failed!" 1575 | fi 1576 | fi 1577 | else 1578 | local reply 1579 | find_branch_rev "${name}" "${hash}" 1580 | if ! merge "${reply}" "${name}"; then 1581 | bailout "Merging '${name}' failed!" 1582 | fi 1583 | fi 1584 | } 1585 | 1586 | build_topic() { 1587 | if ${IDENTICAL}; then 1588 | if [ -n "${MERGE_TOPIC}" ]; then 1589 | bailout "Identical merge requires series with 'hashinfo'" 1590 | fi 1591 | MERGE_TOPIC="${content}" 1592 | else 1593 | build_branch "${content}" 1594 | fi 1595 | } 1596 | build_hashinfo() { 1597 | if ${IDENTICAL}; then 1598 | build_branch "${MERGE_TOPIC}" "${content}" 1599 | MERGE_TOPIC= 1600 | fi 1601 | } 1602 | 1603 | 1604 | ### command: build ### 1605 | 1606 | run_build() { 1607 | parse_series build "${STATE}/series" 1608 | ${GIT} notes add -m "umpf-build-note: $(<"${STATE}/base-name") $(<"${STATE}/name")" 1609 | if [ -f "${FLAGS}" ]; then 1610 | ${GIT} notes append -m "umpf-build-flags: $(<"${FLAGS}")" 1611 | fi 1612 | if [ -n "${GIT_RELATIVE}" ]; then 1613 | ${GIT} notes append -m "umpf-build-relative: ${GIT_RELATIVE}" 1614 | fi 1615 | 1616 | cleanup 1617 | } 1618 | 1619 | do_build() { 1620 | prepare_persistent build "${@}" 1621 | run_build 1622 | } 1623 | 1624 | ### command: merge ### 1625 | 1626 | do_merge() { 1627 | local branch 1628 | if [[ $# -lt 1 || $# -gt 2 ]]; then 1629 | abort "usage: umpf merge []" 1630 | fi 1631 | prepare 1632 | merge "${@}" 1633 | } 1634 | 1635 | ### namespace: diff ### 1636 | 1637 | diff_topic() { 1638 | if ! ${IDENTICAL}; then 1639 | local reply 1640 | find_branch_rev "${content}" 1641 | echo "${reply}" >> "${STATE}/topics" 1642 | fi 1643 | echo "${content}" >> "${STATE}/topic-names" 1644 | } 1645 | 1646 | diff_hashinfo() { 1647 | if ${IDENTICAL}; then 1648 | echo "${content}" >> "${STATE}/topics" 1649 | fi 1650 | } 1651 | 1652 | diff_end() { 1653 | local head 1654 | local -a branches branch_names 1655 | mapfile -t branches < "${STATE}/topics" 1656 | if [ -e "${STATE}/flat" ]; then 1657 | branches[${#branches[@]}]="$(<"${STATE}/flat")" 1658 | fi 1659 | mapfile -t branch_names < "${STATE}/topic-names" 1660 | 1661 | head="$(<"${STATE}/head")" 1662 | 1663 | show_diff "${head}" "$(<"${STATE}/base")" 1664 | } 1665 | 1666 | ### command: diff ### 1667 | 1668 | do_diff() { 1669 | prepare_persistent diff "${@}" 1670 | 1671 | echo "${SERIES}" > "${STATE}/head" 1672 | parse_series diff "${STATE}/series" 1673 | 1674 | if ${IDENTICAL} && [ ! -e "${STATE}/topics" ]; then 1675 | abort "Identical diff requires series with 'hashinfo'" 1676 | fi 1677 | 1678 | cleanup 1679 | } 1680 | 1681 | ### command: distribute ### 1682 | 1683 | apply_to_topic() { 1684 | local rev branch topic state base subject match 1685 | rev="${1}" 1686 | branch=$(cat "${STATE}/distribute-branch" 2>/dev/null) 1687 | topic=$(cat "${STATE}/distribute-topic" 2>/dev/null) 1688 | state=$(cat "${STATE}/distribute-state" 2>/dev/null) 1689 | base="$(<"${STATE}/base-name")" 1690 | 1691 | echo 1692 | GIT_PAGER="" ${GIT} log --oneline -1 "${rev}" 1693 | 1694 | subject="$(git log --pretty="format:%s" -1 "${rev}")" 1695 | case "${subject}" in 1696 | "fixup!"*|"amend!"*|"squash!"*) 1697 | match="${subject#*\! }" 1698 | ;; 1699 | esac 1700 | 1701 | while [ -z "${topic}" ]; do 1702 | local i=0 choice default 1703 | for branch in "${branch_names[@]}"; do 1704 | echo "${i}) ${branch}" 1705 | if git log --pretty="format:%s" "${base}..${branches[${i}]}" | grep -q "^${match}$"; then 1706 | default="${i}" 1707 | fi 1708 | i=$((i+1)) 1709 | done 1710 | echo "s) show patch" 1711 | echo "x) skip patch" 1712 | read_interactive "Branch" "${default}" 1713 | case "${choice}" in 1714 | s) 1715 | ${GIT} show "${rev}" 1716 | continue 1717 | ;; 1718 | x) 1719 | return 1720 | ;; 1721 | [0-9]*) 1722 | branch="${branch_names[${choice}]}" 1723 | if [ -z "${branch}" ]; then 1724 | echo "'${choice}' is not a valid branch number" 1725 | fi 1726 | ;; 1727 | *) 1728 | echo "Invalid command '${choice}'" 1729 | continue 1730 | esac 1731 | if ! topic="$(${GIT} rev-parse -q --verify "refs/umpf/${branch}^{}")"; then 1732 | topic="${branches[${choice}]}" 1733 | fi 1734 | if [ -z "${topic}" ]; then 1735 | local reply 1736 | IDENTICAL=false find_branch_rev "${branch}" 1737 | topic="${reply}" 1738 | branches[${choice}]="${topic}" 1739 | fi 1740 | echo "${branch}" > "${STATE}/distribute-branch" 1741 | echo "${topic}" > "${STATE}/distribute-topic" 1742 | done 1743 | case "${state}" in 1744 | fatal) 1745 | bailout "Fatal error occurred. Cannot continue." 1746 | ;; 1747 | "") 1748 | if ! ${GIT} checkout -q "${topic}"; then 1749 | echo fatal > "${STATE}/distribute-state" 1750 | bailout "failed to checkout '${branch}' (${topic})! This should not happen!" 1751 | fi 1752 | echo checkout > "${STATE}/distribute-state" 1753 | ;& 1754 | checkout) 1755 | local args 1756 | if [ -e "${GIT_DIR}/CHERRY_PICK_HEAD" ]; then 1757 | args="--continue" 1758 | else 1759 | args="${rev}" 1760 | fi 1761 | if ! ${GIT} cherry-pick "${args}"; then 1762 | bailout "cherry-pick ${args} failed." 1763 | fi 1764 | echo cherry-pick > "${STATE}/distribute-state" 1765 | ;& 1766 | cherry-pick) 1767 | if ! ${GIT} update-ref --no-deref "refs/umpf/${branch}" HEAD; then 1768 | echo fatal > "${STATE}/distribute-state" 1769 | bailout "update-ref failed! This should not happen!" 1770 | fi 1771 | ;; 1772 | esac 1773 | rm "${STATE}/distribute-branch" 1774 | rm "${STATE}/distribute-topic" 1775 | rm "${STATE}/distribute-state" 1776 | } 1777 | 1778 | update_local_topic() { 1779 | local topic="${GIT_REMOTE}${1}" 1780 | local umpf_topic="refs/umpf/${1}" 1781 | if ${GIT} rev-parse --verify -q "${topic}" > /dev/null; then 1782 | info "Fast-forwarding '${topic}'..." 1783 | if ! ${GIT} checkout -q "${topic#refs/heads/}"; then 1784 | info "Could not checkout '${topic}'. Skipping." 1785 | return 1786 | fi 1787 | if ! ${GIT} merge -q --ff-only "${umpf_topic}"; then 1788 | info "Could not update '${topic}'. Skipping." 1789 | return 1790 | fi 1791 | else 1792 | info "Creating new branch '${topic}'..." 1793 | if ! ${GIT} checkout -q -b "${topic#refs/heads/}" "${umpf_topic}"; then 1794 | info "Could not checkout '${umpf_topic}' as '${topic}'. Skipping." 1795 | return 1796 | fi 1797 | fi 1798 | ${GIT} update-ref -d "${umpf_topic}" 1799 | } 1800 | 1801 | update_remote_topic() { 1802 | local topic="${1}" 1803 | local umpf_topic="refs/umpf/${1}" 1804 | 1805 | info "Pushing '${topic}' to '${GIT_REMOTE%/}'..." 1806 | if ! ${GIT} push "${GIT_REMOTE%/}" "${umpf_topic}:refs/heads/${topic}"; then 1807 | info "Could not update '${GIT_REMOTE}${topic}'. Skipping." 1808 | return 1809 | fi 1810 | ${GIT} update-ref -d "${umpf_topic}" 1811 | } 1812 | 1813 | update_topics() { 1814 | local target 1815 | local -a topics 1816 | if ${GIT} remote | grep -q "^${GIT_REMOTE%/}$"; then 1817 | target="remote" 1818 | else 1819 | target="local" 1820 | fi 1821 | info 1822 | info "Updating ${target} topic branches for '${GIT_REMOTE}'..." 1823 | read -p "Press Enter to continue." 1824 | mapfile -t topics < <(${GIT} show-ref | sed -r -n 's,.* refs/umpf/(.*),\1,p') 1825 | for topic in "${topics[@]}"; do 1826 | update_${target}_topic "${topic}" 1827 | done 1828 | } 1829 | 1830 | run_distribute(){ 1831 | local -a branches branch_names 1832 | mapfile -t branches < "${STATE}/topics" 1833 | if ! ${IDENTICAL}; then 1834 | mapfile -t branch_names < "${STATE}/topic-names" 1835 | fi 1836 | 1837 | exec {patches_in}< "${STATE}/diff" 1838 | while read rev <&${patches_in}; do 1839 | grep -q "^${rev}$" "${STATE}/distribute-done" 2> /dev/null && continue 1840 | apply_to_topic "${rev}" 1841 | echo "${rev}" >> "${STATE}/distribute-done" 1842 | done 1843 | exec {patches_in}<&- 1844 | 1845 | update_topics 1846 | undo_persistent 1847 | if ${GIT} show-ref | grep -q " refs/umpf/"; then 1848 | info 1849 | info "Failed to update the following topic branches:" 1850 | ${GIT} show-ref | sed -r -n 's,.* refs/umpf/(.*),\1,p' 1851 | info 1852 | bailout 1853 | fi 1854 | cleanup 1855 | } 1856 | 1857 | do_distribute() { 1858 | prepare_persistent distribute "${@}" 1859 | 1860 | echo "${SERIES}" > "${STATE}/head" 1861 | parse_series diff "${STATE}/series" 1862 | 1863 | if [ ! -e "${STATE}/diff" ]; then 1864 | info 1865 | info "No new patches to distribute" 1866 | cleanup 1867 | return 1868 | fi 1869 | 1870 | if ${IDENTICAL} && [ ! -e "${STATE}/topics" ]; then 1871 | abort "Identical diff requires series with 'hashinfo'" 1872 | fi 1873 | 1874 | run_distribute 1875 | } 1876 | 1877 | ### command: continue ### 1878 | 1879 | do_continue() { 1880 | prepare 1881 | 1882 | test -f "${STATE}/command" || bailout "nothing to continue!" 1883 | # shellcheck source=/dev/null 1884 | . "${STATE}/config" || bailout "Failed to source '${STATE}/config'" 1885 | 1886 | case "$(<"${STATE}/command")" in 1887 | tag) 1888 | run_tag 1889 | ;; 1890 | build) 1891 | run_build 1892 | ;; 1893 | distribute) 1894 | run_distribute 1895 | ;; 1896 | *) 1897 | bailout "nothing to continue!" 1898 | ;; 1899 | esac 1900 | } 1901 | 1902 | ### command: abort ### 1903 | 1904 | do_abort() { 1905 | prepare 1906 | abort 1907 | } 1908 | 1909 | ### command: import ### 1910 | 1911 | do_show() { 1912 | VERBOSE=true 1913 | prepare_persistent show "${@}" 1914 | cleanup 1915 | } 1916 | 1917 | ### namespace: tig ### 1918 | 1919 | tig_topic() { 1920 | ${GIT} show-ref -s "${content}" >> "${STATE}/refs" 1921 | } 1922 | 1923 | tig_release() { 1924 | echo "${content}" >> "${STATE}/refs" 1925 | } 1926 | 1927 | tig_hashinfo() { 1928 | echo "${content}" >> "${STATE}/refs" 1929 | } 1930 | 1931 | ### command: tig ### 1932 | 1933 | do_tig () { 1934 | local -a refs 1935 | local base 1936 | 1937 | prepare_persistent tig "${@}" 1938 | parse_series tig "${STATE}/series" 1939 | 1940 | mapfile -t refs < "${STATE}/refs" 1941 | base="$(<"${STATE}/base-name")" 1942 | 1943 | # cut off each ref at base 1944 | tig ^"${base}"^ "${refs[@]}" 1945 | 1946 | cleanup 1947 | } 1948 | 1949 | ### command: init ### 1950 | 1951 | do_init() { 1952 | if [ $# = 0 ]; then 1953 | bailout "usage: umpf init " 1954 | fi 1955 | SERIES="${1}" 1956 | if ! ${FORCE} && [ -e "${SERIES}" ]; then 1957 | bailout "series file '${SERIES}' exists" 1958 | fi 1959 | 1960 | if [ -z "${BASE}" ]; then 1961 | read -e -p "base: " BASE 1962 | fi 1963 | echo "# umpf-base: ${BASE}" >> "${SERIES}" 1964 | if [ -n "${GIT_RELATIVE}" ]; then 1965 | echo "# umpf-relative: ${GIT_RELATIVE}" >> "${SERIES}" 1966 | fi 1967 | if [ -n "${FLAGS}" ]; then 1968 | echo "# umpf-flags: ${FLAGS}" >> "${series}" 1969 | fi 1970 | if [ -z "${NAME}" ]; then 1971 | read -e -p "name: " NAME 1972 | fi 1973 | echo "# umpf-name: ${NAME}" >> "${SERIES}" 1974 | while true; do 1975 | read -e -p "topic: " NAME 1976 | test -z "${NAME}" && break 1977 | echo "# umpf-topic: ${NAME}" >> "${SERIES}" 1978 | done 1979 | echo "# umpf-end" >> "${SERIES}" 1980 | } 1981 | 1982 | setup "${@}" 1983 | 1984 | command_func="do_${COMMAND//-/_}" 1985 | if declare -F | grep " ${command_func}$" &>/dev/null; then 1986 | "${command_func}" "${ARGS[@]}" 1987 | else 1988 | info "Unknown command '${COMMAND}'" 1989 | usage 1990 | exit 1 1991 | fi 1992 | --------------------------------------------------------------------------------