Skip to content

Instantly share code, notes, and snippets.

@michel47
Last active November 27, 2021 13:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save michel47/265459b6ff51e28d179a7f4b7778c603 to your computer and use it in GitHub Desktop.
Save michel47/265459b6ff51e28d179a7f4b7778c603 to your computer and use it in GitHub Desktop.
git tokens
#
git init
export GIT_AUTHOR_DATE='Thu, 01 Jan 1970 00:00:00 +0000'
export GIT_COMMITTER_DATE='Thu, 01 Jan 1970 00:00:00 +0000'
git commit --allow-empty -m 'Initial commit'
git tag "init"
gitid=$(git rev-parse HEAD)
git filter-branch --env-filter "if [ \$GIT_COMMIT = $gitid ]; then
export GIT_AUTHOR_DATE='$GIT_AUTHOR_DATE'
export GIT_COMMITTER_DATE='$GIT_COMMITTER_DATE'
fi" -- --all
git log
git remote add origin git@hologit.ml:anony/init.git
# read more :
# https://hardbin.com/ipfs/QmNcWM3HM4RNrP6YP8JHBp7wHpgCPsk6H4gmGxxBaLPjeZ/
#
gitdir=$(git rev-parse --git-dir)
emptytree=$(git hash-object -t tree /dev/null)
file="$1"
if [ -f $file ]; then
git add $file
githash=$(git hash-object $file)
git reset $file
else
if [ -e README.md ]; then
githash=$(git hash-object README.md)
else
githash=$emptytree
fi
fi
shard=$(echo $githash | cut -c-2)
obj=$(echo $githash | cut -c3-)
objf=$gitdir/objects/$shard/$obj
echo objf: $objf
if [ ! -e $objf ]; then
echo "! -e $objf"
fi
perl -S dat2png.pl -r 1 -o $githash.png $objf
ls -l $githash.png
token=$(ipfs add -Q $objf --pin=true)
echo "qmtoken: $token"
token=$(ipfs add -Q $objf --pin=true --hash sha1 --raw-leaves --cid-base base16)
echo "token: $token"
echo -n "provs: "
ipfs dht findprovs -n 1 /ipfs/$token
echo "qmgit=\$(ipfs add -Q -r \$(git rev-parse --git-dir))"
echo "ipfs object patch add-link \$qmgit --create objects/$shard/$obj $token"
#qmgit=$(ipfs add -Q -r $(git rev-parse --git-dir))
#ipfs object patch add-link $qmgit --create objects/$shard/$obj $token

  • This is the famous empty tree object from any GIT repository in the world ... now you can own it, i.e your NFT will be in the source repository of every software around :)
#
# remarkable object
echo -n "blob 0\0" | pigz -9 -z > blob.z
echo -n "tree 0\0" | pigz -1 -z > tree.z
echo -n "commit 0\0" | pigz -9 -z > commit.z
for obj in *.z; do
echo // $obj
pigz -d -c -k $obj | openssl sha1 -r
dat2png.pl -r 1 $obj ${obj%.*}.png
magnify.sh ${obj%.*}.png
ipfs add -w ${obj%.*}*
echo .
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment