Add levels for refs and symrefs

This commit is contained in:
Sebastian Morr 2020-09-13 21:55:51 +02:00
parent cb2bb767db
commit 9ba485b789
7 changed files with 32 additions and 0 deletions
levels/05-ref

View file

@ -0,0 +1,9 @@
Let's take a look at "refs", short for "references"! Refs are not objects, but rather very simple *pointers* to objects! They can help you keep track of what's where.
You can create or update a ref with
git update-ref refs/<refname> <newvalue>
Make sure to start a ref's name with "refs/"! That's a convention that helps Git find all refs you create.
Create refs that point to all objects in this repository!

5
levels/05-ref/start Normal file
View file

@ -0,0 +1,5 @@
echo hello > hello
echo world > world
git add .
TREE=$(git write-tree)
git commit-tree $TREE -m "Initial commit"

3
levels/05-ref/win Normal file
View file

@ -0,0 +1,3 @@
OBJECTS=$(git cat-file --batch-check='%(objectname)' --batch-all-objects | sort)
REF_TARGETS=$(git show-ref -s | sort | uniq)
test "$OBJECTS" = "$REF_TARGETS"