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:52:32 +0000 |
commit | 909486e124c2aa78be98ee20dd837c7bfc17aebe (patch) | |
tree | 5c1c86a07b330b6e2a6aed111bd92f2c5131209d /meta | |
parent | 56236e74f0fe275c1e3e7b59f44ca55cba1d4e3b (diff) | |
download | poky-909486e124c2aa78be98ee20dd837c7bfc17aebe.tar.gz |
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.
(From OE-Core rev: 3a14b0943731822905e6d45b13d08a6e8237e2fe)
Signed-off-by: Laszlo Papp <lpapp@kde.org>
Signed-off-by: Saul Wold <sgw@linux.intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta')
-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): | |||
203 | PatchTree.__init__(self, dir, d) | 203 | PatchTree.__init__(self, dir, d) |
204 | 204 | ||
205 | def _applypatch(self, patch, force = False, reverse = False, run = True): | 205 | def _applypatch(self, patch, force = False, reverse = False, run = True): |
206 | shellcmd = ["git", "--git-dir=.", "apply", "-p%s" % patch['strippath']] | 206 | def _applypatchhelper(shellcmd, patch, force = False, reverse = False, run = True): |
207 | if reverse: | ||
208 | shellcmd.append('-R') | ||
207 | 209 | ||
208 | if reverse: | 210 | shellcmd.append(patch['file']) |
209 | shellcmd.append('-R') | ||
210 | 211 | ||
211 | shellcmd.append(patch['file']) | 212 | if not run: |
213 | return "sh" + "-c" + " ".join(shellcmd) | ||
212 | 214 | ||
213 | if not run: | 215 | return runcmd(["sh", "-c", " ".join(shellcmd)], self.dir) |
214 | return "sh" + "-c" + " ".join(shellcmd) | ||
215 | 216 | ||
216 | return runcmd(["sh", "-c", " ".join(shellcmd)], self.dir) | 217 | try: |
218 | shellcmd = ["git", "--work-tree=.", "am", "-3", "-p%s" % patch['strippath']] | ||
219 | return _applypatchhelper(shellcmd, patch, force, reverse, run) | ||
220 | except CmdError: | ||
221 | shellcmd = ["git", "--git-dir=.", "apply", "-p%s" % patch['strippath']] | ||
222 | return _applypatchhelper(shellcmd, patch, force, reverse, run) | ||
217 | 223 | ||
218 | 224 | ||
219 | class QuiltTree(PatchSet): | 225 | class QuiltTree(PatchSet): |