Subject: bug#21120: vc-chlog fails if git submodules are dirty

From: Assaf Gordon <[email-masked]>
Date: Wed, 22 Jul 2015 19:54:47 -0400

Hello,

it seems that if a project using git has a submodule that is dirty, vc-chlog will fail to print the information about all the files.

To reproduce:
====
    git clone git://git.sv.gnu.org/hello.git
    cd hello/
    ./bootstrap
    echo >> bootstrap.conf
    echo >> gnulib/cfg.mk
    echo >> src/hello.c
====

The diff looks like this:
===
$ git diff
diff --git a/bootstrap.conf b/bootstrap.conf
index 9e6b005..79d4c5b 100644
--- a/bootstrap.conf
+++ b/bootstrap.conf
@@ -119,3 +119,4 @@ bootstrap_epilogue()
      done
    fi
  }
+
diff --git a/gnulib b/gnulib
--- a/gnulib
+++ b/gnulib
@@ -1 +1 @@
-Subproject commit b9bfe78424b871f5b92e5ee9e7d21ef951a6801d
+Subproject commit b9bfe78424b871f5b92e5ee9e7d21ef951a6801d-dirty
diff --git a/src/hello.c b/src/hello.c
index 8e6cfbd..f0d12de 100644
--- a/src/hello.c
+++ b/src/hello.c
@@ -187,3 +187,4 @@ License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>\n\
  This is free software: you are free to change and redistribute it.\n\
  There is NO WARRANTY, to the extent permitted by law.\n"), COPYRIGHT_YEAR);
  }
+
===

But vc-chlog will stop after the gnulib submodule:
===
$ vc-chlog
2015-07-22  gordon  <gordon@hostname>

	* bootstrap.conf:
	* gnulib:
===

A bit of debugging seems to show that in 'vc-chlog', the output of 'processed-diff()' is:
    bootstrap.conf 1 3 9 0-0-122-122
    gnulib 1 11 15 1-1-1-1
    src/hello.c 1 18 24 0-0-190-190

Then 'func_extract_identifiers()' calls 'func_apply_tmp_patch()' which runs 'patch', and patch fails.
  
One possible work-around is to ignore submodules in 'vc-dwim' (attached patch).

Another possible thing is to make 'vc-dwim' abort if there are dirty submodules, on the assumption that 'vc-dwim' is meant to prevent problematic commits, and a dirty submodule is a hint of a potential problem.
related to this approach, there was a discussion couple of months about about adding a server-side git hook in savannah to prevent such commits, but it was decided against such forcible approach. perhaps warning about dirty submodules in 'vc-dwim' is more polite?
   http://lists.gnu.org/archive/html/coreutils/2015-04/msg00017.html

regards,
  - assaf

>From fb509424ca4b2b5f69f4ab52959d1cb03e7ebd5a Mon Sep 17 00:00:00 2001
From: Assaf Gordon <[email-masked]>
Date: Wed, 22 Jul 2015 19:40:52 -0400
Subject: [PATCH] VC.pm: ignore changes in git submodules

---
 VC.pm | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/VC.pm b/VC.pm
index 81a2390..039f312 100644
--- a/VC.pm
+++ b/VC.pm
@@ -57,8 +57,9 @@ my $vc_cmd =
    GIT() =>
    {
     AUTHOR_FMT => '--author=%s',
-    DIFF_COMMAND => [qw(git diff -B -C HEAD --)],
-    DIFF_PRISTINE => [qw(git diff --no-ext-diff -B -C HEAD --)],
+    DIFF_COMMAND => [qw(git diff --ignore-submodules=all -B -C HEAD --)],
+    DIFF_PRISTINE => [qw(git diff --ignore-submodules=all --no-ext-diff
+                         -B -C HEAD --)],
     VALID_DIFF_EXIT_STATUS => {0 => 1},
     COMMIT_COMMAND => [qw(git commit -q -F)],
     # is-version-controlled-file: true, if "git cat-file -t HEAD:$file"
-- 
1.9.1