[oe-commits] Dale Farnsworth : patch.bbclass: Add "git" patchtool mechanism, which uses git-apply

git version control git at git.openembedded.org
Mon Aug 24 21:16:22 UTC 2009


Module: openembedded.git
Branch: org.openembedded.dev
Commit: 97cd9822750689a733b07b01b21acf93f3877e33
URL:    http://gitweb.openembedded.net/?p=openembedded.git&a=commit;h=97cd9822750689a733b07b01b21acf93f3877e33

Author: Dale Farnsworth <dfarnsworth at mvista.com>
Date:   Wed Jul  8 13:47:18 2009 -0700

patch.bbclass: Add "git" patchtool mechanism, which uses git-apply

It can be selected by setting PATCHTOOL = "git".

This is useful because git-apply honors the permissions information
produced by git-format-patch.

Signed-off-by: Dale Farnsworth <dfarnsworth at mvista.com>
Signed-off-by: Chris Larson <clarson at mvista.com>
Acked-by: Denys Dmytriyenko <denis at denix.org>

---

 classes/patch.bbclass |   20 ++++++++++++++++++++
 1 files changed, 20 insertions(+), 0 deletions(-)

diff --git a/classes/patch.bbclass b/classes/patch.bbclass
index 2f99e4c..dfb8ec9 100644
--- a/classes/patch.bbclass
+++ b/classes/patch.bbclass
@@ -189,6 +189,24 @@ def patch_init(d):
 		def Clean(self):
 			""""""
 
+	class GitApplyTree(PatchTree):
+		def __init__(self, dir, d):
+			PatchTree.__init__(self, dir, d)
+
+		def _applypatch(self, patch, force = False, reverse = False, run = True):
+			shellcmd = ["git", "--git-dir=.", "apply", "-p%s" % patch['strippath']]
+
+			if reverse:
+				shellcmd.append('-R')
+
+			shellcmd.append(patch['file'])
+
+			if not run:
+				return "sh" + "-c" + " ".join(shellcmd)
+
+			return runcmd(["sh", "-c", " ".join(shellcmd)], self.dir)
+
+
 	class QuiltTree(PatchSet):
 		def _runcmd(self, args, run = True):
 			quiltrc = bb.data.getVar('QUILTRCFILE', self.d, 1)
@@ -424,6 +442,7 @@ def patch_init(d):
 	g["PatchSet"] = PatchSet
 	g["PatchTree"] = PatchTree
 	g["QuiltTree"] = QuiltTree
+	g["GitApplyTree"] = GitApplyTree
 	g["Resolver"] = Resolver
 	g["UserResolver"] = UserResolver
 	g["NOOPResolver"] = NOOPResolver
@@ -449,6 +468,7 @@ python patch_do_patch() {
 	patchsetmap = {
 		"patch": PatchTree,
 		"quilt": QuiltTree,
+		"git": GitApplyTree,
 	}
 
 	cls = patchsetmap[bb.data.getVar('PATCHTOOL', d, 1) or 'quilt']





More information about the Openembedded-commits mailing list