diff options
author | Kirill Elagin <kirelagin@gmail.com> | 2012-06-07 18:01:07 +0400 |
---|---|---|
committer | Eelco Dolstra <eelco.dolstra@logicblox.com> | 2012-06-20 23:28:53 -0400 |
commit | 1be62b87fe15821d0513ded1bf9e7fae37819874 (patch) | |
tree | adf6517d464e752c00e02e1f49a4a2c38650fa4c /pkgs/build-support/fetchgit/nix-prefetch-git | |
parent | ba766ebcf41236d5d46d849d10fa7579fc7403b0 (diff) |
Handle invalid references
Diffstat (limited to 'pkgs/build-support/fetchgit/nix-prefetch-git')
-rwxr-xr-x | pkgs/build-support/fetchgit/nix-prefetch-git | 6 |
1 files changed, 2 insertions, 4 deletions
diff --git a/pkgs/build-support/fetchgit/nix-prefetch-git b/pkgs/build-support/fetchgit/nix-prefetch-git index e5ee43a138c0..00cd7d3129b3 100755 --- a/pkgs/build-support/fetchgit/nix-prefetch-git +++ b/pkgs/build-support/fetchgit/nix-prefetch-git @@ -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 |