#!/usr/bin/env bash

. "$(dirname "$0")/testlib.sh"

begin_test "does not look in current directory for git"
(
  set -e

  reponame="$(basename "$0" ".sh")"
  git init "$reponame"
  cd "$reponame"
  export PATH="$(echo "$PATH" | sed -e "s/:.:/:/g" -e "s/::/:/g")"

  printf "#!/bin/sh\necho exploit >&2\n" > git
  chmod +x git || true
  printf "echo exploit 1>&2\n" > git.bat

  # This needs to succeed.  If it fails, that could be because our malicious
  # "git" is broken but got invoked anyway.
  git lfs env > output.log 2>&1
  ! grep -q 'exploit' output.log
)
end_test
