#!/bin/sh
# test for a bug in the symlinked ChangeLog feature.
# Before, vc-dwim would insert a line like SCALAR(0xb1d360)
# in the commit log.

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

require_git_

touch f || framework_failure_
( git init && git add . && git commit -m m . ) || framework_failure_
mkdir .git/c || framework_failure_
cat <<EOF >> .git/c/ChangeLog || framework_failure_
2006-09-04  Jo R. User  <random@example.com>

	sum:X
	* f: ..

	sum:0
	* f: other.

2006-09-03  Jo R. User  <random@example.com>

	sum:g
	* g: Y.
EOF
ln -s .git/c/ChangeLog . || framework_failure_
( cd .git/c && git init && git add . && git commit -m m . ) || framework_failure_

perl -pi -e '/X/ and print "\t* f: new\n";' \
         -e '/Y/ and print "\tgah\n"' .git/c/ChangeLog || framework_failure_
echo >> f || framework_failure_

fail=0

vc-dwim --c || fail=1

git log -1 --pretty=format:%b > log || fail=1

# Before the fix, this would contain SCALAR(0x......)
test "$(cat log)" = gah || fail=1

Exit $fail
