Bug 145082

Summary: prepare-ChangeLog reports function above deleted function as deleted; uninitialized value warning when staged non-empty file for commit
Product: WebKit Reporter: Daniel Bates <dbates>
Component: Tools / TestsAssignee: Daniel Bates <dbates>
Status: RESOLVED FIXED    
Severity: Normal CC: darin, ddkilzer, matthew_hanson, mitz
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: All   
OS: All   
Attachments:
Description Flags
Patch and unit tests darin: review+

Description Daniel Bates 2015-05-15 17:13:36 PDT
Perl warns of the use of an uninitialized variable in prepare-ChangeLog when the working copy has a non-empty new file staged for commit:

Use of uninitialized value $first_line in pattern match (m//) at Tools/Scripts/prepare-ChangeLog line 644.

Without loss of generality, you can reproduce this issue by running the following terminal commands inside the top-level directory of a Git checkout of the WebKit repository:

$ echo 'A' > A.txt
$ git add A.txt 
$ Tools/Scripts/prepare-ChangeLog

Then you will see output of the form:

  Running status to find changed, added, or removed files.
  Reviewing diff to determine which lines changed.
  Extracting affected function names from source files.
fatal: Path 'A.txt' exists on disk, but not in 'HEAD'.
Use of uninitialized value $first_line in pattern match (m//) at Tools/Scripts/prepare-ChangeLog line 644.
  Change author: Daniel Bates <dabates@apple.com>.
  Editing the ./ChangeLog file.
-- Please remember to include a detailed description in your ChangeLog entry. --
-- See <http://webkit.org/coding/contributing.html> for more info --
Comment 1 Daniel Bates 2015-05-15 17:16:11 PDT
The logic for parsing a chunk range line of a unified diff is incorrect in extractLineRange{Before, After}Change(). In addition to causes this bug it also causes prepare-ChangeLog to always emit the name of the function f_0 above a deleted function regardless of whether f_0 changed.
Comment 2 Daniel Bates 2015-05-15 17:21:50 PDT
Created attachment 253243 [details]
Patch and unit tests
Comment 3 Daniel Bates 2015-05-15 17:24:12 PDT
Comment on attachment 253243 [details]
Patch and unit tests

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

> Tools/Scripts/webkitperl/prepare-ChangeLog_unittest/extractLineRangeBeforeAndAfterChange.pl:29
> +use VCSUtils;

Will remove this before landing.
Comment 4 Daniel Bates 2015-05-18 16:56:32 PDT
Committed r184521: <http://trac.webkit.org/changeset/184521>