Subject: bug#8771: [Bug-vc-dwim] vc-dwim problem parsing ChangeLog entries

From: Jim Meyering <[email-masked]>
Date: Tue, 31 May 2011 23:43:35 +0200

Paul Eggert wrote:
> On 05/31/11 06:03, Stefan Monnier wrote:
>> And rather than
>>
>>    * composite.c (get_composition_id, gstring_lookup_cache):
>>    (composition_gstring_put_cache): Foobar.
>>
>> we usually write:
>>
>>    * composite.c (get_composition_id, gstring_lookup_cache)
>>    (composition_gstring_put_cache): Foobar.
>
> OK, I'll adjust that ChangeLog entry by hand.  I had appended
> the extra colon to the first line because otherwise vc-dwim doesn't
> parse the ChangeLog properly.
>
> This appears to be a bug in vc-dwim so I'll send this email
> to [email-masked] (the original thread is at
> <http://debbugs.gnu.org/cgi/bugreport.cgi?bug=8771#8>).  For example,
> with vc-dwim 1.5 and the following ChangeLog:
>
> 2011-05-31  Paul Eggert  <[email-masked]>
>
>         Remove arbitrary limit of 2**31 entries in hash tables.  (Bug#8771)
> 	* composite.c (get_composition_id, gstring_lookup_cache)
>         (composition_gstring_put_cache):
>         * composite.h (struct composition.hash_index):
>         Use 'EMACS_UINT' and 'EMACS_INT'
>         for hashes and hash indexes, instead of 'unsigned' and 'int'.
>
> vc-dwim generates the following diagnostic:
>
> vc-dwim:ChangeLog: line of unexpected form:
> * composite.c (get_composition_id, gstring_lookup_cache) at
> /home/eggert/opt/Linux-x86_64/merged/bin/vc-dwim line 991.
>
> This diagnostic means vc-dwim isn't understanding the newish ChangeLog
> format in the GNU coding standards
> <http://www.gnu.org/prep/standards/html_node/Style-of-Change-Logs.html>.
> Also, that "line 991" is confusing, since it's not the line number in
> the ChangeLog file.

Hi Paul,

Thanks for the report.
I've added a test for that and fixed it with these:

>From 92d2db3ccfa024f84db6780029a2017cf5184618 Mon Sep 17 00:00:00 2001
From: Jim Meyering <[email-masked]>
Date: Tue, 31 May 2011 23:41:19 +0200
Subject: [PATCH 1/2] vc-dwim: relax file-spec ChangeLog regexp to accommodate
 new GCS-style

* vc-dwim.pl (main): Relax the file-spec matching regexp.  Before,
the regexp was /^\* (\S.*?):/, while now we also allow a line
ending in ")": /^\* (\S.*?)(:|\)$)/
* NEWS (Bug fixes): Mention it.
---
 NEWS       |    3 +++
 vc-dwim.pl |    2 +-
 2 files changed, 4 insertions(+), 1 deletions(-)

diff --git a/NEWS b/NEWS
index 21b39f2..571b4be 100644
--- a/NEWS
+++ b/NEWS
@@ -4,6 +4,9 @@ vc-dwim NEWS                                          -*- outline -*-

 ** Bug fixes

+  vc-dwim no longer fails when it encounters a ChangeLog line like
+  "* file (...)" (i.e., with no colon) when that line ends with a ")".
+
   "vc-dwim a/ChangeLog b/ChangeLog" would mistakenly complain about
   an "--author/ChangeLog mismatch" even though the two name/email
   pairs in the ChangeLog files were identical.
diff --git a/vc-dwim.pl b/vc-dwim.pl
index e474efc..76b3ae0 100755
--- a/vc-dwim.pl
+++ b/vc-dwim.pl
@@ -989,7 +989,7 @@ sub main

           if ($line =~ /^\*/)
             {
-              $line =~ /^\* (\S.*?):/
+              $line =~ /^\* (\S.*?)(:|\)$)/
                 or die "$ME:$log: line of unexpected form:\n$line";
               my $f_spec = $1;
               foreach my $file (change_log_line_extract_file_list ($f_spec))
--
1.7.5.2.660.g9f46c

>From d2083c184da222885e6fd96cbe204af95c86bd2b Mon Sep 17 00:00:00 2001
From: Jim Meyering <[email-masked]>
Date: Tue, 31 May 2011 22:39:52 +0200
Subject: [PATCH 2/2] tests: add a test to exercise a ChangeLog syntax bug

* tests/cl-syntax: New script. Test for the bug reported by Paul Eggert
in https://lists.gnu.org/archive/html/bug-vc-dwim/2011-05/msg00006.html
* tests/Makefile.am (TESTS): Add cl-syntax.
---
 tests/Makefile.am |    1 +
 tests/cl-syntax   |   34 ++++++++++++++++++++++++++++++++++
 2 files changed, 35 insertions(+), 0 deletions(-)
 create mode 100755 tests/cl-syntax

diff --git a/tests/Makefile.am b/tests/Makefile.am
index 307851d..b588c3f 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -14,6 +14,7 @@ TESTS = \
   git-mv \
   two-line-attr \
   cl-other-user \
+  cl-syntax \
   no-vc \
   symlinked-changelog \
   scalar \
diff --git a/tests/cl-syntax b/tests/cl-syntax
new file mode 100755
index 0000000..3a29619
--- /dev/null
+++ b/tests/cl-syntax
@@ -0,0 +1,34 @@
+#!/bin/sh
+# Ensure that we accept relatively new ChangeLog syntax.
+
+. "${srcdir=.}/init.sh"; path_prepend_ ..
+print_ver_ vc-dwim
+
+require_git_
+
+cat <<EOF > ChangeLog || framework_failure_
+2011-05-31  R. Andom  <[email-masked]>
+
+	* not-checked.c: Irrelevant.
+
+EOF
+git init > /dev/null || framework_failure_
+touch foo || framework_failure_
+git add . || framework_failure_
+git commit -m m . > /dev/null || framework_failure_
+
+cat <<EOF > ChangeLog
+2011-05-31  R. Andom  <[email-masked]>
+
+	* foo (bar)
+        (qux): Comment.
+	* not-checked.c: Irrelevant.
+
+EOF
+
+fail=0
+
+echo a > foo || framework_failure_
+vc-dwim ChangeLog || fail=1
+
+Exit $fail
--
1.7.5.2.660.g9f46c