Revert nix-prefetch-git changes merged in earlier from Merge request #3, which broke git describe functionality used in GNU jobsets.
[?]
Apr 26, 2012, 7:31 AM
EEZ6UXWN42MNOBLWH43DXWDYRMLFCFLAIVLNOEFNWLCS5KIHS2UACDependencies
- [2]
HE3GX5IPOptimize fetch-git. - [3]
KX5L74EYadd nix-prefetch- scripts for now, were externals in svn
Change contents
- replacement in src/script/nix-prefetch-git at line 1[3.1944]→[3.1945:3302](∅→∅),[3.3302]→[2.3595:3712](∅→∅),[2.3712]→[3.3401:4665](∅→∅),[3.3401]→[3.3401:4665](∅→∅),[3.4665]→[2.3713:3991](∅→∅),[2.3991]→[3.4675:6957](∅→∅),[3.4675]→[3.4675:6957](∅→∅),[3.6957]→[2.3992:4044](∅→∅),[2.4044]→[3.6989:8025](∅→∅),[3.6989]→[3.6989:8025](∅→∅),[3.8025]→[2.4045:4097](∅→∅),[2.4097]→[3.8088:8352](∅→∅),[3.8088]→[3.8088:8352](∅→∅),[3.8352]→[2.4098:4150](∅→∅),[2.4150]→[3.8416:8494](∅→∅),[3.8416]→[3.8416:8494](∅→∅)
#! /bin/sh -eurl=$1rev=$2expHash=$3hashType=$NIX_HASH_ALGOdeepClone=$NIX_PREFETCH_GIT_DEEP_CLONEleaveDotGit=$NIX_PREFETCH_GIT_LEAVE_DOT_GITbuilder=if test -n "$deepClone"; thendeepClone=trueelsedeepClone=falsefiif test "$leaveDotGit" != 1; thenleaveDotGit=elseleaveDotGit=truefiargi=0argfun=""for arg; doif test -z "$argfun"; thencase $arg in--out) argfun=set_out;;--url) argfun=set_url;;--rev) argfun=set_rev;;--hash) argfun=set_hashType;;--deepClone) deepClone=true;;--no-deepClone) deepClone=false;;--leave-dotGit) leaveDotGit=true;;--builder) builder=true;;*)argi=$(($argi + 1))case $argi in1) url=$arg;;2) rev=$arg;;3) expHash=$arg;;*) exit 1;;esac;;esacelsecase $argfun inset_*)var=$(echo $argfun | sed 's,^set_,,')eval $var=$arg;;esacargfun=""fidoneusage(){echo >&2 "syntax: nix-prefetch-git [options] [URL [REVISION [EXPECTED-HASH]]]Options:--out path Path where the output would be stored.--url url Any url understand by 'git clone'.--rev ref Any sha1 or references (such as refs/heads/master)--hash h Expected hash.--deepClone Clone history until a tag is found as parent.--no-deepClone Clone the minimum history.--leave-dotGit Keep the .git directories.--builder Clone as fetchgit does, but url, rev, and out option are mandatory."exit 1}if test -z "$url"; thenusagefiinit_remote(){local url=$1;git init;git remote add origin $url;}# Return the reference of an hash if it exists on the remote repository.ref_from_hash(){local hash=$1;git ls-remote origin | sed -n "\,$hash\t, { s,\(.*\)\t\(.*\),\2,; p; q}"}# Return the hash of a reference if it exists on the remote repository.hash_from_ref(){local ref=$1git ls-remote origin | sed -n "\,\t$ref, { s,\(.*\)\t\(.*\),\1,; p; q}"}# Fetch everything and checkout the right sha1checkout_hash(){local hash="$1";local ref="$2";if test -z "$hash"; thenhash=$(hash_from_ref $ref);fi;git fetch ${builder:+--progress} origin || return 1git checkout -b fetchgit $hash || return 1}# Fetch only a branch/tag and checkout it.checkout_ref(){local hash="$1";local ref="$2";if "$deepClone"; then# The caller explicitly asked for a deep clone. Deep clones# allow "git describe" and similar tools to work. See# http://thread.gmane.org/gmane.linux.distributions.nixos/3569# for a discussion.# To make git describe works, we need to fetch all tags.if git fetch -t ${builder:+--progress} --depth 1 origin; thenreturn 1else# There is no tag, don't try to recover git-describe mechanism.deepClone=falsefifiif test -z "$ref"; thenref=$(ref_from_hash $hash);fi;if test -n "$ref"; then# --depth option is ignored on http repository.git fetch ${builder:+--progress} --depth 1 origin +"$ref" || return 1git checkout -b fetchgit FETCH_HEAD || return 1elsereturn 1;fi;}# Update submodulesinit_submodules(){# Add urls into .git/config filegit submodule init# list submodule directories and their hashesgit submodule status |while read l; do# checkout each submodulelocal hash=$(echo $l | sed 's,^-\([0-9a-f]*\) \(.*\)$,\1,');local dir=$(echo $l | sed 's,^-\([0-9a-f]*\) \(.*\)$,\2,');local url=$(sed -n "\,$dir, { :loop; n; s,^.*url = ,,; T loop; p; q }" .git/config);clone "$dir" "$url" "$hash" "";done;}clone(){local top=$(pwd)local dir="$1"local url="$2"local hash="$3"local ref="$4"cd $dir;# Initialize the repository.init_remote "$url";# Download data from the repository.checkout_ref "$hash" "$ref" ||checkout_hash "$hash" "$ref" || (echo 1>&2 "Unable to checkout $hash$ref from $url.";exit 1;)# Checkout linked sources.init_submodules;if [ -z "$builder" -a -f .topdeps ]; thenif tg help 2>&1 > /dev/nullthenecho "populating TopGit branches..."tg remote --populate originelseecho "WARNING: would populate TopGit branches but TopGit is not available" >&2echo "WARNING: install TopGit to fix the problem" >&2fificd $top;}clone_user_rev() {local dir="$1"local url="$2"local rev="$3"# Perform the checkout.case "$rev" inHEAD|refs/*)clone "$dir" "$url" "" "$rev" 1>&2;;[0-9a-f]*)if test -z "$(echo $rev | tr -d 0123456789abcdef)"; thenclone "$dir" "$url" "$rev" "" 1>&2;elseecho 1>&2 "Bad commit hash or bad reference.";exit 1;fi;;"")clone "$dir" "$url" "" "HEAD" 1>&2;;esac# Allow doing additional processing before .git removaleval "$NIX_PREFETCH_GIT_CHECKOUT_HOOK"if test -z "$leaveDotGit"; thentest -n "$QUIET" || echo "removing \`.git'..." >&2find $dir -name .git\* | xargs rm -rffi}if test -n "$builder"; thentest -n "$out" -a -n "$url" -a -n "$rev" || usagemkdir $outclone_user_rev "$out" "$url" "$rev"elseif test -z "$hashType"; thenhashType=sha256fi# If the hash was given, a file with that hash may already be in the# store.if test -n "$expHash"; thenfinalPath=$(nix-store --print-fixed-path --recursive "$hashType" "$expHash" git-export)if ! nix-store --check-validity "$finalPath" 2> /dev/null; thenfinalPath=fihash=$expHashfi# If we don't know the hash or a path with that hash doesn't exist,# download the file and add it to the store.if test -z "$finalPath"; thentmpPath=/tmp/git-checkout-tmp-$$tmpFile=$tmpPath/git-exportmkdir $tmpPath $tmpFiletrap "rm -rf $tmpPath" EXIT# Perform the checkout.clone_user_rev "$tmpFile" "$url" "$rev"# Compute the hash.hash=$(nix-hash --type $hashType $hashFormat $tmpFile)test -n "$QUIET" || echo "hash is $hash" >&2;# Add the downloaded file to the Nix store.finalPath=$(nix-store --add-fixed --recursive "$hashType" $tmpFile)if test -n "$expHash" -a "$expHash" != "$hash"; thenecho "hash mismatch for URL \`$url'"exit 1fifitest -n "$QUIET" || echo "path is $finalPath" >&2echo $hashif test -n "$PRINT_PATH"; thenecho $finalPathfifi[3.1944]<html><body>You are being <a href="https://raw.github.com/NixOS/hydra/966cc2213117c15a6b09d2c4e179b0929cff3023/src/script/nix-prefetch-git">redirected</a>.</body></html>