#!/bin/sh -e
# Copyright © 2020 Miguel Ángel Arruga Vivas <rosen644835@gmail.com>
# Copying and distribution of this file, with or without modification, are
# permitted in any medium without royalty provided the copyright notice and
# this notice are preserved.

add_history () {
    echo 'First line' > file
    git add file
    git commit -m 'first commit'
    echo 'Second line' >> file
    git add file
    git commit -m 'second commit'
}

tempdir="$(mktemp -d)"
trap "cd && rm -rf '${tempdir}'" EXIT
cd "${tempdir}"
git init p1
cd p1
echo '((nil . ((eval . (message "Eval called")))))' > .dir-locals.el
git add .dir-locals.el
add_history
git init ../p2
cd ../p2
add_history
cd ..

echo 'C-x C-f p1/file -> press !
C-x v l
C-h v file-local-variables-alist (contains eval message?)
C-x o
C-x C-f ../p2/file
C-x v l
C-h v file-local-variables-alist (still contains eval message?)' > README

emacs -Q README
cd
rm -rf "${tempdir}"
exit 0
