aboutsummaryrefslogtreecommitdiff
path: root/b4/command.py
AgeCommit message (Collapse)Author
2022-06-17Add ability to exit before git-merge is invokedKonstantin Ryabitsev
It may be useful for the maintainer to review b4 retrieval/validation output before git-merge is invoked, so add a pause requiring an Enter or Ctrl-C. Signed-off-by: Konstantin Ryabitsev <konstantin@linuxfoundation.org>
2022-06-16Implement "b4 shazam -M" that execs git-mergeKonstantin Ryabitsev
In addition to just being able to fetch a series into FETCH_HEAD, also add an option to exec git-merge automatically so that people don't have to cut-and-paste the merge command to use with paths to the cover letter. Signed-off-by: Konstantin Ryabitsev <konstantin@linuxfoundation.org>
2022-06-16Allow breaking threads using --no-parentKonstantin Ryabitsev
It is a common request to be able to get a partial thread in case someone submitted an auxiliary standalone patch in the middle of a larger patch series. Passing the msgid of the start of the thread along with --no-parent should tell b4 to break the thread at the start of the message-id specified and only consider that message and its children. Suggested-by: Mark Brown <broonie@kernel.org> Link: https://lore.kernel.org/tools/YpTI9lhCfA7shi6j@sirena.org.uk/ Signed-off-by: Konstantin Ryabitsev <konstantin@linuxfoundation.org>
2022-06-14am: Fix broken guessbranch handlingRob Herring
b4's usage of git-log '--branches' option is broken. The option takes a glob pattern *only* and must have an '=', but b4 ends up passing '--branches <guessbranch>' to git-log. This will kind of work, but is not checking only 'guessbranch'. For example, these 3 commands all do something different: git log -1 --branches=master git log -1 --branches master git log -1 --branches=*aster A maintainer wanting to apply a patch or series likely has a small set of known branches they apply patches to. Using a glob pattern is not a good fit for that. Instead, allow --guess-branch to be repeated and to take fixed refs. Signed-off-by: Rob Herring <robh@kernel.org> Signed-off-by: Konstantin Ryabitsev <konstantin@linuxfoundation.org> Link: https://lore.kernel.org/r/20220331195346.1384515-1-robh@kernel.org
2021-11-01mbox: initial support to check for unicode control charsKonstantin Ryabitsev
Implement initial support for checking if the patch message contains unicode control characters that can be used to trick code reviewer into accepting maliciously formatted code. Link: https://lore.kernel.org/tools/20211101175020.5r4cwmy4qppi7dis@meerkat.local/ Signed-off-by: Konstantin Ryabitsev <konstantin@linuxfoundation.org>
2021-10-20ty: fix bugs introduced when switching -s to -tKonstantin Ryabitsev
Test out and fix the bugs introduced by switching flags. Reported-by: Jens Axboe <axboe@kernel.dk> Signed-off-by: Konstantin Ryabitsev <konstantin@linuxfoundation.org>
2021-10-20shazam: change default behaviour to be "apply-here"Konstantin Ryabitsev
Based on the feedback, change the default behaviour of "b4 shazam" to apply patches to the current tree instead of doing FETCH_HEAD magic. This is still available when used with -H,--make-fetch-head flag. Signed-off-by: Konstantin Ryabitsev <konstantin@linuxfoundation.org>
2021-10-19Initial implementation of native mail sendingKonstantin Ryabitsev
I'm felling comfortable that "b4 ty" is sufficiently mature at this point to implement sending thank-yous directly. This is only the initial implementation that covers only the very basic parts of git's sendemail configuration options, but this should actually cover 90% of cases if not more. One important caveat -- I moved the "b4 ty -s" flag to be "b4 ty -t" in order to disambiguate it from the capital -S (that actually does the sending). Since "b4 ty" is still marked as an experimental feature, I feel we can do this without much impact. Signed-off-by: Konstantin Ryabitsev <konstantin@linuxfoundation.org>
2021-09-21Add "b4 shazam" that is like b4 am + git amKonstantin Ryabitsev
By popular demand, provide a way to apply series straight to a git repository. By default, we're still going the safest possible route: - create a sparse worktree consisting just of the files being modified - run "git am" against the temporary worktree - if "git am" went well, fetch from the temporary worktree into our current tree and leave everything in FETCH_HEAD - unless we're running "b4 shazam -A" in which case we just apply to the current HEAD (exact equivalent of b4 am -o- | git am) Further changes to come based on feedback. Signed-off-by: Konstantin Ryabitsev <konstantin@linuxfoundation.org>
2021-06-22Additional --guess-base refinementsKonstantin Ryabitsev
Use --all by default, instead of limiting ourselves just to the current HEAD. This is actually a faster operation, because we don't have to pre-filter results. Signed-off-by: Konstantin Ryabitsev <konstantin@linuxfoundation.org>
2021-06-21Reimplement --guess-baseKonstantin Ryabitsev
Based on some feedback, attempt to reimplement --guess-base by looking at the file index hashes and using --find-object to locate when they were last changed. We limit this using --since and --until, so that we aren't trying to look through the entire history of the repo. For the --until date, we take the date of the patch. For the --since date, we take the timedelta using the number of days specified by --guess-lookback (default is 14 days). Signed-off-by: Konstantin Ryabitsev <konstantin@linuxfoundation.org>
2021-06-08Tentative suport for sending exploded seriesKonstantin Ryabitsev
I've been working on a way to automatically convert pull requests into series, complete with mailing them out to arbitrary destinations. This would allow folks to send a pull request to a dedicated list and have it automatically converted into a well-formed series. This is a tentative implementation that relies on git-send-email to do most of the heavy lifting. I have misgivings about using git-send-email for this purpose, but it does reduce the amount of duplicated code we would have otherwise had to write, and allows us to hook into things like tocmd/cccmd, etc. For example, adding the following to your .git/config: [sendemail "autopr"] smtpserver = [your.server.here] smtpserverport = 587 smtpencryption = tls smtpuser = [your-user] smtppass = [your-pass] transferEncoding = 8bit suppressFrom = yes confirm = never validate = no tocmd = "$(git rev-parse --show-toplevel)/scripts/get_maintainer.pl --norolestats --nol" cccmd = "$(git rev-parse --show-toplevel)/scripts/get_maintainer.pl --norolestats --nom" This would allow doing the following: b4 pr -e -f "AutoPR Exploder <autopr@yourdomain.here>" -s autopr [--dry-run] The pull request will be exploded into a patch series and sent to all the proper destinations as returned by get_maintainer.pl. We construct the message headers in a way that allow regular code review and "b4 am" usage after the auto-exploded series is sent out. If testing goes well, we'll implement this as a kernel.org service and then hook a similar implementation via Gitlab/Github. Signed-off-by: Konstantin Ryabitsev <konstantin@linuxfoundation.org>
2021-05-21Move --show-keys into its own kr subcommandKonstantin Ryabitsev
There will be more keyring operations supported in the future, probably, but for now just move the --show-keys subcommand from "mbox" to "kr". Signed-off-by: Konstantin Ryabitsev <konstantin@linuxfoundation.org>
2021-05-18Don't use mboxo for anythingKonstantin Ryabitsev
While trying to figure out some odd DKIM failures, I've discovered that there is an important incompatibility between git's idea of what "mbox" format is, and Python's mboxo implementation -- at least when it comes to treating "\nFrom " escapes. According to the "original mbox" standard, when a message body contains a "\nFrom " sequence, it should be converted to "\n>From " in order not to confuse the parser. When reading messages in that format, clients are supposed to back-convert "\n>From " into their original form. This is the so-called "mboxo" format, which is what Python's mailbox.mbox supports: https://docs.python.org/3/library/mailbox.html#mailbox.mbox The "mboxrd" format was created to avoid a corruption problem whereas a body that legitimately contains "\n>From " would be wrongly converted into "\nFrom " upon parsing the mailbox, so mboxrd standard requires that, when saving a mailbox, "\n>From " sequences are additionally escaped as "\n>>From ". This is the format public-inbox supports, so when we grab mailboxes from remote, they are in mboxrd format. Git will try to guess the format of the mbox file, but it will ONLY back-convert "\n>From " sequences when you specifically tell it that it's "mboxrd" format, even when it's in fact "mboxo": git am --patch-format=mboxrd If you don't force the mboxrd format, git-am will preserve all escaped "\n>From " lines as-is. We've been previously operating on the assumption that git-am's mbox support properly implements "mboxo", but this was wrong, resulting in some commits like the following: https://git.kernel.org/torvalds/c/137733d08f4a This large-ish change ditches all internal use of Python's mboxo. When asked to save mbox files, we will save them without any escaping, the way git-am (i.e. git-mailsplit) espects them. The same goes when we're outputting to stdout. There is also a way now to pass -M to both "b4 am" and "b4 mbox" that will save things as maildirs -- git-am supports this natively and thus avoids any possible parsing ambiguities. You can set a config option b4.save-maildirs=yes to make this the default behaviour. The fallout of this is fairly benign, if annoying. There is no situation in which a patch would have "\nFrom " as part of its body, so the problem only affected commit messages. We will have a handful of these sprinkled around the trees, and will hopefully not introduce any new ones once everyone switches to the b4 version that outputs things in the format git-am expects. Signed-off-by: Konstantin Ryabitsev <konstantin@linuxfoundation.org>
2021-05-17Allow passing entire mbox via stdinKonstantin Ryabitsev
Per request, allow passing entire mbox files via stdin, allowing fully pipe-through operation from something like mutt: b4 am -sl -m - -o - Suggested-by: Peter Zijlstra <peterz@infradead.org> Signed-off-by: Konstantin Ryabitsev <konstantin@linuxfoundation.org> Link: https://lore.kernel.org/tools/YFETLu8TKWI2WlSF@hirez.programming.kicks-ass.net
2021-05-17Implement partial rerollKonstantin Ryabitsev
It has been a common request to support partial series rerolls where someone sends an amended patch as a follow-up to a previous series, e.g.: [PATCH v3 1/3] Patch one [PATCH v3 2/3] Patch two \- Re: [PATCH v3 2/3] Patch two Looks good, but please fix this $small_thing \- [PATCH v4 2/3] Patch two [PATCH v3] Patch three Previously, b4 refused to consider v4 as a complete new series, but now it will properly perform a partial reroll, but only in the cases where such patches are sent as follow-ups to the exact same patch number in the previous series: [PATCH v3->v4 1/3] Patch one [PATCH v4 2/3] Patch two [PATCH v3->v4 3/3] Patch three Reported-by: Dan Williams <dan.j.williams@intel.com> Signed-off-by: Konstantin Ryabitsev <konstantin@linuxfoundation.org> Link: https://lore.kernel.org/r/CAPcyv4ggbuHbqKV33_TpE7pqxvRag34baJrX3yQe-jXOikoATQ@mail.gmail.com
2021-05-11Rudimentary support for showing patatt key infoKonstantin Ryabitsev
I expect that we'll have better keyring management tooling in the future, but for now show some rudimentary information about patatt keys used in a thread via --show-keys, e.g.: b4 mbox --show-keys 20210511143536.743919-1-konstantin@linuxfoundation.org b4 mbox --show-keys 20210507181322.172569-1-konstantin@linuxfoundation.org Signed-off-by: Konstantin Ryabitsev <konstantin@linuxfoundation.org>
2021-05-11Reimplement attestation code one more timeKonstantin Ryabitsev
Move end-to-end attestation code into its own library: patatt. See https://git.kernel.org/pub/scm/utils/patatt/patatt.git/about/ It is included into b4 as a submodule, but you will need to init it first: git submodule update --init This change significantly simplifies our attestation code, dropping thousands of lines of rather hairy code. Notably, patatt-style attestation is incompatible with previous attestation implementations done directly in b4, but that's just as well -- we've always marked it as "experimental" and the lack of adoption was proving that we weren't on the right path. Next to come is keyring management and documentation. Signed-off-by: Konstantin Ryabitsev <konstantin@linuxfoundation.org>
2020-12-21Add -f to "b4 mbox" to filter dupesKonstantin Ryabitsev
When saving to a maildir, add option to filter out dupes. Note, that this requires going through the entire maildir to collect message-ids, so it's not going to be a great experience on large maildirs. Signed-off-by: Konstantin Ryabitsev <konstantin@linuxfoundation.org>
2020-12-14Fix crasher when we don't use -g with b4 prKonstantin Ryabitsev
If we're not passing -g to "b4 pr -e", then we should try to see if we are inside a git checkout and use that as our source. Signed-off-by: Konstantin Ryabitsev <konstantin@linuxfoundation.org>
2020-12-11Rework b4 pr exploder for transparency log needsKonstantin Ryabitsev
Two services we'll be running in the near future: 1. Transparency log for all pull requests 2. Auto-exploder for pull requests that can send auto-exploded patches to all the same recipients. This requires quite a bit more testing and refinement, but the core of the functionality is there. Signed-off-by: Konstantin Ryabitsev <konstantin@linuxfoundation.org>
2020-11-24Add --cc-trailers option to b4 amKonstantin Ryabitsev
By request, add ability to copy all addresses from the email's "Cc" header into Cc: trailers, unless they are already mentioned in some other trailer. Requested-by: Arnaldo Carvalho de Melo <acme@kernel.org> Signed-off-by: Konstantin Ryabitsev <konstantin@linuxfoundation.org>
2020-11-23Add mutt-filter modeKonstantin Ryabitsev
Only works for x-patch-sig style attestation, as doing DKIM attestation requires that we unignore all headers, which just junks up the view. Signed-off-by: Konstantin Ryabitsev <konstantin@linuxfoundation.org>
2020-11-17Remove standalone attverify commandKonstantin Ryabitsev
We're only doing this as part of b4 am now, so remove the obsolete attverify command. Signed-off-by: Konstantin Ryabitsev <konstantin@linuxfoundation.org>
2020-10-02Reimplement attestation for in-header hashesKonstantin Ryabitsev
Rewrite attestation to implement in-header hashing and signing. For now, just implementing mode=pgp, but other modes are coming next. Signed-off-by: Konstantin Ryabitsev <konstantin@linuxfoundation.org>
2020-05-28Add --no-cover and -o - to output to stdoutKonstantin Ryabitsev
By request, provide a way to output the results of b4 am to stdout. This way it can be piped straight to "git am". E.g.: b4 diff 20200526205322.23465-1-mic@digikod.net -o - | git am Requested-by: Rob Herring <robh@kernel.org> Signed-off-by: Konstantin Ryabitsev <konstantin@linuxfoundation.org>
2020-05-25Add -3 to "b4 am" to prep for a 3way mergeKonstantin Ryabitsev
The original code used for b4 diff was to prepare for a 3-way merge by making sure that all blob indexes exist in the local repo. Add this functionality to "b4 am" and document all the features added in the 0.5.0 branch. Signed-off-by: Konstantin Ryabitsev <konstantin@linuxfoundation.org>
2020-05-22Add ability to diff arbitrary mbox filesKonstantin Ryabitsev
Sometimes we are unable to properly look up previous series -- usually because the cover letter title changes. For those cases, it is now possible to diff two arbitrary mbox files prepared with "b4 am -T". There's also a smattering of other fixes in there because I'm too lazy to properly stage my patches. Signed-off-by: Konstantin Ryabitsev <konstantin@linuxfoundation.org>
2020-05-19Display range-diff by defaultKonstantin Ryabitsev
Don't make developers do copy-pasting unnecessarily. Switch to outputting the diff by default, with flag options to save to file or just show what needs to be done. Additionally, adds caching to lookups and remember previously generated fake-am ranges so we don't continuously generate loose objects on repeat runs. Signed-off-by: Konstantin Ryabitsev <konstantin@linuxfoundation.org>
2020-05-15Initial implementation of b4 diffKonstantin Ryabitsev
Based on feedback from Jason Gunthorpe, implement diffing of series by creating fake git-am commit ranges. Here's an easy example: b4 diff 20200511192156.1618284-1-mic@digikod.net Suggested-by: Jason Gunthorpe <jgg@ziepe.ca> Signed-off-by: Konstantin Ryabitsev <konstantin@linuxfoundation.org>
2020-05-15Expand use of --cherry-pick ("this", globbing)Konstantin Ryabitsev
In addition to numerical ranges, -P is now also able to do: - "-P _" to grab just the msgid used with "b4 am" - "-P *glob*" to filter by commit message subject Suggested-by: Rob Herring <robh@kernel.org> Signed-off-by: Konstantin Ryabitsev <konstantin@linuxfoundation.org>
2020-05-07Add -P,--cherry-pick option to "b4 am"Konstantin Ryabitsev
This lets someone select a subset of patches in a series, e.g.: b4 am -P 1-3,5,7- [msgid] Suggested-by: Heiko Stübner <heiko@sntech.de> Signed-off-by: Konstantin Ryabitsev <konstantin@linuxfoundation.org>
2020-05-07Switch ty -s and -d to allow friendly rangesKonstantin Ryabitsev
Instead of insisting that people put in specific numbers, allow them to specify ranges, such as: b4 ty -s 1-3,5,7- Signed-off-by: Konstantin Ryabitsev <konstantin@linuxfoundation.org>
2020-05-07Do not crash when thread is incompleteKonstantin Ryabitsev
Do not try to calculate indexes on a missing patch in an incomplete thread. Signed-off-by: Konstantin Ryabitsev <konstantin@linuxfoundation.org>
2020-04-24Prepare for 0.4.0 releaseKonstantin Ryabitsev
It's time to graduate to 0.4.0 with these features. Signed-off-by: Konstantin Ryabitsev <konstantin@linuxfoundation.org>
2020-04-15Changes to b4 ty based on developer feedbackKonstantin Ryabitsev
- Properly expand ~ and env vars like $HOME in template paths - Allow partial matching of series (with a warning) - Allow using remote branches with -b - Always fall back to subject matching for patches - Tweak to the summary output Suggested-by: Mark Brown <broonie@kernel.org> Signed-off-by: Konstantin Ryabitsev <konstantin@linuxfoundation.org>
2020-04-10Add summaries to default templatesKonstantin Ryabitsev
They are much more useful if b4.thanks-commit-url-mask is set, but even without them this will list all subjects and corresponding commit IDs. Signed-off-by: Konstantin Ryabitsev <konstantin@linuxfoundation.org>
2020-04-10Don't use git patch-id for patch trackingKonstantin Ryabitsev
Looks like some of the patches sent from quilt (at least from Andrew Morton) are not properly parsed by git patch-id, so use our own patch hashing routines, even if this means we're likely going to miss some of the patches that were edited by maintainers. Signed-off-by: Konstantin Ryabitsev <konstantin@linuxfoundation.org>
2020-04-09Add b4 ty that aims to simplify common feedbackKonstantin Ryabitsev
New experimental feature that aims to simplify a very common "thanks, applied" kind of feedback often expected of maintainers. Still needs documentation to explain its usage. Signed-off-by: Konstantin Ryabitsev <konstantin@linuxfoundation.org>
2020-03-30Add current rev to version when running from gitKonstantin Ryabitsev
For ease of tracking version information for folks running things straight out of the checkout, add current git revision to the version info string. Signed-off-by: Konstantin Ryabitsev <konstantin@linuxfoundation.org>
2020-03-26Add initial "b4 pr" command setKonstantin Ryabitsev
While working on "pull-request exploder" stuff for achiving on lore.kernel.org, I realized that this may be a useful set of features for developers as well, so here is a very simple framework for handing pull requests. Examples: b4 pr <msgid> - downloads that message - parses the pull request - checks that the remote tip is where the message says it should be - makes sure the base-commit is present in the tree - makes sure the tip commit isn't already in one of the branches - checks if FETCH_HEAD already is at that commit - if the above two checks pass, performs a git fetch b4 pr --check <msgid> Runs all of the checks above, but doesn't perform the actual fetch. Useful if you don't remember if you've already processed a pull request or not. b4 pr --explode <msgid> Runs basic sanity checks and then: - performs a git fetch - runs a "git format-patch" for base-commit..FETCH_HEAD - adds the same to/from/cc headers as in the pull request - properly threads each patch below the pull request - saves that into a <msgid>.mbox file The above is handy if you want to comment on something in a pull request and not have to hunt around for sender/cc information. Signed-off-by: Konstantin Ryabitsev <konstantin@linuxfoundation.org>
2020-03-24Warn when we are ignoring trailersKonstantin Ryabitsev
Provide a warning when we are ignoring trailers due to from/name mismatch between the headers and the body. Also provides a -S,--sloppy-trailers option to ignore all mismatches. Signed-off-by: Konstantin Ryabitsev <konstantin@linuxfoundation.org>
2020-03-23Use a better single-sourced version setupKonstantin Ryabitsev
Fun read: https://packaging.python.org/guides/single-sourcing-package-version/ Anyway, I hated this way the least. Signed-off-by: Konstantin Ryabitsev <konstantin@linuxfoundation.org>
2020-03-20Force nocache if we're running with -cKonstantin Ryabitsev
Checking for newer versions always requires going out to lore.kernel.org, so force nocache operation. Signed-off-by: Konstantin Ryabitsev <konstantin@linuxfoundation.org>
2020-03-20Add caching layerKonstantin Ryabitsev
Many lore.kernel.org operations can be repeated within quick succession of each-other (e.g. someone reruns a query with -t). This commit adds a caching layer that keeps lookups in local cache for 10 minutes (default). It can be made longer or shorter by editing the 'cache-expire' setting, or running "b4 am" with -C,--no-cache. Signed-off-by: Konstantin Ryabitsev <konstantin@linuxfoundation.org>
2020-03-16Quickfix for running without any commandsv0.3.2Konstantin Ryabitsev
Don't backtrace if there are no commands passed on cmdline. Reported-by: Jens Axboe <axboe@kernel.dk> Signed-off-by: Konstantin Ryabitsev <konstantin@linuxfoundation.org>
2020-03-15Tweak attestation parametersKonstantin Ryabitsev
Signed-off-by: Konstantin Ryabitsev <konstantin@linuxfoundation.org>
2020-03-14Initial commit after porting from korg-helpersKonstantin Ryabitsev
This is the beginning of a new tool that inherits from get-lore-mbox and attest-patches. Signed-off-by: Konstantin Ryabitsev <konstantin@linuxfoundation.org>