remove splitcolon use

This commit is contained in:
root 2013-02-14 19:48:46 +03:00
parent a7f381143e
commit 3cddb977c4

View file

@ -17,7 +17,6 @@ Gref="refs/gcrypt/gitception$GITCEPTION"
Gref_rbranch="refs/heads/master" Gref_rbranch="refs/heads/master"
Packkey_bytes=33 # 33 random bytes for passphrase, still compatible if changed Packkey_bytes=33 # 33 random bytes for passphrase, still compatible if changed
Hashtype=SHA256 # SHA512 SHA384 SHA256 SHA224 supported. Hashtype=SHA256 # SHA512 SHA384 SHA256 SHA224 supported.
Packpat="pack :*:"
Manifestfile=91bd0c092128cf2e60e1a608c31e92caf1f9c1595f83f2890ef17c0e4881aa0a Manifestfile=91bd0c092128cf2e60e1a608c31e92caf1f9c1595f83f2890ef17c0e4881aa0a
Hex40="[a-f0-9]" Hex40="[a-f0-9]"
Hex40=$Hex40$Hex40$Hex40$Hex40$Hex40$Hex40$Hex40$Hex40 Hex40=$Hex40$Hex40$Hex40$Hex40$Hex40$Hex40$Hex40$Hex40
@ -81,13 +80,6 @@ append_to()
setvar "$1" "$f_append_tmp_$2" setvar "$1" "$f_append_tmp_$2"
} }
# Split $1 into $2:$3
splitcolon()
{
setvar "$2" "${1%%:*}"
setvar "$3" "${1#*:}"
}
# Pick words from each line # Pick words from each line
# $1 return variable name # $1 return variable name
# $2 input value # $2 input value
@ -559,31 +551,31 @@ get_verify_decrypt_pack()
# $1 destdir (when repack, else "") # $1 destdir (when repack, else "")
get_pack_files() get_pack_files()
{ {
local pack_id= r_pack_key_line= r_htype= r_pack= key_= local pack_id= r_pack_key_line= htype_= pack_= key_=
while read -r _ pack_id # <<here-document while IFS=': ' read -r _ htype_ pack_ # <<here-document
do do
isnonnull "$pack_id" || continue isnonnull "$pack_" || continue
# Get the Packlist line with the key # Get the Packlist line with the key
pack_id=":${htype_}:$pack_"
filter_to @r_pack_key_line "pack $pack_id *" "$Packlist" filter_to @r_pack_key_line "pack $pack_id *" "$Packlist"
key_=${r_pack_key_line#pack "$pack_id" } key_=${r_pack_key_line#pack $pack_id }
splitcolon "${pack_id#:}" @r_htype @r_pack if isnonnull "${pack_##$Hex40*}" ||
if isnonnull "${r_pack##$Hex40*}" || isnoteq "$htype_" SHA256 && isnoteq "$htype_" SHA224 &&
isnoteq "$r_htype" SHA256 && isnoteq "$r_htype" SHA224 && isnoteq "$htype_" SHA384 && isnoteq "$htype_" SHA512
isnoteq "$r_htype" SHA384 && isnoteq "$r_htype" SHA512
then then
echo_die "Packline malformed: $pack_id" echo_die "Packline malformed: $pack_id"
fi fi
get_verify_decrypt_pack "$r_htype" "$r_pack" "$key_" | \ get_verify_decrypt_pack "$htype_" "$pack_" "$key_" | \
if isnull "${1:-}" if isnull "${1:-}"
then then
# add to local pack list # add to local pack list
git index-pack -v --stdin >/dev/null git index-pack -v --stdin >/dev/null
xecho "pack $pack_id" >> "$Localdir/have_packs$GITCEPTION" xecho "pack $pack_id" >> "$Localdir/have_packs$GITCEPTION"
else else
git index-pack -v --stdin "$1/${r_pack}.pack" >/dev/null git index-pack -v --stdin "$1/${pack_}.pack" >/dev/null
fi fi
done done
} }
@ -693,8 +685,8 @@ do_push()
# Each git packfile is encrypted and then named for the encrypted # Each git packfile is encrypted and then named for the encrypted
# file's hash. The manifest is updated with the pack id. # file's hash. The manifest is updated with the pack id.
# The manifest is encrypted. # The manifest is encrypted.
local r_revlist= line_= pack_id= r_pack_id= key_= obj_= \ local r_revlist= pack_id= key_= obj_= src_= dst_= \
r_pack_delete= r_src= r_dst= tmp_encrypted= tmp_objlist= r_pack_delete= tmp_encrypted= tmp_objlist=
ensure_connected ensure_connected
@ -710,18 +702,16 @@ do_push()
safe_git_rev_parse | sed -e 's/^\(.\)/^&/') safe_git_rev_parse | sed -e 's/^\(.\)/^&/')
fi fi
while read line_ # from << while IFS=: read -r src_ dst_ # << +src:dst
do do
# +src:dst -- remove leading + then split at : src_=${src_#+}
splitcolon "${line_#+}" @r_src @r_dst filter_to ! @Refslist "$Hex40 $dst_" "$Refslist"
filter_to ! @Refslist "$Hex40 $r_dst" "$Refslist" if isnonnull "$src_"
if isnonnull "$r_src"
then then
append_to @r_revlist "$r_src" append_to @r_revlist "$src_"
obj_=$(xecho "$r_src" | safe_git_rev_parse) obj_=$(xecho "$src_" | safe_git_rev_parse)
append_to @Refslist "$obj_ $r_dst" append_to @Refslist "$obj_ $dst_"
fi fi
done <<EOF done <<EOF
$1 $1
@ -779,23 +769,23 @@ EOF
# Delete packs # Delete packs
if isnonnull "$r_pack_delete"; then if isnonnull "$r_pack_delete"; then
rm -r -f "$Localdir/pack" rm -r -f "$Localdir/pack"
REMOVE "$URL" "$(xecho "$r_pack_delete" | while read packline_ REMOVE "$URL" "$(xecho "$r_pack_delete" | \
do while IFS=': ' read -r _ _ pack_
isnonnull "$packline_" || continue do
pack_=${packline_#$Packpat} isnonnull "$pack_" || continue
xecho "$pack_" xecho "$pack_"
done)" done)"
fi fi
PUT_FINAL "$URL" PUT_FINAL "$URL"
# ok all updates # ok all updates
xecho "$1" | while read line_ while IFS=: read -r src_ dst_ # << +src:dst
do do
# +src:dst -- remove leading + then split at : echo_git "ok $dst_"
splitcolon "${line_#+}" @r_src @r_dst done <<EOF
echo_git "ok $r_dst" $1
done EOF
echo_git echo_git
} }