2010-01-25  Chris Jerdonek  <cjerdonek@webkit.org>

        Reviewed by Adam Barth.

        Improved prepare-ChangeLog so that it preserves the relative
        indentation of a git commit message.

        https://bugs.webkit.org/show_bug.cgi?id=34058

        * Scripts/prepare-ChangeLog:
          - Also adjusted the script so that it does not add white
            space characters to empty lines.

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@53796 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/WebKitTools/Scripts/prepare-ChangeLog b/WebKitTools/Scripts/prepare-ChangeLog
index 4c59af9..57743e7 100755
--- a/WebKitTools/Scripts/prepare-ChangeLog
+++ b/WebKitTools/Scripts/prepare-ChangeLog
@@ -1606,6 +1606,7 @@
         $description .= "\n" if $commitLogCount;
         $commitLogCount++;
         my $inHeader = 1;
+        my $commitLogIndent; 
         my @lines = split(/\n/, $commitLog);
         shift @lines; # Remove initial blank line
         foreach my $line (@lines) {
@@ -1620,11 +1621,18 @@
                 } else {
                     $reviewer .= ", " . $1;
                 }
-            } elsif (length $line == 0) {
+            } elsif ($line =~ /^\s*$/) {
                 $description = $description . "\n";
             } else {
-                $line =~ s/^\s*//;
-                $description = $description . "        " . $line . "\n";
+                if (!defined($commitLogIndent)) {
+                    # Let the first line with non-white space determine
+                    # the global indent.
+                    $line =~ /^(\s*)\S/;
+                    $commitLogIndent = length($1);
+                }
+                # Strip at most the indent to preserve relative indents.
+                $line =~ s/^\s{0,$commitLogIndent}//;
+                $description = $description . (" " x 8) . $line . "\n";
             }
         }
     }