aboutsummaryrefslogtreecommitdiff
path: root/tools/patman/gitutil.py
AgeCommit message (Collapse)AuthorFilesLines
2022-02-09patman: Rename Color() method to build()Simon Glass1-3/+3
This method has the same name as its class which is confusing. It is also annoying when searching the code. It builds a string with a colour, so rename it to build(). Signed-off-by: Simon Glass <sjg@chromium.org>
2022-02-09patman: Convert camel case in gitutil.pySimon Glass1-62/+62
Convert this file to snake case and update all files which use it. Signed-off-by: Simon Glass <sjg@chromium.org>
2022-02-09patman: Convert camel case in command.pySimon Glass1-23/+23
Convert this file to snake case and update all files which use it. Signed-off-by: Simon Glass <sjg@chromium.org>
2022-01-13patman: Support absolute and ~user-relative alias filesBrian Norris1-3/+8
Python doesn't naturally support tilde (~) as a user-home marker in paths, but git-config does. So we need to resolve it before continuing. We also shouldn't blindly join the top-level tree with the aliasesfile path, because it might be an absolute path. This resolves warnings like the following: Warning: Cannot find alias file '/path/to/source/tree/~/.git-email' Seen when git-config is like: $ git config sendemail.aliasesfile ~/.git-email Signed-off-by: Brian Norris <briannorris@chromium.org> Reviewed-by: Simon Glass <sjg@chromium.org> Reviewed-by: Otavio Salvador <otavio@ossystems.com.br>
2021-03-22patman: Quieten down the alias checkingSimon Glass1-25/+20
When a tag is used in a patch subject (e.g. "tag: rest of message") and it cannot be found as an alias, patman currently reports a fatal error, unless -t is provided, in which case it reports a warning. Experience suggest that the fatal error is not very useful. Instead, default to reporting a warning, with -t tell patman to ignore it altogether. Signed-off-by: Simon Glass <sjg@chromium.org>
2020-12-22patman: Add --no-signoff to suppress adding signoffsPhilipp Tomsich1-2/+4
To enable use of patman with FSF/GNU projects, such as GCC or Binutils, no Signed-off-by may be added. This adds a command line flag '--no-signoff' to suppress adding signoffs in patman when processing commits. Signed-off-by: Philipp Tomsich <philipp.tomsich@vrull.eu> Reviewed-by: Simon Glass <sjg@chromium.org> Fix patman testBranch() test: Signed-off-by: Simon Glass <sjg@chromium.org>
2020-12-13patman: Drop unicode helper functionsSimon Glass1-2/+1
We don't need these now that everything uses Python 3. Remove them and the extra code in GetBytes() and ToBytes() too. Signed-off-by: Simon Glass <sjg@chromium.org>
2020-11-14patman: Refactor how the default subcommand worksSimon Glass1-5/+5
At present patman tries to assume a default subcommand of 'send', to maintain backwards compatibility. However it does not cope with arguments added to the default command, so for example 'patman -t' does not work. Update the logic to handle this. Also update the CC command to use 'send' explicitly, since otherwise patman gets confused with the patch-filename argument. Signed-off-by: Simon Glass <sjg@chromium.org>
2020-11-05patman: Detect missing upstream in CountCommitsToBranchSimon Glass1-3/+7
At present if we fail to find the upstream then the error output is piped to wc, resulting in bogus results. Avoid the pipe and check the output directly. Signed-off-by: Simon Glass <sjg@chromium.org>
2020-09-22buildman: Use git worktrees instead of git clones when possibleAlper Nebi Yasak1-0/+42
This patch makes buildman create linked working trees instead of clones of the source repository, but keeps updating the older clones of the repository that might already exist. These worktrees share "everything except working directory specific files such as HEAD, index, etc." with the source repository. See the git-worktree(1) manual page for more information. If git-worktree isn't available, silently falls back to cloning the repository. Signed-off-by: Alper Nebi Yasak <alpernebiyasak@gmail.com> Reviewed-by: Simon Glass <sjg@chromium.org> Tested-by: Simon Glass <sjg@chromium.org>
2020-07-25patman: Make sure sendemail.suppresscc is (un)set correctlyNicolas Boichat1-0/+25
Setting sendemail.suppresscc to all or cccmd leads to --cc-cmd parameter being ignored, and emails going either nowhere, or just to the To: line maintainer. Signed-off-by: Nicolas Boichat <drinkcat@chromium.org> Reviewed-by: Simon Glass <sjg@chromium.org>
2020-07-24patman: Allow creating patches for another branchSimon Glass1-5/+14
Add a -b option to allow patches to be created from a branch other than the current one. Signed-off-by: Simon Glass <sjg@chromium.org>
2020-07-24patman: Move main code out to a control moduleSimon Glass1-1/+3
To make testing easier, move the code out from main into a separate 'control' module and split it into four parts: setup, preparing patches, checking patches and emailing patches. Add comments and fix a few code-style issues while we are here. Signed-off-by: Simon Glass <sjg@chromium.org>
2020-07-24Revert "Merge tag 'dm-pull-20jul20' of git://git.denx.de/u-boot-dm"Tom Rini1-42/+6
This reverts commit 5d3a21df6694ebd66d5c34c9d62a26edc7456fc7, reversing changes made to 56d37f1c564107e27d873181d838571b7d7860e7. Unfortunately this is causing CI failures: https://travis-ci.org/github/trini/u-boot/jobs/711313649 Signed-off-by: Tom Rini <trini@konsulko.com>
2020-07-20patman: Make sure sendemail.suppresscc is (un)set correctlyNicolas Boichat1-0/+25
Setting sendemail.suppresscc to all or cccmd leads to --cc-cmd parameter being ignored, and emails going either nowhere, or just to the To: line maintainer. Signed-off-by: Nicolas Boichat <drinkcat@chromium.org> Reviewed-by: Simon Glass <sjg@chromium.org>
2020-07-20patman: Allow creating patches for another branchSimon Glass1-5/+14
Add a -b option to allow patches to be created from a branch other than the current one. Signed-off-by: Simon Glass <sjg@chromium.org>
2020-07-20patman: Move main code out to a control moduleSimon Glass1-1/+3
To make testing easier, move the code out from main into a separate 'control' module and split it into four parts: setup, preparing patches, checking patches and emailing patches. Add comments and fix a few code-style issues while we are here. Signed-off-by: Simon Glass <sjg@chromium.org>
2020-07-09patman: Use a dict in gitutil to avoid importing seriesSimon Glass1-5/+4
Only a few members of this class are used and only in a test. To avoid importing the module, convert the test to use a dict. Signed-off-by: Simon Glass <sjg@chromium.org> Reported-by: Stefan Bosch <stefan_b@posteo.net>
2020-07-09patman: Drop unnecessary import in gitutilSimon Glass1-1/+0
The checkpatch module is not used, so drop it. Signed-off-by: Simon Glass <sjg@chromium.org> Reported-by: Stefan Bosch <stefan_b@posteo.net>
2020-05-29patman: Add an option to create patches without binary contentsBin Meng1-1/+3
Some mailing lists have size limits and when we add binary contents to our patches it's easy to exceed the size limits. Git supports a command line option "--no-binary" to generate patches without any binary contents. Add an option in patman to handle this. Note with this option patches cannot be applied properly, but they are still useful for code review. Signed-off-by: Bin Meng <bmeng.cn@gmail.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2020-04-26patman: Move to absolute importsSimon Glass1-6/+6
At present patman sets the python path on startup so that it can access the libraries it needs. If we convert to use absolute imports this is not necessary. Move patman to use absolute imports. This requires changes in tools which use the patman libraries (which is most of them). Signed-off-by: Simon Glass <sjg@chromium.org>
2019-11-14patman: fix some typos in commentsAnatolij Gustschin1-2/+2
s/Subprocress/Subprocess/ s/easiler/easier/ s/repositiory/repository/ s/rangem/range/ s/Retruns/Returns/ Signed-off-by: Anatolij Gustschin <agust@denx.de> Reviewed-by: Simon Glass <sjg@chromium.org>
2019-07-10patman: Tidy up a few more unicode conversionsSimon Glass1-3/+1
Use the new functions in the tools module to handle conversion. Signed-off-by: Simon Glass <sjg@chromium.org>
2019-07-10patman: Move unicode helpers to toolsSimon Glass1-2/+2
Create helper functions in the tools module to deal with the differences between unicode in Python 2 (where we use the 'unicode' type) and Python 3 (where we use the 'str' type). Signed-off-by: Simon Glass <sjg@chromium.org>
2019-07-10patman: Convert print statements to Python 3Simon Glass1-5/+5
Update all print statements to be functions, as required by Python 3. Signed-off-by: Simon Glass <sjg@chromium.org>
2019-07-10patman: Update cros_subprocess to use bytesSimon Glass1-0/+2
At present this function uses lists and strings. This does not work so well with Python 3, and testing against '' does not work for a bytearray. Update the code to fix these issues. Signed-off-by: Simon Glass <sjg@chromium.org>
2018-06-23patman: Support using a particular SMTP serverSimon Glass1-1/+5
Some environments require providing the '--smtp-server' argument to 'git send-email'. Add support for this. Signed-off-by: Simon Glass <sjg@chromium.org>
2018-05-07SPDX: Convert all of our single license tags to Linux Kernel styleTom Rini1-2/+1
When U-Boot started using SPDX tags we were among the early adopters and there weren't a lot of other examples to borrow from. So we picked the area of the file that usually had a full license text and replaced it with an appropriate SPDX-License-Identifier: entry. Since then, the Linux Kernel has adopted SPDX tags and they place it as the very first line in a file (except where shebangs are used, then it's second line) and with slightly different comment styles than us. In part due to community overlap, in part due to better tag visibility and in part for other minor reasons, switch over to that style. This commit changes all instances where we have a single declared license in the tag as both the before and after are identical in tag contents. There's also a few places where I found we did not have a tag and have introduced one. Signed-off-by: Tom Rini <trini@konsulko.com>
2017-06-08patman: Rename 'str' variable in EmailPatches()Simon Glass1-3/+3
This is not a good variable name in Python because 'str' is a type. It shows up highlighted in some editors. Rename it. Signed-off-by: Simon Glass <sjg@chromium.org> Tested-by: Philipp Tomsich <philipp.tomsich@theobroma-systems.com>
2017-06-08patman: Adjust handling of unicode email addressSimon Glass1-0/+2
Don't mess with the email address when outputting them. Just make sure they are encoded with utf-8. Signed-off-by: Simon Glass <sjg@chromium.org> Tested-by: Philipp Tomsich <philipp.tomsich@theobroma-systems.com>
2016-10-09patman: Make exception handling python 3.x safePaul Burton1-6/+6
Syntax for exception handling is a little more strict in python 3.x. Convert all uses to a form accepted by both python 2.x & python 3.x. Signed-off-by: Paul Burton <paul.burton@imgtec.com> Acked-by: Simon Glass <sjg@chromium.org>
2016-10-09patman: Make print statements python 3.x safePaul Burton1-3/+3
In python 3.x, print must be used as a function call. Convert all print statements to the function call style, importing from __future__ where we print with no trailing newline or print to a file object. Signed-off-by: Paul Burton <paul.burton@imgtec.com> Acked-by: Simon Glass <sjg@chromium.org>
2016-09-18patman: Adjust command.Output() to raise an error by defaultSimon Glass1-1/+2
It is more useful to have this method raise an error when something goes wrong. Make this the default and adjust the few callers that don't want to use it this way. Signed-off-by: Simon Glass <sjg@chromium.org>
2016-03-17buildman: Allow branch names which conflict with directoriesSimon Glass1-0/+5
At present if you try to use buildman with the branch 'test' it will complain that it is unsure whether you mean the branch or the directory. This is a feature of the 'git log' command that buildman uses. Fix it by resolving the ambiguity. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Joe Hershberger <joe.hershberger@ni.com>
2016-01-20patman: Add --thread optionMateusz Kulikowski1-1/+5
Add option to create threaded series of patches. With it, it will be possible to create patch threads like this: [PATCH 0/10] Add support for time travel [PATCH 1/10] Add Flux Capacitor driver [PATCH 2/10] Add Mr. Fusion driver (...) Internally it will call git send-email with --thread option Signed-off-by: Mateusz Kulikowski <mateusz.kulikowski@gmail.com> Acked-by: Simon Glass <sjg@chromium.org>
2015-09-09Revert "patman: use -D option for git format-patch"Masahiro Yamada1-1/+1
This reverts commit 19b4a3369876f9215e2b861f211e8df1a75e26ca. Since that commit, patman generates useless patches for file removal; "git format -D" prints only the header but not the diff when deleting files, and "git am" always refuses such patches. The following is the quotation from "man git-format-patch": -D, --irreversible-delete Omit the preimage for deletes, i.e. print only the header but not the diff between the preimage and /dev/null. The resulting patch is not meant to be applied with patch nor git apply; this is solely for people who want to just concentrate on reviewing the text after the change. In addition, the output obviously lack enough information to apply such a patch in reverse, even manually, hence the name of the option. Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com> Acked-by: Simon Glass <sjg@chromium.org>
2015-08-26patman: use -D option for git format-patchMasahiro Yamada1-1/+1
This allows Patman to generate smaller patches for file removal. Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com> Acked-by: Simon Glass <sjg@chromium.org> Acked-by: Heiko Schocher <hs@denx.de>
2015-04-23patman: check git format.subjectprefix setting when generate patches prefixWu, Josh1-0/+11
For the local project, we may specified format.subjectprefix setting. Then the patch will be formated as [Project_prefix][PATCH]. But patman will not check this setting. It will remove the format.subjectprefix. So This patch will let patman check this setting and add it as a project prefix. Signed-off-by: Josh Wu <josh.wu@atmel.com> Acked-by: Simon Glass <sjg@chromium.org> Tested-by: Simon Glass <sjg@chromium.org>
2015-02-15buildman: Fix incorrect arguemnt in GetUpstream()Simon Glass1-1/+1
This causes an error when trying to build a local branch which has a local branch as its upstream. Signed-off-by: Simon Glass <sjg@chromium.org> Reported-by: Masahiro Yamada <yamada.m@jp.panasonic.com>
2015-01-30patman: Make dry-run output match real functionalityPeter Tyser1-1/+2
When run with the --dry-run argument patman prints out information showing what it would do. This information currently doesn't line up with what patman/git send-email really do. Some basic examples: - If an email address is addressed via "Series-cc" and "Patch-cc" patman shows that email address would be CC-ed two times. - If an email address is addressed via "Series-to" and "Patch-cc" patman shows that email address would be sent TO and CC-ed. - If an email address is addressed from a combination of tag aliases, get_maintainer.pl output, "Series-cc", "Patch-cc", etc patman shows that the email address would be CC-ed multiple times. Patman currently does try to send duplicate emails like the --dry-run output shows, but "git send-email" intelligently removes duplicate addresses so this patch shouldn't change the non-dry-run functionality. Change patman's output and email addressing to line up with the "git send-email" logic. This trims down patman's dry-run output and prevents confusion about what patman will do when emails are actually sent. Signed-off-by: Peter Tyser <ptyser@xes-inc.com> Acked-by: Simon Glass <sjg@chromium.org> Tested-by: Simon Glass <sjg@chromium.org>
2015-01-14buildman: Allow specifying a range of commits to buildSimon Glass1-5/+19
Adjust the -b flag to permit a range expression as well as a branch. Signed-off-by: Simon Glass <sjg@chromium.org> Suggested-by: Daniel Schwierzeck <daniel.schwierzeck@gmail.com> Tested-by: Daniel Schwierzeck <daniel.schwierzeck@gmail.com>
2015-01-14buildman: Try to guess the upstream commitSimon Glass1-9/+59
Buildman normally obtains the upstream commit by asking git. Provided that the branch was created with 'git checkout -b <branch> <some_upstream>' then this normally works. When there is no upstream, we can try to guess one, by looking up through the commits until we find a branch. Add a function to try this and print a warning if buildman ends up relying on it. Also update the documentation to match. Signed-off-by: Simon Glass <sjg@chromium.org> Suggested-by: Wolfgang Denk <wd@denx.de>
2014-09-09patman: RunPipe() should not pipe stdout/stderr unless askedSimon Glass1-3/+5
RunPipe() currently pipes the output of stdout and stderr to a pty, but this is not the intended behaviour. Fix it. Signed-off-by: Simon Glass <sjg@chromium.org>
2014-09-05patman: Fix detection of git versionSimon Glass1-0/+2
A missing 'global' declaration means that this feature does not currently work. Fix it. Signed-off-by: Simon Glass <sjg@chromium.org>
2014-09-05patman: Use --no-pager' to stop git from forking a pagerSimon Glass1-1/+1
In a headless environment the pager can apparently hang. We don't want a pager anyway so let's request that none be used. Reported-by: Tom Rini <trini@ti.com> Signed-off-by: Simon Glass <sjg@chromium.org>
2014-09-05patman: Remove the -a optionSimon Glass1-88/+0
It seems that this is no longer needed, since checkpatch.pl will catch whitespace problems in patches. Also the option is not widely used, so it seems safe to just remove it. Suggested-by: Masahiro Yamada <yamada.m@jp.panasonic.com> Signed-off-by: Simon Glass <sjg@chromium.org>
2014-09-05patman: Correct unit tests to run correctlySimon Glass1-4/+4
It seems that doctest behaves differently now, and some of the unit tests do not run. Adjust the tests to work correctly. ./tools/patman/patman --test <unittest.result.TestResult run=10 errors=0 failures=0> Signed-off-by: Simon Glass <sjg@chromium.org>
2014-08-28patman: Support the 'reverse' option for 'git log'Simon Glass1-0/+2
This option is currently not supported, but needs to be, for buildman to operate as expected. Reported-by: York Sun <yorksun@freescale.com> Signed-off-by: Simon Glass <sjg@chromium.org>
2014-08-13patman: Only use git's --no-decorate when availableSimon Glass1-1/+8
Older versions of git (e.g. Ubuntu 10.04) do not support this flag. By default they do not decorate. So only enable this flag when supported. Suggested-by: Tom Rini <trini@ti.com> Signed-off-by: Simon Glass <sjg@chromium.org>
2014-08-13patman: Move the 'git log' command into a functionSimon Glass1-5/+28
Move the code that builds a 'git log' command into a function so we can more easily adjust it. Signed-off-by: Simon Glass <sjg@chromium.org>