Subject: Re: [Bug-vc-dwim] bug#21120: vc-chlog fails if git submodules are dirty

From: Jim Meyering <[email-masked]>
Date: Mon, 27 Jul 2015 22:22:08 -0700

On Wed, Jul 22, 2015 at 4:54 PM, Assaf Gordon <[email-masked]> wrote:
> 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

Hi Assaf,

Wow. Thank you for diving in and writing all of that.
Issuing a warning does have a little more appeal to me, but I would be happy
with a complete patch implementing either behavior (i.e., updating NEWS
and adding a test).

Are you inclined to write that?