Changeset 62692 in webkit


Ignore:
Timestamp:
Jul 7, 2010 1:02:09 PM (14 years ago)
Author:
ddkilzer@apple.com
Message:

<http://webkit.org/b/41788> commit-log-editor: wrong ChangeLog read when invoked from subdir with git

Reviewed by Anders Carlsson.

For both svn and git, commit-log-editor is invoked from the root
of the working directory. Unlike svn, git returns a list of
changed files that are relative to the directory where the
command was invoked. This caused the ChangeLog file in the root
directory to be read instead of the ChangeLog in the current
directory.

The fix is to use $ENV{PWD} as the base directory when fixing
the path to the ChangeLog files. With svn, this has no net
effect since $ENV{PWD} is the root of the working directory and
the ChangeLog paths are already relative to that directory.
With git, $ENV{PWD} is the directory that the commit was invoked
from, which fixes the ChangeLog paths so that the correct files
are read when creating the commit log entry.

Note that the call to makeFilePathRelative() was supposed to
address this issue, but it doesn't because (a) it does nothing
with svn working directories by design, and (b) it does nothing
with git working directories because it's invoked when the
current directory is the root of the working directory, thus
giving no relative path.

  • Scripts/commit-log-editor: Removed call to

makeFilePathRelative() since since it does nothing. Moved code
to fix up $changeLog path so that it's fixed before trying to
open the file, and use $ENV{PWD} as the base path. Also use
canonicalizePath() to clean up paths with "../" in them.

Location:
trunk/WebKitTools
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebKitTools/ChangeLog

    r62688 r62692  
     12010-07-07  David Kilzer  <ddkilzer@apple.com>
     2
     3        <http://webkit.org/b/41788> commit-log-editor: wrong ChangeLog read when invoked from subdir with git
     4
     5        Reviewed by Anders Carlsson.
     6
     7        For both svn and git, commit-log-editor is invoked from the root
     8        of the working directory.  Unlike svn, git returns a list of
     9        changed files that are relative to the directory where the
     10        command was invoked.  This caused the ChangeLog file in the root
     11        directory to be read instead of the ChangeLog in the current
     12        directory.
     13
     14        The fix is to use $ENV{PWD} as the base directory when fixing
     15        the path to the ChangeLog files.  With svn, this has no net
     16        effect since $ENV{PWD} is the root of the working directory and
     17        the ChangeLog paths are already relative to that directory.
     18        With git, $ENV{PWD} is the directory that the commit was invoked
     19        from, which fixes the ChangeLog paths so that the correct files
     20        are read when creating the commit log entry.
     21
     22        Note that the call to makeFilePathRelative() was supposed to
     23        address this issue, but it doesn't because (a) it does nothing
     24        with svn working directories by design, and (b) it does nothing
     25        with git working directories because it's invoked when the
     26        current directory is the root of the working directory, thus
     27        giving no relative path.
     28
     29        * Scripts/commit-log-editor: Removed call to
     30        makeFilePathRelative() since since it does nothing.  Moved code
     31        to fix up $changeLog path so that it's fixed before trying to
     32        open the file, and use $ENV{PWD} as the base path.  Also use
     33        canonicalizePath() to clean up paths with "../" in them.
     34
    1352010-07-07  Anders Carlsson  <andersca@apple.com>
    236
  • trunk/WebKitTools/Scripts/commit-log-editor

    r57447 r62692  
    107107    $existingLog = isGit() && !(/^#/ || /^\s*$/) unless $existingLog;
    108108
    109     push @changeLogs, makeFilePathRelative($1) if $inChangesToBeCommitted && (/^(?:M|A)....(.*ChangeLog)\r?\n?$/ || /^#\t(?:modified|new file):   (.*ChangeLog)$/) && !/-ChangeLog$/;
     109    push @changeLogs, $1 if $inChangesToBeCommitted && (/^(?:M|A)....(.*ChangeLog)\r?\n?$/ || /^#\t(?:modified|new file):   (.*ChangeLog)$/) && !/-ChangeLog$/;
    110110}
    111111close LOG;
     
    134134my %changeLogContents;
    135135for my $changeLog (@changeLogs) {
     136    $changeLog = File::Spec->abs2rel(canonicalizePath(File::Spec->rel2abs($changeLog, $ENV{PWD})), $topLevel);
     137
    136138    open CHANGELOG, $changeLog or die "Can't open $changeLog";
    137139    my $contents = "";
     
    200202    close CHANGELOG;
    201203
    202     $changeLog = File::Spec->abs2rel(File::Spec->rel2abs($changeLog), $topLevel);
    203 
    204204    my $label = dirname($changeLog);
    205205    $label = "top level" unless length $label;
Note: See TracChangeset for help on using the changeset viewer.