#!/bin/sh

# full paths from the repo root separated by newlines
MUST_NOT_CHANGE='js/canvas-to-blob.min.js
js/jquery.cloudinary.js
js/jquery.fileupload.js
js/jquery.fileupload-image.js
js/jquery.fileupload-process.js
js/jquery.fileupload-validate.js
js/jquery.iframe-transport.js
js/load-image.all.min.js
js/README.md
'

if git rev-parse --verify HEAD >/dev/null 2>&1
then
  against=HEAD
else
  # Initial commit: diff against an empty tree object
  against=4b825dc642cb6eb9a060e54bf8d69288fbee4904
fi

exec 1>&2

if git diff --cached --name-only $against |
   grep --quiet --line-regexp --fixed-strings "$MUST_NOT_CHANGE"
then
  echo Commit would modify one or more files from the /js folder, that must not change.
  exit 1
else
  echo Commit is ok! it did not modify files from the /js folder, that must not change.
  exit 0
fi
