Use 'pack' lines in manifest for packs (REPO FORMAT CHANGE)
This commit is contained in:
parent
12cd4c92d6
commit
949ebdc92a
1 changed files with 24 additions and 23 deletions
|
@ -125,6 +125,8 @@ make_new_repo()
|
||||||
|
|
||||||
ensure_connected()
|
ensure_connected()
|
||||||
{
|
{
|
||||||
|
local MANIFESTDATA
|
||||||
|
|
||||||
if [ ! -z "$DID_CONNECT" ]
|
if [ ! -z "$DID_CONNECT" ]
|
||||||
then
|
then
|
||||||
return
|
return
|
||||||
|
@ -132,6 +134,8 @@ ensure_connected()
|
||||||
DID_CONNECT=1
|
DID_CONNECT=1
|
||||||
MASTERKEY="$(get_masterkey)"
|
MASTERKEY="$(get_masterkey)"
|
||||||
MANIFESTDATA="$(GET_OR_EMPTY "$URL" manifest | DECRYPT)"
|
MANIFESTDATA="$(GET_OR_EMPTY "$URL" manifest | DECRYPT)"
|
||||||
|
BRANCHLIST=$(printf "%s\n" "$MANIFESTDATA" | (grep -v '^pack ' || :))
|
||||||
|
PACKLIST=$(printf "%s\n" "$MANIFESTDATA" | (grep '^pack ' || :))
|
||||||
}
|
}
|
||||||
|
|
||||||
get_masterkey()
|
get_masterkey()
|
||||||
|
@ -153,7 +157,7 @@ do_list()
|
||||||
local REFNAME
|
local REFNAME
|
||||||
ensure_connected
|
ensure_connected
|
||||||
|
|
||||||
printf "%s\n" "$MANIFESTDATA" | while read LINE
|
printf "%s\n" "$BRANCHLIST" | while read LINE
|
||||||
do
|
do
|
||||||
OBJID=${LINE%% *}
|
OBJID=${LINE%% *}
|
||||||
REFNAME=${LINE##* }
|
REFNAME=${LINE##* }
|
||||||
|
@ -172,17 +176,14 @@ do_fetch()
|
||||||
{
|
{
|
||||||
# Security protocol:
|
# Security protocol:
|
||||||
# The PACK id is the SHA-1 of the encrypted git packfile.
|
# The PACK id is the SHA-1 of the encrypted git packfile.
|
||||||
# We only download packs mentioned in the encrypted 'packfest',
|
# We only download packs mentioned in the encrypted manifest,
|
||||||
# and check their digest when received.
|
# and check their digest when received.
|
||||||
local PNEED
|
local PNEED
|
||||||
local PREMOTE
|
|
||||||
local PBOTH
|
local PBOTH
|
||||||
local PHAVE
|
local PHAVE
|
||||||
ensure_connected
|
ensure_connected
|
||||||
|
|
||||||
touch "$LOCALDIR/packfest"
|
if [ -z "$PACKLIST" ]
|
||||||
PREMOTE="$(GET_OR_EMPTY "$URL" packfest | DECRYPT)"
|
|
||||||
if [ -z "$PREMOTE" ]
|
|
||||||
then
|
then
|
||||||
echo # end with blank line
|
echo # end with blank line
|
||||||
exit 0
|
exit 0
|
||||||
|
@ -192,12 +193,13 @@ do_fetch()
|
||||||
trap 'rm -f "$TMPPACK_ENCRYPTED"' EXIT
|
trap 'rm -f "$TMPPACK_ENCRYPTED"' EXIT
|
||||||
|
|
||||||
# Needed packs is REMOTE - (HAVE & REMOTE)
|
# Needed packs is REMOTE - (HAVE & REMOTE)
|
||||||
PHAVE="$(cat "$LOCALDIR/packfest")"
|
PHAVE="$(cat "$LOCALDIR/have_packs" || :)"
|
||||||
PBOTH="$(printf "%s\n%s" "$PREMOTE" "$PHAVE" | sort | uniq -d)"
|
PBOTH="$(printf "%s\n%s" "$PACKLIST" "$PHAVE" | sort | uniq -d)"
|
||||||
PNEED="$(printf "%s\n%s" "$PREMOTE" "$PBOTH" | sort | uniq -u)"
|
PNEED="$(printf "%s\n%s" "$PACKLIST" "$PBOTH" | sort | uniq -u)"
|
||||||
|
|
||||||
printf "%s\n" "$PNEED" | while read PACK
|
printf "%s\n" "$PNEED" | while read PACKLINE
|
||||||
do
|
do
|
||||||
|
PACK=${PACKLINE#pack }
|
||||||
RCVID="$(GET "$URL" "$PACK" | tee "$TMPPACK_ENCRYPTED" | sha1)"
|
RCVID="$(GET "$URL" "$PACK" | tee "$TMPPACK_ENCRYPTED" | sha1)"
|
||||||
if [ "$RCVID" != "$PACK" ]
|
if [ "$RCVID" != "$PACK" ]
|
||||||
then
|
then
|
||||||
|
@ -207,7 +209,7 @@ do_fetch()
|
||||||
DECRYPT < "$TMPPACK_ENCRYPTED" | git unpack-objects
|
DECRYPT < "$TMPPACK_ENCRYPTED" | git unpack-objects
|
||||||
|
|
||||||
# add to local pack list
|
# add to local pack list
|
||||||
printf "%s\n" "$PACK" >> "$LOCALDIR/packfest"
|
printf "pack %s\n" "$PACK" >> "$LOCALDIR/have_packs"
|
||||||
done
|
done
|
||||||
|
|
||||||
rm -f "$TMPPACK_ENCRYPTED"
|
rm -f "$TMPPACK_ENCRYPTED"
|
||||||
|
@ -220,11 +222,11 @@ do_push()
|
||||||
{
|
{
|
||||||
# Security protocol:
|
# Security protocol:
|
||||||
# Each git packfile is encrypted and then named for the encrypted
|
# Each git packfile is encrypted and then named for the encrypted
|
||||||
# file's SHA-1. `packfest` is updated with the pack id.
|
# file's SHA-1. The manifest is updated with the pack id.
|
||||||
# The packfest and manifest are encrypted.
|
# The manifest is encrypted.
|
||||||
local REMOTEHAS
|
local REMOTEHAS
|
||||||
local REMOTEWANT
|
local REMOTEWANT
|
||||||
local PACKFEST
|
local MANIFESTDATA
|
||||||
local prefix_
|
local prefix_
|
||||||
local suffix_
|
local suffix_
|
||||||
ensure_connected
|
ensure_connected
|
||||||
|
@ -237,10 +239,10 @@ do_push()
|
||||||
trap 'rm -f "$TMPMANIFEST" "$TMPPACK_ENCRYPTED" "$TMPOBJLIST"' EXIT
|
trap 'rm -f "$TMPMANIFEST" "$TMPPACK_ENCRYPTED" "$TMPOBJLIST"' EXIT
|
||||||
TMPMANIFEST="$LOCALDIR/tmp_new_manifest_.$$"
|
TMPMANIFEST="$LOCALDIR/tmp_new_manifest_.$$"
|
||||||
touch "$TMPMANIFEST"
|
touch "$TMPMANIFEST"
|
||||||
if [ ! -z "$MANIFESTDATA" ]
|
if [ ! -z "$BRANCHLIST" ]
|
||||||
then
|
then
|
||||||
printf "%s\n" "$MANIFESTDATA" > "$TMPMANIFEST"
|
printf "%s\n" "$BRANCHLIST" >"$TMPMANIFEST"
|
||||||
REMOTEHAS="$(printf "%s" "$MANIFESTDATA" | \
|
REMOTEHAS="$(printf "%s" "$BRANCHLIST" | \
|
||||||
cut -f1 -d' ' | sed -e s/^/^/ | tr '\n' ' ')"
|
cut -f1 -d' ' | sed -e s/^/^/ | tr '\n' ' ')"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -257,7 +259,7 @@ do_push()
|
||||||
done)"
|
done)"
|
||||||
|
|
||||||
# POSIX compat issue: sort -s (stable), but supported in bsd and gnu
|
# POSIX compat issue: sort -s (stable), but supported in bsd and gnu
|
||||||
MANIFESTDATA="$(sort -k2 -s "$TMPMANIFEST" | tac | uniq -s40)"
|
BRANCHLIST="$(sort -k2 -s "$TMPMANIFEST" | tac | uniq -s40)"
|
||||||
|
|
||||||
TMPPACK_ENCRYPTED="$LOCALDIR/tmp_pack_ENCRYPTED_.$$"
|
TMPPACK_ENCRYPTED="$LOCALDIR/tmp_pack_ENCRYPTED_.$$"
|
||||||
TMPOBJLIST="$LOCALDIR/tmp_packrevlist.$$"
|
TMPOBJLIST="$LOCALDIR/tmp_packrevlist.$$"
|
||||||
|
@ -268,18 +270,17 @@ do_push()
|
||||||
if [ -s "$TMPOBJLIST" ]
|
if [ -s "$TMPOBJLIST" ]
|
||||||
then
|
then
|
||||||
PACKID=$(sha1 < "$TMPPACK_ENCRYPTED")
|
PACKID=$(sha1 < "$TMPPACK_ENCRYPTED")
|
||||||
PACKFEST="$(GET_OR_EMPTY "$URL" packfest | DECRYPT)"
|
if [ -z "$PACKLIST" ]
|
||||||
if [ -z "$PACKFEST" ]
|
|
||||||
then
|
then
|
||||||
PACKFEST="$(printf "%s\n" "$PACKID")"
|
PACKLIST="$(printf "pack %s\n" "$PACKID")"
|
||||||
else
|
else
|
||||||
PACKFEST="$(printf "%s\n%s\n" "$PACKFEST" "$PACKID")"
|
PACKLIST="$(printf "%s\npack %s\n" "$PACKLIST" "$PACKID")"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
PUT "$URL" "$PACKID" < "$TMPPACK_ENCRYPTED"
|
PUT "$URL" "$PACKID" < "$TMPPACK_ENCRYPTED"
|
||||||
printf "%s\n" "$PACKFEST" | ENCRYPT | PUT "$URL" "packfest"
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
MANIFESTDATA=$(printf "%s\n%s\n" "$BRANCHLIST" "$PACKLIST")
|
||||||
printf "%s\n" "$MANIFESTDATA" | ENCRYPT | PUT "$URL" "manifest"
|
printf "%s\n" "$MANIFESTDATA" | ENCRYPT | PUT "$URL" "manifest"
|
||||||
|
|
||||||
# ok all updates (not deletes)
|
# ok all updates (not deletes)
|
||||||
|
|
Loading…
Reference in a new issue