#!/bin/sh
# Demonstrate that with two identical ChangeLog headers, vc-dwim
# no longer mistakenly emits one at the end of the log message.

# Copyright (C) 2011-2013 Free Software Foundation, Inc.

# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

. "${srcdir=.}/init.sh"; path_prepend_ ..
print_ver_ vc-dwim
require_git_

header='2011-03-04  Joe Random  <jr@example.com>'
git init > /dev/null                            \
  && printf "$header\n\n\tfirst\n"> ChangeLog   \
  && touch x                                    \
  && git add .                                  \
  && git commit -m m . > /dev/null              \
    || framework_failure_

printf "$header\n\n\t* x: y\n\n$header\n\n\tfirst\n" > ChangeLog \
    || framework_failure_
echo foo > x || framework_failure_

vc-dwim --c > out || fail=1
grep "$header" out && fail=1
cat out

Exit $fail
