<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugs.webkit.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4.1"
          urlbase="https://bugs.webkit.org/"
          
          maintainer="admin@webkit.org"
>

    <bug>
          <bug_id>138627</bug_id>
          
          <creation_ts>2014-11-11 13:29:25 -0800</creation_ts>
          <short_desc>webkit-patch --suggest-reviewers is broken with newer versions of git</short_desc>
          <delta_ts>2015-06-12 23:11:01 -0700</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebKit</product>
          <component>Tools / Tests</component>
          <version>528+ (Nightly build)</version>
          <rep_platform>Unspecified</rep_platform>
          <op_sys>Unspecified</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P2</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="David Kilzer (:ddkilzer)">ddkilzer</reporter>
          <assigned_to name="David Kilzer (:ddkilzer)">ddkilzer</assigned_to>
          <cc>ap</cc>
    
    <cc>buildbot</cc>
    
    <cc>changseok</cc>
    
    <cc>commit-queue</cc>
    
    <cc>dbates</cc>
    
    <cc>glenn</cc>
    
    <cc>jake.nielsen.webkit</cc>
    
    <cc>rniwa</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>1047960</commentid>
    <comment_count>0</comment_count>
    <who name="David Kilzer (:ddkilzer)">ddkilzer</who>
    <bug_when>2014-11-11 13:29:25 -0800</bug_when>
    <thetext>The --suggest-reviewers feature of webkit-patch is broken on newer versions of git when any commit being considered has a single ChangeLog and that ChangeLog is the first file in the list of changed files for a commit.

In Tools/Scripts/webkitpy/common/checkout/scm/git.py we have:

def _changes_files_for_commit(self, git_commit):
    # --pretty=&quot;format:&quot; makes git show not print the commit log header,
    changed_files = self._run_git([&quot;show&quot;, &quot;--pretty=format:&quot;, &quot;--name-only&quot;, git_commit]).splitlines()
    # instead it just prints a blank line at the top, so we skip the blank line:
    return changed_files[1:]

And let&apos;s say we&apos;re looking at 0b09603c479afc9ce9256ecbb36cb18e149fe81c (r174332):

$ git show --pretty=format: --name-only 0b09603c479afc9ce9256ecbb36cb18e149fe81c
Source/WebCore/ChangeLog
Source/WebCore/bindings/gobject/WebKitDOMPrivate.cpp
Source/WebCore/css/CSSStyleSheet.h
Source/WebCore/css/StyleSheet.h
Source/WebCore/dom/Document.cpp
Source/WebCore/dom/DocumentStyleSheetCollection.cpp
Source/WebCore/dom/ProcessingInstruction.cpp
Source/WebCore/inspector/InspectorCSSAgent.cpp
Source/WebCore/xml/XSLStyleSheet.h

The existing code will skip &apos;Source/WebCore/ChangeLog&apos; from the list of files, thus causing --suggest-reviewers to break:

Traceback (most recent call last):
  File &quot;./Tools/Scripts/webkit-patch&quot;, line 84, in &lt;module&gt;
    main()
  File &quot;./Tools/Scripts/webkit-patch&quot;, line 79, in main
    WebKitPatch(os.path.abspath(__file__)).main()
  File &quot;./Tools/Scripts/webkitpy/tool/multicommandtool.py&quot;, line 305, in main
    result = command.check_arguments_and_execute(options, args, self)
  File &quot;./Tools/Scripts/webkitpy/tool/multicommandtool.py&quot;, line 123, in check_arguments_and_execute
    return self.execute(options, args, tool) or 0
  File &quot;./Tools/Scripts/webkitpy/tool/commands/abstractsequencedcommand.py&quot;, line 54, in execute
    self._sequence.run_and_handle_errors(tool, options, state)
  File &quot;./Tools/Scripts/webkitpy/tool/commands/stepsequence.py&quot;, line 73, in run_and_handle_errors
    self._run(tool, options, state)
  File &quot;./Tools/Scripts/webkitpy/tool/commands/stepsequence.py&quot;, line 67, in _run
    step(tool, options).run(state)
  File &quot;./Tools/Scripts/webkitpy/tool/steps/suggestreviewers.py&quot;, line 45, in run
    reviewers = self._tool.checkout().suggested_reviewers(self._options.git_commit, self._changed_files(state))[:5]
  File &quot;./Tools/Scripts/webkitpy/common/checkout/checkout.py&quot;, line 144, in suggested_reviewers
    commit_infos = sorted(self.recent_commit_infos_for_files(changed_files), key=lambda info: info.revision(), reverse=True)
  File &quot;./Tools/Scripts/webkitpy/common/checkout/checkout.py&quot;, line 144, in &lt;lambda&gt;
    commit_infos = sorted(self.recent_commit_infos_for_files(changed_files), key=lambda info: info.revision(), reverse=True)
AttributeError: &apos;NoneType&apos; object has no attribute &apos;revision&apos;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1047961</commentid>
    <comment_count>1</comment_count>
      <attachid>241378</attachid>
    <who name="David Kilzer (:ddkilzer)">ddkilzer</who>
    <bug_when>2014-11-11 13:31:52 -0800</bug_when>
    <thetext>Created attachment 241378
Patch v1</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1047991</commentid>
    <comment_count>2</comment_count>
      <attachid>241378</attachid>
    <who name="Daniel Bates">dbates</who>
    <bug_when>2014-11-11 15:15:51 -0800</bug_when>
    <thetext>Comment on attachment 241378
Patch v1

View in context: https://bugs.webkit.org/attachment.cgi?id=241378&amp;action=review

&gt; Tools/Scripts/webkitpy/common/checkout/scm/git.py:229
&gt; +        return [s for s in changed_files.splitlines() if s.strip()]

This is OK as-is (*). Notice that str.splitlines() breaks a string into lines removing carriage return, new-line characters (by default) and str.strip() returns a copy of a string without leading and trailing whitespace, including carriage return and newline characters. Is it necessary to remove leading and trailing whitespace from each line? I mean, it seems sufficient to trim leading whitespace from the string changed_files before splitting it at line breaks and write:

return changed_files.lstrip().splitlines()

(*) For completeness, with the proposed change we will truncate filenames that have trailing whitespace (e.g. &quot;../WebCore/A Filename With A Space At The End &quot;). I doubt we need to support such file names.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1047994</commentid>
    <comment_count>3</comment_count>
      <attachid>241378</attachid>
    <who name="Daniel Bates">dbates</who>
    <bug_when>2014-11-11 15:21:25 -0800</bug_when>
    <thetext>Comment on attachment 241378
Patch v1

The patch is fine to land as-is. I&apos;m marking this patch cq- should you wish to consider my remark in comment #2. Feel free to cq+ the patch to land as-is.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1047997</commentid>
    <comment_count>4</comment_count>
      <attachid>241378</attachid>
    <who name="David Kilzer (:ddkilzer)">ddkilzer</who>
    <bug_when>2014-11-11 15:27:19 -0800</bug_when>
    <thetext>Comment on attachment 241378
Patch v1

View in context: https://bugs.webkit.org/attachment.cgi?id=241378&amp;action=review

&gt;&gt; Tools/Scripts/webkitpy/common/checkout/scm/git.py:229
&gt;&gt; +        return [s for s in changed_files.splitlines() if s.strip()]
&gt; 
&gt; This is OK as-is (*). Notice that str.splitlines() breaks a string into lines removing carriage return, new-line characters (by default) and str.strip() returns a copy of a string without leading and trailing whitespace, including carriage return and newline characters. Is it necessary to remove leading and trailing whitespace from each line? I mean, it seems sufficient to trim leading whitespace from the string changed_files before splitting it at line breaks and write:
&gt; 
&gt; return changed_files.lstrip().splitlines()
&gt; 
&gt; (*) For completeness, with the proposed change we will truncate filenames that have trailing whitespace (e.g. &quot;../WebCore/A Filename With A Space At The End &quot;). I doubt we need to support such file names.

I realize this change doesn&apos;t precisely preserve the previous behavior, but my goal was to make the new behavior more explicit/well-defined to defend against a future change to git-show output.

I&apos;ll land a follow-up fix once the CQ lands this to use your suggestion above.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1048028</commentid>
    <comment_count>5</comment_count>
    <who name="David Kilzer (:ddkilzer)">ddkilzer</who>
    <bug_when>2014-11-11 16:47:19 -0800</bug_when>
    <thetext>Committed r175991: &lt;http://trac.webkit.org/changeset/175991&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1101796</commentid>
    <comment_count>6</comment_count>
    <who name="ChangSeok Oh">changseok</who>
    <bug_when>2015-06-12 23:11:01 -0700</bug_when>
    <thetext>This happens again on mac using Yosemite.

[changseok@MacBookProStation:WebKit]$ ./Tools/Scripts/webkit-patch suggest-reviewers
Traceback (most recent call last):
  File &quot;./Tools/Scripts/webkit-patch&quot;, line 84, in &lt;module&gt;
    main()
  File &quot;./Tools/Scripts/webkit-patch&quot;, line 79, in main
    WebKitPatch(os.path.abspath(__file__)).main()
  File &quot;/Users/changseok/Projects/WebKit/Tools/Scripts/webkitpy/tool/multicommandtool.py&quot;, line 305, in main
    result = command.check_arguments_and_execute(options, args, self)
  File &quot;/Users/changseok/Projects/WebKit/Tools/Scripts/webkitpy/tool/multicommandtool.py&quot;, line 123, in check_arguments_and_execute
    return self.execute(options, args, tool) or 0
  File &quot;/Users/changseok/Projects/WebKit/Tools/Scripts/webkitpy/tool/commands/abstractsequencedcommand.py&quot;, line 54, in execute
    self._sequence.run_and_handle_errors(tool, options, state)
  File &quot;/Users/changseok/Projects/WebKit/Tools/Scripts/webkitpy/tool/commands/stepsequence.py&quot;, line 73, in run_and_handle_errors
    self._run(tool, options, state)
  File &quot;/Users/changseok/Projects/WebKit/Tools/Scripts/webkitpy/tool/commands/stepsequence.py&quot;, line 67, in _run
    step(tool, options).run(state)
  File &quot;/Users/changseok/Projects/WebKit/Tools/Scripts/webkitpy/tool/steps/suggestreviewers.py&quot;, line 45, in run
    reviewers = self._tool.checkout().suggested_reviewers(self._options.git_commit, self._changed_files(state))[:5]
  File &quot;/Users/changseok/Projects/WebKit/Tools/Scripts/webkitpy/common/checkout/checkout.py&quot;, line 144, in suggested_reviewers
    commit_infos = sorted(self.recent_commit_infos_for_files(changed_files), key=lambda info: info.revision(), reverse=True)
  File &quot;/Users/changseok/Projects/WebKit/Tools/Scripts/webkitpy/common/checkout/checkout.py&quot;, line 144, in &lt;lambda&gt;
    commit_infos = sorted(self.recent_commit_infos_for_files(changed_files), key=lambda info: info.revision(), reverse=True)
AttributeError: &apos;NoneType&apos; object has no attribute &apos;revision&apos;</thetext>
  </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="1"
              isprivate="0"
          >
            <attachid>241378</attachid>
            <date>2014-11-11 13:31:52 -0800</date>
            <delta_ts>2014-11-11 15:21:25 -0800</delta_ts>
            <desc>Patch v1</desc>
            <filename>bug-138627-20141111133155.patch</filename>
            <type>text/plain</type>
            <size>2075</size>
            <attacher name="David Kilzer (:ddkilzer)">ddkilzer</attacher>
            
              <data encoding="base64">U3VidmVyc2lvbiBSZXZpc2lvbjogMTc1OTU2CmRpZmYgLS1naXQgYS9Ub29scy9DaGFuZ2VMb2cg
Yi9Ub29scy9DaGFuZ2VMb2cKaW5kZXggNzcwMzM0YjE5NDQzNGQxNjM2ZGFjNTI1M2YyYjhjYWIy
YTAzNThiZi4uY2UzM2FjYzkzN2VmNjNjZjYwOWY1MDJmOWU3YTgzYjU1NjNjZTM3MiAxMDA2NDQK
LS0tIGEvVG9vbHMvQ2hhbmdlTG9nCisrKyBiL1Rvb2xzL0NoYW5nZUxvZwpAQCAtMSwzICsxLDE1
IEBACisyMDE0LTExLTExICBEYXZpZCBLaWx6ZXIgIDxkZGtpbHplckBhcHBsZS5jb20+CisKKyAg
ICAgICAgd2Via2l0LXBhdGNoIC0tc3VnZ2VzdC1yZXZpZXdlcnMgaXMgYnJva2VuIHdpdGggbmV3
ZXIgdmVyc2lvbnMgb2YgZ2l0CisgICAgICAgIDxodHRwOi8vd2Via2l0Lm9yZy9iLzEzODYyNz4K
KworICAgICAgICBSZXZpZXdlZCBieSBOT0JPRFkgKE9PUFMhKS4KKworICAgICAgICAqIFNjcmlw
dHMvd2Via2l0cHkvY29tbW9uL2NoZWNrb3V0L3NjbS9naXQucHk6CisgICAgICAgIChHaXQuX2No
YW5nZXNfZmlsZXNfZm9yX2NvbW1pdCk6IEZpbHRlciBvdXQgYmxhbmsgbGluZXMgaW5zdGVhZAor
ICAgICAgICBvZiBhc3N1bWluZyB0aGVyZSBpcyBhbHdheXMgYSBibGFuayBsaW5lIGF0IHRoZSBi
ZWdpbm5pbmcgb2YgdGhlCisgICAgICAgIGxpc3QuCisKIDIwM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b3JtYXQ6IiwgIi0tbmFtZS1vbmx5IiwgZ2l0X2Nv
bW1pdF0pLnNwbGl0bGluZXMoKQotICAgICAgICAjIGluc3RlYWQgaXQganVzdCBwcmludHMgYSBi
bGFuayBsaW5lIGF0IHRoZSB0b3AsIHNvIHdlIHNraXAgdGhlIGJsYW5rIGxpbmU6Ci0gICAgICAg
IHJldHVybiBjaGFuZ2VkX2ZpbGVzWzE6XQorICAgICAgICAjIC0tcHJldHR5PSJmb3JtYXQ6IiBt
YWtlcyBnaXQgc2hvdyBub3QgcHJpbnQgdGhlIGNvbW1pdCBsb2cgaGVhZGVyLgorICAgICAgICBj
aGFuZ2VkX2ZpbGVzID0gc2VsZi5fcnVuX2dpdChbInNob3ciLCAiLS1wcmV0dHk9Zm9ybWF0OiIs
ICItLW5hbWUtb25seSIsIGdpdF9jb21taXRdKQorICAgICAgICAjIEZpbHRlciBvdXQgYmxhbmsg
bGluZXMgd2hpY2ggY291bGQgYXBwZWFyIGF0IHRoZSB0b3Agb24gb2xkZXIgdmVyc2lvbnMgb2Yg
Z2l0LgorICAgICAgICByZXR1cm4gW3MgZm9yIHMgaW4gY2hhbmdlZF9maWxlcy5zcGxpdGxpbmVz
KCkgaWYgcy5zdHJpcCgpXQogCiAgICAgZGVmIGNoYW5nZWRfZmlsZXNfZm9yX3JldmlzaW9uKHNl
bGYsIHJldmlzaW9uKToKICAgICAgICAgY29tbWl0X2lkID0gc2VsZi5naXRfY29tbWl0X2Zyb21f
c3ZuX3JldmlzaW9uKHJldmlzaW9uKQo=
</data>
<flag name="review"
          id="266233"
          type_id="1"
          status="+"
          setter="msaboff"
    />
    <flag name="commit-queue"
          id="266234"
          type_id="3"
          status="-"
          setter="dbates"
    />
          </attachment>
      

    </bug>

</bugzilla>