3
0
Fork 0
forked from mirrors/nixpkgs

Handle invalid references

This commit is contained in:
Kirill Elagin 2012-06-07 18:01:07 +04:00 committed by Eelco Dolstra
parent ba766ebcf4
commit 1be62b87fe

View file

@ -189,21 +189,19 @@ clone(){
clone_user_rev() {
local dir="$1"
local url="$2"
local rev="$3"
local rev="${3:-HEAD}"
# Perform the checkout.
case "$rev" in
HEAD|refs/*)
clone "$dir" "$url" "" "$rev" 1>&2;;
[0-9a-f]*)
*)
if test -z "$(echo $rev | tr -d 0123456789abcdef)"; then
clone "$dir" "$url" "$rev" "" 1>&2;
else
echo 1>&2 "Bad commit hash or bad reference.";
exit 1;
fi;;
"")
clone "$dir" "$url" "" "HEAD" 1>&2;;
esac
# Allow doing additional processing before .git removal