This commit is contained in:
Joey Hess 2024-04-26 12:53:53 -04:00
parent 6ff4300bd1
commit 99491f572f
No known key found for this signature in database
GPG key ID: DB12DB0FF05F8F38

View file

@ -1,5 +1,7 @@
#!/bin/sh #!/bin/sh
TOPDIR=..
set -x set -x
# remember the refs that were uploaded already # remember the refs that were uploaded already
@ -34,16 +36,16 @@ while read foo; do
echo echo
;; ;;
list*) list*)
if [ -e "MANIFEST" ]; then if [ -e "$TOPDIR/MANIFEST" ]; then
# Only list the refs in the last bundle # Only list the refs in the last bundle
# listed in the manifest. Each push # listed in the manifest. Each push
# includes all refs in its bundle. # includes all refs in its bundle.
f=$(tail -n 1 MANIFEST) f=$(tail -n 1 $TOPDIR/MANIFEST)
if [ -n "$f" ]; then if [ -n "$f" ]; then
# refs in the bundle may end up prefixed with refs/namespaces/mine/ # refs in the bundle may end up prefixed with refs/namespaces/mine/
# when the intent is for the bundle to include a # when the intent is for the bundle to include a
# ref with the name that comes after that. # ref with the name that comes after that.
git bundle list-heads $f | sed 's/refs\/namespaces\/mine\///' git bundle list-heads $TOPDIR/$f | sed 's/refs\/namespaces\/mine\///'
fi fi
fi fi
echo echo
@ -78,9 +80,9 @@ while read foo; do
# another series of commands could follow # another series of commands could follow
"") "")
if [ "$dofetch" ]; then if [ "$dofetch" ]; then
if [ -e "MANIFEST" ]; then if [ -e "$TOPDIR/MANIFEST" ]; then
for f in $(cat MANIFEST); do for f in $(cat $TOPDIR/MANIFEST); do
git bundle unbundle "$f" >/dev/null 2>&1 git bundle unbundle "$TOPDIR/$f" >/dev/null 2>&1
done done
fi fi
echo echo
@ -89,21 +91,21 @@ while read foo; do
if [ "$dopush" ]; then if [ "$dopush" ]; then
if [ -z "$(git for-each-ref refs/namespaces/mine/)" ]; then if [ -z "$(git for-each-ref refs/namespaces/mine/)" ]; then
# deleted all refs # deleted all refs
if [ -e "MANIFEST" ]; then if [ -e "$TOPDIR/MANIFEST" ]; then
for f in $(cat MANIFEST); do for f in $(cat $TOPDIR/MANIFEST); do
rm "$f" rm "$TOPDIR/$f"
done done
rm MANIFEST rm $TOPDIR/MANIFEST
touch MANIFEST touch $TOPDIR/MANIFEST
fi fi
else else
# set REPUSH=1 to do a full push # set REPUSH=1 to do a full push
# rather than incremental # rather than incremental
if [ "$REPUSH" ]; then if [ "$REPUSH" ]; then
rm MANIFEST rm $TOPDIR/MANIFEST
rm *.bundle rm $TOPDIR/*.bundle
git for-each-ref refs/namespaces/mine/ | awk '{print $3}' | \ git for-each-ref refs/namespaces/mine/ | awk '{print $3}' | \
git bundle create --quiet new.bundle --stdin git bundle create --quiet $TOPDIR/new.bundle --stdin
else else
# incremental bundle # incremental bundle
IFS=" IFS="
@ -138,11 +140,11 @@ while read foo; do
echo "$r" echo "$r"
fi fi
done) \ done) \
| git bundle create --quiet new.bundle --stdin | git bundle create --quiet $TOPDIR/new.bundle --stdin
fi fi
sha1=$(sha1sum new.bundle | awk '{print $1}') sha1=$(sha1sum $TOPDIR/new.bundle | awk '{print $1}')
mv new.bundle "$sha1.bundle" mv $TOPDIR/new.bundle "$TOPDIR/$sha1.bundle"
echo "$sha1.bundle" >> MANIFEST echo "$sha1.bundle" >> $TOPDIR/MANIFEST
fi fi
echo echo
dopush="" dopush=""