[OE-core] [PATCH] lib/oe/patch.py: Prefer "git am" over "git apply" when applying git patches

Saul Wold sgw at linux.intel.com
Mon Jan 6 22:10:02 UTC 2014


On 12/31/2013 06:18 AM, Laszlo Papp wrote:
> Ping?
>
> Alternatively, the system could also have an option for further
> fine-tuning what to do with git patches
>
> On Tue, Dec 24, 2013 at 12:44 PM, Laszlo Papp <lpapp at kde.org> wrote:
>> 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.
>>
Looking at this, is it possible to detect a git patch and only then use 
git am?  Since most of the patches carried in oe-core and other layers 
the 'git am' will typically fail and increase the build time since it 
will have to re-run the git apply, we don't want to had more forking and 
work in the main hot path.

I am not the expert in this, neither is RP, so maybe Chris can comment 
further.

Thanks
	Sau!


>> Signed-off-by: Laszlo Papp <lpapp at kde.org>
>> ---
>>   meta/lib/oe/patch.py | 20 +++++++++++++-------
>>   1 file changed, 13 insertions(+), 7 deletions(-)
>>
>> diff --git a/meta/lib/oe/patch.py b/meta/lib/oe/patch.py
>> index 59abd0a..b085c9d 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):
>> --
>> 1.8.5.1
>>
> _______________________________________________
> Openembedded-core mailing list
> Openembedded-core at lists.openembedded.org
> http://lists.openembedded.org/mailman/listinfo/openembedded-core
>



More information about the Openembedded-core mailing list