patman: Only apply patches when we know the original HEAD

When patman applies the patches it checks out a new branch, uses 'git am'
to apply the patches one by one, and then tries to go back to the old
branch. If you try this when the branch is 'undefined', this doesn't work
as patman cannot restore the correct branch after applying the patches.
It seems that 'undefined' is created by git and is persistent after it is
created, so that you can end up on quite an old branch.

Add a check for the 'undefined' branch to avoid this.

Reported-by: Masahiro Yamada <yamada.m@jp.panasonic.com>
Signed-off-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
Simon Glass 2014-06-11 23:27:09 -06:00
parent 6ee3d00d1d
commit 4251978afc

View File

@ -232,6 +232,10 @@ def ApplyPatches(verbose, args, start_point):
print stdout print stdout
return False return False
old_head = stdout.splitlines()[0] old_head = stdout.splitlines()[0]
if old_head == 'undefined':
str = "Invalid HEAD '%s'" % stdout.strip()
print col.Color(col.RED, str)
return False
# Checkout the required start point # Checkout the required start point
cmd = ['git', 'checkout', 'HEAD~%d' % start_point] cmd = ['git', 'checkout', 'HEAD~%d' % start_point]