makepkg: guard against undefined git pinned sources

If something like source=(..."#commit=") is used, e.g. due to failed
variable expansion, we try to check out an empty refspec as nothing at
all, and end up just running "git checkout". This happens because we
fail at variable expansion too -- so let's quote our variables properly
and make sure git sees this as an empty refspec, so it can error out.

Also make sure it is interpreted as a ref instead of a path.

Signed-off-by: Eli Schwartz <eschwartz@archlinux.org>
Signed-off-by: Allan McRae <allan@archlinux.org>
(cherry picked from commit 817f9fb715)
This commit is contained in:
Eli Schwartz 2020-05-25 23:52:16 -04:00 committed by Andrew Gregory
parent 12503767c0
commit d69da08abe

View file

@ -125,7 +125,7 @@ extract_git() {
fi fi
if [[ $ref != "origin/HEAD" ]] || (( updating )) ; then if [[ $ref != "origin/HEAD" ]] || (( updating )) ; then
if ! git checkout --force --no-track -B makepkg $ref; then if ! git checkout --force --no-track -B makepkg "$ref" --; then
error "$(gettext "Failure while creating working copy of %s %s repo")" "${repo}" "git" error "$(gettext "Failure while creating working copy of %s %s repo")" "${repo}" "git"
plain "$(gettext "Aborting...")" plain "$(gettext "Aborting...")"
exit 1 exit 1