@@ -56,6 +56,10 @@ def runcmd(args, dir = None):
if dir:
os.chdir(olddir)
+def getstatusoutput(cmd):
+ import subprocess
+ return subprocess.getstatusoutput(cmd.split())
+
class PatchError(Exception):
def __init__(self, msg):
self.msg = msg
@@ -298,6 +302,19 @@ class GitApplyTree(PatchTree):
PatchTree.__init__(self, dir, d)
self.commituser = d.getVar('PATCH_GIT_USER_NAME')
self.commitemail = d.getVar('PATCH_GIT_USER_EMAIL')
+ if not self._isInitialized():
+ self._initRepo()
+
+ def _isInitialized(self):
+ cmd = "git rev-parse --show-toplevel"
+ (status, output) = getstatusoutput(cmd)
+ ## Make sure we're in builddir to not break top-level git repos
+ return status == 0 and os.path.samedir(output, self.dir)
+
+ def _initRepo(self):
+ runcmd("git init".split(), self.dir)
+ runcmd("git add .".split(), self.dir)
+ runcmd("git commit -a --allow-empty -m Patching_started".split(), self.dir)
@staticmethod
def extractPatchHeader(patchfile):
@@ -297,3 +297,9 @@ INHERIT:remove = \"report-error\"
test_recipe_summary_after = get_bb_var('SUMMARY', test_recipe)
self.assertEqual(expected_recipe_summary, test_recipe_summary_after)
+
+ def test_git_patchtool(self):
+ self.write_recipeinc('man-db', 'PATCHTOOL=\"git\"')
+ result = bitbake('man-db -c patch', ignore_status=False)
+ self.delete_recipeinc('man-db')
+ bitbake('-cclean man-db')