diff options
author | Laszlo Papp <lpapp@kde.org> | 2013-12-24 12:44:10 +0000 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2014-01-28 00:48:25 +0000 |
commit | 3a14b0943731822905e6d45b13d08a6e8237e2fe (patch) | |
tree | ecd88a09e67f35a91d822200f61774423ac34d50 /meta/lib/oe | |
parent | 0cd58eb1ca29bdc53f623aba1f761b97cfe31fb4 (diff) | |
download | openembedded-core-3a14b0943731822905e6d45b13d08a6e8237e2fe.tar.gz openembedded-core-3a14b0943731822905e6d45b13d08a6e8237e2fe.tar.bz2 openembedded-core-3a14b0943731822905e6d45b13d08a6e8237e2fe.zip |
lib/oe/patch.py: Prefer "git am" over "git apply" when applying git patches
It is better to use "git am" when possible to preserve the commit messages and
the mail format in general for patches when those are present. A typical use
case is when developers would like to keep the changes on top of the latest
upstream, and they may occasionally need to rebase. This is not possible with
"git diff" and "diff" generated patches.
Since this is not always the case, the fallback would be the "git apply"
operation which is currently available.
Signed-off-by: Laszlo Papp <lpapp@kde.org>
Signed-off-by: Saul Wold <sgw@linux.intel.com>
Diffstat (limited to 'meta/lib/oe')
-rw-r--r-- | meta/lib/oe/patch.py | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/meta/lib/oe/patch.py b/meta/lib/oe/patch.py index 59abd0af19..b085c9d6b5 100644 --- a/meta/lib/oe/patch.py +++ b/meta/lib/oe/patch.py @@ -203,17 +203,23 @@ class GitApplyTree(PatchTree): PatchTree.__init__(self, dir, d) def _applypatch(self, patch, force = False, reverse = False, run = True): - shellcmd = ["git", "--git-dir=.", "apply", "-p%s" % patch['strippath']] + def _applypatchhelper(shellcmd, patch, force = False, reverse = False, run = True): + if reverse: + shellcmd.append('-R') - if reverse: - shellcmd.append('-R') + shellcmd.append(patch['file']) - shellcmd.append(patch['file']) + if not run: + return "sh" + "-c" + " ".join(shellcmd) - if not run: - return "sh" + "-c" + " ".join(shellcmd) + return runcmd(["sh", "-c", " ".join(shellcmd)], self.dir) - return runcmd(["sh", "-c", " ".join(shellcmd)], self.dir) + try: + shellcmd = ["git", "--work-tree=.", "am", "-3", "-p%s" % patch['strippath']] + return _applypatchhelper(shellcmd, patch, force, reverse, run) + except CmdError: + shellcmd = ["git", "--git-dir=.", "apply", "-p%s" % patch['strippath']] + return _applypatchhelper(shellcmd, patch, force, reverse, run) class QuiltTree(PatchSet): |