forked from mirrors/nixpkgs
nix-prefetch-git: whitespace cleanup
Use 4 spaces per indent level instead of a mix of 2 spaces, 4 spaces and hardtab. (According to nixpkgs coding style for shell scripts.)
This commit is contained in:
parent
12e26d47b7
commit
8ec8358724
|
@ -10,51 +10,51 @@ fetchSubmodules=
|
||||||
builder=
|
builder=
|
||||||
|
|
||||||
if test -n "$deepClone"; then
|
if test -n "$deepClone"; then
|
||||||
deepClone=true
|
deepClone=true
|
||||||
else
|
else
|
||||||
deepClone=false
|
deepClone=false
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if test "$leaveDotGit" != 1; then
|
if test "$leaveDotGit" != 1; then
|
||||||
leaveDotGit=
|
leaveDotGit=
|
||||||
else
|
else
|
||||||
leaveDotGit=true
|
leaveDotGit=true
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
argi=0
|
argi=0
|
||||||
argfun=""
|
argfun=""
|
||||||
for arg; do
|
for arg; do
|
||||||
if test -z "$argfun"; then
|
if test -z "$argfun"; then
|
||||||
case $arg in
|
case $arg in
|
||||||
--out) argfun=set_out;;
|
--out) argfun=set_out;;
|
||||||
--url) argfun=set_url;;
|
--url) argfun=set_url;;
|
||||||
--rev) argfun=set_rev;;
|
--rev) argfun=set_rev;;
|
||||||
--hash) argfun=set_hashType;;
|
--hash) argfun=set_hashType;;
|
||||||
--deepClone) deepClone=true;;
|
--deepClone) deepClone=true;;
|
||||||
--no-deepClone) deepClone=false;;
|
--no-deepClone) deepClone=false;;
|
||||||
--leave-dotGit) leaveDotGit=true;;
|
--leave-dotGit) leaveDotGit=true;;
|
||||||
--fetch-submodules) fetchSubmodules=true;;
|
--fetch-submodules) fetchSubmodules=true;;
|
||||||
--builder) builder=true;;
|
--builder) builder=true;;
|
||||||
*)
|
*)
|
||||||
argi=$(($argi + 1))
|
argi=$(($argi + 1))
|
||||||
case $argi in
|
case $argi in
|
||||||
1) url=$arg;;
|
1) url=$arg;;
|
||||||
2) rev=$arg;;
|
2) rev=$arg;;
|
||||||
3) expHash=$arg;;
|
3) expHash=$arg;;
|
||||||
*) exit 1;;
|
*) exit 1;;
|
||||||
esac
|
esac
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
else
|
else
|
||||||
case $argfun in
|
case $argfun in
|
||||||
set_*)
|
set_*)
|
||||||
var=$(echo $argfun | sed 's,^set_,,')
|
var=$(echo $argfun | sed 's,^set_,,')
|
||||||
eval $var=$arg
|
eval $var=$arg
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
argfun=""
|
argfun=""
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
usage(){
|
usage(){
|
||||||
|
@ -75,7 +75,7 @@ Options:
|
||||||
}
|
}
|
||||||
|
|
||||||
if test -z "$url"; then
|
if test -z "$url"; then
|
||||||
usage
|
usage
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
@ -116,11 +116,11 @@ checkout_ref(){
|
||||||
local ref="$2";
|
local ref="$2";
|
||||||
|
|
||||||
if "$deepClone"; then
|
if "$deepClone"; then
|
||||||
# The caller explicitly asked for a deep clone. Deep clones
|
# The caller explicitly asked for a deep clone. Deep clones
|
||||||
# allow "git describe" and similar tools to work. See
|
# allow "git describe" and similar tools to work. See
|
||||||
# http://thread.gmane.org/gmane.linux.distributions.nixos/3569
|
# http://thread.gmane.org/gmane.linux.distributions.nixos/3569
|
||||||
# for a discussion.
|
# for a discussion.
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if test -z "$ref"; then
|
if test -z "$ref"; then
|
||||||
|
@ -154,7 +154,7 @@ init_submodules(){
|
||||||
|
|
||||||
# Get Absolute URL if we have a relative URL
|
# Get Absolute URL if we have a relative URL
|
||||||
if ! echo "$url" | grep '^[a-zA-Z]\+://' >/dev/null 2>&1; then
|
if ! echo "$url" | grep '^[a-zA-Z]\+://' >/dev/null 2>&1; then
|
||||||
url="$(git config --get remote.origin.url)/$url"
|
url="$(git config --get remote.origin.url)/$url"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
clone "$dir" "$url" "$hash" "";
|
clone "$dir" "$url" "$hash" "";
|
||||||
|
@ -186,14 +186,14 @@ clone(){
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -z "$builder" -a -f .topdeps ]; then
|
if [ -z "$builder" -a -f .topdeps ]; then
|
||||||
if tg help 2>&1 > /dev/null
|
if tg help 2>&1 > /dev/null
|
||||||
then
|
then
|
||||||
echo "populating TopGit branches..."
|
echo "populating TopGit branches..."
|
||||||
tg remote --populate origin
|
tg remote --populate origin
|
||||||
else
|
else
|
||||||
echo "WARNING: would populate TopGit branches but TopGit is not available" >&2
|
echo "WARNING: would populate TopGit branches but TopGit is not available" >&2
|
||||||
echo "WARNING: install TopGit to fix the problem" >&2
|
echo "WARNING: install TopGit to fix the problem" >&2
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
cd $top;
|
cd $top;
|
||||||
|
@ -224,7 +224,7 @@ clone_user_rev() {
|
||||||
# Allow doing additional processing before .git removal
|
# Allow doing additional processing before .git removal
|
||||||
eval "$NIX_PREFETCH_GIT_CHECKOUT_HOOK"
|
eval "$NIX_PREFETCH_GIT_CHECKOUT_HOOK"
|
||||||
if test -z "$leaveDotGit"; then
|
if test -z "$leaveDotGit"; then
|
||||||
echo "removing \`.git'..." >&2
|
echo "removing \`.git'..." >&2
|
||||||
find $dir -name .git\* | xargs rm -rf
|
find $dir -name .git\* | xargs rm -rf
|
||||||
else
|
else
|
||||||
# The logs and index contain timestamps, and the hooks contain
|
# The logs and index contain timestamps, and the hooks contain
|
||||||
|
@ -234,55 +234,55 @@ clone_user_rev() {
|
||||||
}
|
}
|
||||||
|
|
||||||
if test -n "$builder"; then
|
if test -n "$builder"; then
|
||||||
test -n "$out" -a -n "$url" -a -n "$rev" || usage
|
test -n "$out" -a -n "$url" -a -n "$rev" || usage
|
||||||
mkdir $out
|
mkdir $out
|
||||||
clone_user_rev "$out" "$url" "$rev"
|
clone_user_rev "$out" "$url" "$rev"
|
||||||
else
|
else
|
||||||
if test -z "$hashType"; then
|
if test -z "$hashType"; then
|
||||||
hashType=sha256
|
hashType=sha256
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# If the hash was given, a file with that hash may already be in the
|
# If the hash was given, a file with that hash may already be in the
|
||||||
# store.
|
# store.
|
||||||
if test -n "$expHash"; then
|
if test -n "$expHash"; then
|
||||||
finalPath=$(nix-store --print-fixed-path --recursive "$hashType" "$expHash" git-export)
|
finalPath=$(nix-store --print-fixed-path --recursive "$hashType" "$expHash" git-export)
|
||||||
if ! nix-store --check-validity "$finalPath" 2> /dev/null; then
|
if ! nix-store --check-validity "$finalPath" 2> /dev/null; then
|
||||||
finalPath=
|
finalPath=
|
||||||
fi
|
fi
|
||||||
hash=$expHash
|
hash=$expHash
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# If we don't know the hash or a path with that hash doesn't exist,
|
# 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.
|
# download the file and add it to the store.
|
||||||
if test -z "$finalPath"; then
|
if test -z "$finalPath"; then
|
||||||
|
|
||||||
tmpPath="$(mktemp -d "${TMPDIR:-/tmp}/git-checkout-tmp-XXXXXXXX")"
|
tmpPath="$(mktemp -d "${TMPDIR:-/tmp}/git-checkout-tmp-XXXXXXXX")"
|
||||||
trap "rm -rf \"$tmpPath\"" EXIT
|
trap "rm -rf \"$tmpPath\"" EXIT
|
||||||
|
|
||||||
tmpFile="$tmpPath/git-export"
|
tmpFile="$tmpPath/git-export"
|
||||||
mkdir "$tmpFile"
|
mkdir "$tmpFile"
|
||||||
|
|
||||||
# Perform the checkout.
|
# Perform the checkout.
|
||||||
clone_user_rev "$tmpFile" "$url" "$rev"
|
clone_user_rev "$tmpFile" "$url" "$rev"
|
||||||
|
|
||||||
# Compute the hash.
|
# Compute the hash.
|
||||||
hash=$(nix-hash --type $hashType $hashFormat $tmpFile)
|
hash=$(nix-hash --type $hashType $hashFormat $tmpFile)
|
||||||
if ! test -n "$QUIET"; then echo "hash is $hash" >&2; fi
|
if ! test -n "$QUIET"; then echo "hash is $hash" >&2; fi
|
||||||
|
|
||||||
# Add the downloaded file to the Nix store.
|
# Add the downloaded file to the Nix store.
|
||||||
finalPath=$(nix-store --add-fixed --recursive "$hashType" $tmpFile)
|
finalPath=$(nix-store --add-fixed --recursive "$hashType" $tmpFile)
|
||||||
|
|
||||||
if test -n "$expHash" -a "$expHash" != "$hash"; then
|
if test -n "$expHash" -a "$expHash" != "$hash"; then
|
||||||
echo "hash mismatch for URL \`$url'"
|
echo "hash mismatch for URL \`$url'"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if ! test -n "$QUIET"; then echo "path is $finalPath" >&2; fi
|
if ! test -n "$QUIET"; then echo "path is $finalPath" >&2; fi
|
||||||
|
|
||||||
echo $hash
|
echo $hash
|
||||||
|
|
||||||
if test -n "$PRINT_PATH"; then
|
if test -n "$PRINT_PATH"; then
|
||||||
echo $finalPath
|
echo $finalPath
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
Loading…
Reference in a new issue