#!/usr/bin/env bash

set -ev
test $DARCS || DARCS=$PWD/../darcs

rm -rf temp1

mkdir temp1
cd temp1
$DARCS init
echo -e 'foo\nbar\nbaz' > f
$DARCS rec -Ax -alm p1
echo -e 'foo\nbar\nwibble' > f
$DARCS rec -Ax -alm p2
sleep 1 # ensure the timestamps would differ after this change alone
echo -e 'baz\nbar\nwibble' > f

# unset $HOME to get rid of --ignore-times that is in $HOME/.darcs/defaults
export HOME=

# check that wh (without --ignore-times) sees the change now
$DARCS wh > whatsnew
grep 'foo' whatsnew

# the problematic unpull
$DARCS unpull --last 1 -a --ignore-times

# whatsnew will now think there are no changes without --ignore-times
$DARCS wh > whatsnew
grep 'foo' whatsnew

cd ..
rm -rf temp1
