diff --git a/scripts/apply-patch b/scripts/apply-patch index ebf7c921d9..54ad1eaf85 100755 --- a/scripts/apply-patch +++ b/scripts/apply-patch @@ -3,6 +3,7 @@ function usage { cat < @@ -50,5 +51,13 @@ function path_components { echo "${n}" } +GIT_ROOT="$(git rev-parse --show-toplevel)" +if [[ "$(pwd)" != "${GIT_ROOT}" ]]; then + echo "ERROR: Script has not been run from the repository root ('${GIT_ROOT}')." + echo "Please move to the root directory and re-run the script." + + exit 1 +fi + git diff "${COMMIT}" -- "${SRC}" > "${PATCH}" git apply -p "$(path_components "${SRC}")" --directory "${DST}" "${PATCH}"