[U-Boot] [PATCH 1/2] patman: Deal with 'git apply' failures correctly

This sort of failure is rare, but the code to deal with it is wrong. Fix it.
Signed-off-by: Simon Glass sjg@chromium.org ---
tools/patman/gitutil.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/tools/patman/gitutil.py b/tools/patman/gitutil.py index 5dcbaa3..3ea256d 100644 --- a/tools/patman/gitutil.py +++ b/tools/patman/gitutil.py @@ -11,6 +11,7 @@ import subprocess import sys import terminal
+import checkpatch import settings
@@ -193,6 +194,7 @@ def ApplyPatch(verbose, fname): Args: fname: filename of patch file to apply """ + col = terminal.Color() cmd = ['git', 'am', fname] pipe = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE) @@ -203,8 +205,8 @@ def ApplyPatch(verbose, fname): print line match = re_error.match(line) if match: - print GetWarningMsg('warning', match.group(1), int(match.group(2)), - 'Patch failed') + print checkpatch.GetWarningMsg(col, 'warning', match.group(1), + int(match.group(2)), 'Patch failed') return pipe.returncode == 0, stdout
def ApplyPatches(verbose, args, start_point):

Collect all Signed-off-by tags in a commit and make sure that there are no duplicates.
Signed-off-by: Simon Glass sjg@chromium.org ---
tools/patman/README | 1 + tools/patman/commit.py | 13 +++++++++++++ tools/patman/patchstream.py | 10 ++++++++-- 3 files changed, 22 insertions(+), 2 deletions(-)
diff --git a/tools/patman/README b/tools/patman/README index 59f1776..119c554 100644 --- a/tools/patman/README +++ b/tools/patman/README @@ -192,6 +192,7 @@ END A sign-off is added automatically to your patches (this is probably a bug). If you put this tag in your patches, it will override the default signoff that patman automatically adds. + Multiple duplicate signoffs will be removed.
Tested-by: Their Name <email> Reviewed-by: Their Name <email> diff --git a/tools/patman/commit.py b/tools/patman/commit.py index 89cce7f..6cc5a41 100644 --- a/tools/patman/commit.py +++ b/tools/patman/commit.py @@ -29,6 +29,7 @@ class Commit: self.tags = [] self.changes = {} self.cc_list = [] + self.signoff_set = set() self.notes = []
def AddChange(self, version, info): @@ -72,3 +73,15 @@ class Commit: cc_list: List of aliases or email addresses """ self.cc_list += cc_list + + def AddSignoff(self, signoff): + """Add a list of signoffs when we send this patch. + + Args: + signoff: Signoff line + """ + self.signoff_set.add(signoff) + + def FormatSignoffs(self): + """Return a formatted list of signoffs for this commit.""" + return ['Signed-off-by: ' + s for s in self.signoff_set] diff --git a/tools/patman/patchstream.py b/tools/patman/patchstream.py index 684204c..32ebc35 100644 --- a/tools/patman/patchstream.py +++ b/tools/patman/patchstream.py @@ -21,7 +21,7 @@ re_remove = re.compile('^BUG=|^TEST=|^BRANCH=|^Change-Id:|^Review URL:' re_allowed_after_test = re.compile('^Signed-off-by:')
# Signoffs -re_signoff = re.compile('^Signed-off-by:') +re_signoff = re.compile('^Signed-off-by: *(.*)')
# The start of the cover letter re_cover = re.compile('^Cover-letter:') @@ -159,6 +159,7 @@ class PatchStream: commit_tag_match = re_commit_tag.match(line) commit_match = re_commit.match(line) if self.is_log else None cover_cc_match = re_cover_cc.match(line) + signoff_match = re_signoff.match(line) tag_match = None if self.state == STATE_PATCH_HEADER: tag_match = re_tag.match(line) @@ -223,7 +224,7 @@ class PatchStream: if is_blank: # Blank line ends this change list self.in_change = 0 - elif line == '---' or re_signoff.match(line): + elif line == '---': self.in_change = 0 out = self.ProcessLine(line) else: @@ -272,6 +273,10 @@ class PatchStream: else: self.tags.append(line);
+ # Collect signoffs to add later + elif signoff_match: + self.commit.AddSignoff(signoff_match.group(1)) + # Well that means this is an ordinary line else: pos = 1 @@ -305,6 +310,7 @@ class PatchStream: out = [] log = self.series.MakeChangeLog(self.commit) out += self.FormatTags(self.tags) + out += self.commit.FormatSignoffs() out += [line] + self.commit.notes + [''] + log elif self.found_test: if not re_allowed_after_test.match(line):

Hi Simon,
Collect all Signed-off-by tags in a commit and make sure that there are no duplicates.
Signed-off-by: Simon Glass sjg@chromium.org
I have a change request about this patch.
It is true this patch avoids duplication, but it changes the order *-by: credits.
For example, assume something like this in my git-log
blah blah blah
Signed-off-by: Masahiro Yamada yamada.m@jp.panasonic.com Reported-by: For Bar foo@bar.com
Patman changes it to
blah blah blah
Reported-by: For Bar foo@bar.com Signed-off-by: Masahiro Yamada yamada.m@jp.panasonic.com
I want Patman to touch *-by: credits only when it is really necessary. [1] when adding a missing Signed-off-by: [2] when deleting redundant Signed-off-by:
Best Regards Masahiro Yamada

Hi Masahiro,
On 27 March 2014 22:42, Masahiro Yamada yamada.m@jp.panasonic.com wrote:
Hi Simon,
Collect all Signed-off-by tags in a commit and make sure that there are no duplicates.
Signed-off-by: Simon Glass sjg@chromium.org
I have a change request about this patch.
It is true this patch avoids duplication, but it changes the order *-by: credits.
For example, assume something like this in my git-log
blah blah blah
Signed-off-by: Masahiro Yamada yamada.m@jp.panasonic.com Reported-by: For Bar foo@bar.com
Patman changes it to
blah blah blah
Reported-by: For Bar foo@bar.com Signed-off-by: Masahiro Yamada yamada.m@jp.panasonic.com
I want Patman to touch *-by: credits only when it is really necessary. [1] when adding a missing Signed-off-by: [2] when deleting redundant Signed-off-by:
Yes I agree that is better - I will update the patch and resend as v2.
Regards, Simon
participants (2)
-
Masahiro Yamada
-
Simon Glass