#!/usr/bin/env bash

# For issue588, "amend-record --look-for-adds end up with two "addfile" entries"

set -ev

test $DARCS || DARCS=$PWD/../darcs
ACTUAL_DARCS=`which $DARCS`
DARCSPATH=`dirname $ACTUAL_DARCS`
PATH="$DARCSPATH:$PATH"
export PATH

rm -rf temp1
$DARCS init --repodir temp1

export EMAIL=me

cd temp1

date > f
$DARCS add f
$DARCS rec -am p1
for (( i=0 ; i < 500; i=i+1 )); do
  echo $i >> f;
  $DARCS rec -am p$i
done

$DARCS changes 2> err | head

touch correcterr

diff correcterr err

cd ..

rm -rf temp1
