aboutsummaryrefslogtreecommitdiff
path: root/b4/__init__.py
AgeCommit message (Collapse)Author
2020-12-01Release 0.5.4 with the fix for b4 ty bugv0.5.4stable-0.5.yKonstantin Ryabitsev
The bug in b4 ty is bad enough to warrant a new release. Signed-off-by: Konstantin Ryabitsev <konstantin@linuxfoundation.org>
2020-12-01Fix headers generated by "b4 ty"Konstantin Ryabitsev
Make sure we always create a Date: header, and that we're not crashing when we try to parse a message without a Date: header. Signed-off-by: Konstantin Ryabitsev <konstantin@linuxfoundation.org>
2020-12-01Increment version to 0.5.4-devKonstantin Ryabitsev
Signed-off-by: Konstantin Ryabitsev <konstantin@linuxfoundation.org>
2020-11-25Increment version to 0.5.3 in prep for releasev0.5.3Konstantin Ryabitsev
Signed-off-by: Konstantin Ryabitsev <konstantin@linuxfoundation.org>
2020-11-24Unquote msgid if we're getting a full https URLKonstantin Ryabitsev
If we're processing a full https URL to the message, then unquote the message ID before we use it. Signed-off-by: Konstantin Ryabitsev <konstantin@linuxfoundation.org>
2020-11-17Fix crasher when attempting a 3-way prepKonstantin Ryabitsev
Don't attempt a len() on an object that may be None. This happens when there are patches prepared with a tool like quilt that don't include indexes. Reported-by: Mark Brown <broonie@kernel.org> Signed-off-by: Konstantin Ryabitsev <konstantin@linuxfoundation.org>
2020-11-03Fix handling of series with the [PATCHvX] defectMarc Zyngier
b4 tries to handle subject lines such as "[PATCHvX]" by replacing the subject line in situ, but seems to do a rather bad job of it, resulting in only the first patch of the series being picked up. Fetching <20201026134931.28246-1-mark.rutland@arm.com> does exhibit the problem. Fixing the re.sub() expression allows normal funtionalities to be restored, and the above series to be fetched. Fixes: 6bf644f14b3f ("Deal with [PATCHvX] subject") Signed-off-by: Marc Zyngier <maz@kernel.org> Signed-off-by: Konstantin Ryabitsev <konstantin@linuxfoundation.org>
2020-10-02Fix some cherry-picking corner casesKonstantin Ryabitsev
Handle several corner cases when trying to cherrypick from incomplete series. Reported-by: Krzysztof Kozlowski <krzk@kernel.org> Signed-off-by: Konstantin Ryabitsev <konstantin@linuxfoundation.org>
2020-08-18Require that a trailer is at least 2 chars longKonstantin Ryabitsev
I can't think of any trailers that are shorter than 2 characters, so tweak the regex to avoid one of the possible false positives. Reported-by: Jonathan Corbet <corbet@lwn.net> Signed-off-by: Konstantin Ryabitsev <konstantin@linuxfoundation.org>
2020-08-18Cover letters may not have a diffstatKonstantin Ryabitsev
Don't check if a potential cover letter has a diffstat when processing follow-up trailers. Reported-by: Greg Kroah-Hartman <greg@kroah.com> Signed-off-by: Konstantin Ryabitsev <konstantin@linuxfoundation.org>
2020-07-27Prepare for 0.5.2 releasev0.5.2Konstantin Ryabitsev
Signed-off-by: Konstantin Ryabitsev <konstantin@linuxfoundation.org>
2020-07-27Fix handling of single-paragraph commit message bodiesKyle Meyer
The get_body_parts() method added in ba6c790 (Parse body parts into usual chunks, 2020-04-27) strips lines that look like trailers from the last paragraph, storing the other lines to add back to the message. However, if the commit message has only a single paragraph, get_body_parts() returns early, unconditionally returning an empty string for the message even if non-trailer lines were encountered. Return the collected non-trailer lines, if any, as the message. Signed-off-by: Kyle Meyer <kyle@kyleam.com> Signed-off-by: Konstantin Ryabitsev <konstantin@linuxfoundation.org>
2020-07-27Fix basement detection for empty commit message bodiesKyle Meyer
The get_body_parts() method added in ba6c790 (Parse body parts into usual chunks, 2020-04-27) splits the commit message body on "\n---\n" and takes the second half as the "basement" of the patch. The body is stripped of flanking new lines, though, so a delimiter beginning with a new line isn't appropriate for commit messages without a message body. Make the starting new line optional. Note that this doesn't matter in the end in terms of the final applied patch. Before 31f33fd (Fix body part parsing when '---' is not used, 2020-06-08), the expected patch output was produced despite the diff lines being processed as the message body. After that commit, the information following the triple dash is a bit off, but it doesn't matter because git discards it anyway. Signed-off-by: Kyle Meyer <kyle@kyleam.com> Signed-off-by: Konstantin Ryabitsev <konstantin@linuxfoundation.org>
2020-07-07Fix attestation error messagesKonstantin Ryabitsev
Fix a crash when multiple patches fail attestation. Also fixes fancy chechmarks. Reported-by: Christian Brauner <christian.brauner@ubuntu.com> Signed-off-by: Konstantin Ryabitsev <konstantin@linuxfoundation.org>
2020-07-06Deal with [PATCHvX] subjectsKonstantin Ryabitsev
Normally, we'd expect to always have a space between PATCH and other prefixes, but be forgiving if it's not present. Reported-by: Mark Brown <broonie@kernel.org> Signed-off-by: Konstantin Ryabitsev <konstantin@linuxfoundation.org>
2020-06-12Fix crash with unbalanced [] in subjectKonstantin Ryabitsev
Don't crash if there is no matching ] in the subject. The culprit: https://lore.kernel.org/lkml/20200612142621.GA8009@lenoir Signed-off-by: Konstantin Ryabitsev <konstantin@linuxfoundation.org>
2020-06-10Fix regression with oddball charsetsKonstantin Ryabitsev
Fix the same bug we've fixed before in another place -- when charset is set to oddball value like charset=a, fallback to utf-8 and hope for the best. Signed-off-by: Konstantin Ryabitsev <konstantin@linuxfoundation.org>
2020-06-08Up the version to 0.5.2-devKonstantin Ryabitsev
Ready for more bugfixes. Signed-off-by: Konstantin Ryabitsev <konstantin@linuxfoundation.org>
2020-06-08Prepare for 0.5.1 releasev0.5.1Konstantin Ryabitsev
Signed-off-by: Konstantin Ryabitsev <konstantin@linuxfoundation.org>
2020-06-08Output less confusing trailer mismatch messagesKonstantin Ryabitsev
Show the actual trailer name we're complaining about. Signed-off-by: Konstantin Ryabitsev <konstantin@linuxfoundation.org>
2020-06-08Fix bug with threading when cover ref is missingKonstantin Ryabitsev
When the cover letter is missing and we're starting in the middle of the thread, do not discard messages in the mbox that come before the msgid that we want. Reported-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Konstantin Ryabitsev <konstantin@linuxfoundation.org>
2020-06-08Fix body part parsing when '---' is not usedKonstantin Ryabitsev
If the commit message is not separated from the diff using '---' as is commonly the case, fall back to splitting by the word "diff". Reported-by: Mark Brown <broonie@kernel.org> Signed-off-by: Konstantin Ryabitsev <konstantin@linuxfoundation.org>
2020-06-08Use proper charset when reading back mailinfoKonstantin Ryabitsev
Git mailinfo output is going to be in the same character set as specified in the message headers, so we should not assume that we can read it back in unicode. 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-26Use unicode escape sequencesKonstantin Ryabitsev
Let's keep our code sources in plain old ascii. Signed-off-by: Konstantin Ryabitsev <konstantin@linuxfoundation.org>
2020-05-26Up the version to 0.5.1-devKonstantin Ryabitsev
Signed-off-by: Konstantin Ryabitsev <konstantin@linuxfoundation.org>
2020-05-25Prepare for 0.5.0v0.5.0Konstantin Ryabitsev
I think it's time to have more people poking at the diff functionality. Signed-off-by: Konstantin Ryabitsev <konstantin@linuxfoundation.org>
2020-05-25Backfill series before diffing themKonstantin Ryabitsev
Make sure we a) attempt to backfill the series if they are incomplete, b) error out if the series is incomplete anyway 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-13Don't fail when a message uses a weird charsetKonstantin Ryabitsev
Found via auto-testing in: https://lore.kernel.org/linux-sgx/20200421215316.56503-13-jarkko.sakkinen@linux.intel.com/raw This is wrong on many levels: Content-Type: text/plain; charset=a Assume utf-8 when something like this happens and don't fail. Signed-off-by: Konstantin Ryabitsev <konstantin@linuxfoundation.org>
2020-05-13Fix crasher for incomplete threadsKonstantin Ryabitsev
Don't crash if the message in the References: is not available in the thread. Reported-by: Bjorn Helgaas <helgaas@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-05-07Remove QP encoding when getting fromnameKonstantin Ryabitsev
Make sure we get the clean header value when we store fromname. Link: https://linux.kernel.org/g/tools/message/142 Reported-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com> Signed-off-by: Konstantin Ryabitsev <konstantin@linuxfoundation.org>
2020-05-01Check if mbox applies to current treeKonstantin Ryabitsev
Check if all patches in the mbox would apply cleanly to the current tree: - find index hash..hash information in each patch - check if git-hash-object shows exact same hashes for the current tree - if not, try the last 10 tags to see if any of them would be a good base-commit for the patch/series Not sure how useful the latter part it, but it hopefully shouldn't slow down regular operations, so I'm going to leave it in for now. Signed-off-by: Konstantin Ryabitsev <konstantin@linuxfoundation.org>
2020-04-27Parse body parts into usual chunksKonstantin Ryabitsev
Do a better job parsing a patch message into usual body parts: - git headers (From:, Subject:, Date:) - commit message - trailers - basement (under the ---\n) - signature (under the --\s\n) This allows us to create better reply quotes. Reported-by: Martin K. Petersen <martin.petersen@oracle.com> Signed-off-by: Konstantin Ryabitsev <konstantin@linuxfoundation.org>
2020-04-24Set version to 0.5.0-devKonstantin Ryabitsev
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-20Use the cover for backfills when availableKonstantin Ryabitsev
When we have a cover letter, use that for backfill purposes, instead of finding the first non-None patch. Signed-off-by: Konstantin Ryabitsev <konstantin@linuxfoundation.org>
2020-04-20Support file delete patches and binary patchesKonstantin Ryabitsev
Git's file delete patches don't contain hunks, so we weren't properly processing them for attestation (and for b4 am). While fixing that, I also added attestation support for binary patches. Reported-by: Geert Uytterhoeven <geert@linux-m68k.org> Signed-off-by: Konstantin Ryabitsev <konstantin@linuxfoundation.org>
2020-04-15Properly deal with diffs that delete all linesKonstantin Ryabitsev
We weren't properly handling special diffs that deleted entire file contents (e.g. by deleting a file). Reported-by: Mark Brown <broonie@kernel.org> Signed-off-by: Konstantin Ryabitsev <konstantin@linuxfoundation.org>
2020-04-15Don't break on @@ -N,N +N @@ diff linesKonstantin Ryabitsev
When a commit is a new file with only one line, the diff output is different, so handle it without breaking. Reported-by: Mark Brown <broonie@kernel.org> Signed-off-by: Konstantin Ryabitsev <konstantin@linuxfoundation.org>
2020-04-15Get info from gecos if we don't have user.nameKonstantin Ryabitsev
Git gets user.name from gecos if it's not specified in user.name, so let's do the same thing. Signed-off-by: Konstantin Ryabitsev <konstantin@linuxfoundation.org>
2020-04-15Switch to using patchwork-compatible hashesKonstantin Ryabitsev
Using strict attestation hashes for auto-thankinator is problematic, because "git am" uses a certain degree of fuzzing, so when we try to find applied patches by running "git diff" on actual commits, line counts may not be bit-for-bit identical. Signed-off-by: Konstantin Ryabitsev <konstantin@linuxfoundation.org>
2020-04-10Use ~/.signature if it exists for tpt defaultsKonstantin Ryabitsev
If we find a ~/.signature, then use it for making a default ${signature} value, otherwise make a "Name <email>" boring one. 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>