mirror of
https://github.com/git-learning-game/oh-my-git.git
synced 2025-05-01 20:42:01 +02:00
Allow multiple level sets, pull out default order into "sequence" file
This commit is contained in:
parent
a9f096636a
commit
5031009dd5
96 changed files with 37 additions and 29 deletions
levels/bottom-up/tree-nested
5
levels/bottom-up/tree-nested/description
Normal file
5
levels/bottom-up/tree-nested/description
Normal file
|
@ -0,0 +1,5 @@
|
|||
Trees can also point to other trees! This way, they can describe nested directory structures.
|
||||
|
||||
When you add a file inside of a directory to the index, and then call `git write-tree`, it will create a nested tree for the directory, and attach the blob to it.
|
||||
|
||||
To solve this level, build a little stick figure, as shown on the left - a tree that points to two blobs, as well to a tree that points to two blobs.
|
7
levels/bottom-up/tree-nested/goal
Normal file
7
levels/bottom-up/tree-nested/goal
Normal file
|
@ -0,0 +1,7 @@
|
|||
echo "I'm the left arm" > arm1
|
||||
echo "I'm the right arm" > arm2
|
||||
mkdir hip
|
||||
echo "I'm the left leg" > hip/leg1
|
||||
echo "I'm the right leg" > hip/leg2
|
||||
git add .
|
||||
git write-tree
|
0
levels/bottom-up/tree-nested/start
Normal file
0
levels/bottom-up/tree-nested/start
Normal file
16
levels/bottom-up/tree-nested/win
Normal file
16
levels/bottom-up/tree-nested/win
Normal file
|
@ -0,0 +1,16 @@
|
|||
TREES=$(git cat-file --batch-check='%(objectname) %(objecttype)' --batch-all-objects | grep tree | cut -f1 -d" ")
|
||||
|
||||
for OUTER_TREE in $TREES; do
|
||||
NUMBER_OF_BLOB_CHILDREN=$(git cat-file -p $OUTER_TREE | cut -f2 -d" " | grep blob | wc -l)
|
||||
NUMBER_OF_TREE_CHILDREN=$(git cat-file -p $OUTER_TREE | cut -f2 -d" " | grep tree | wc -l)
|
||||
|
||||
if [ $NUMBER_OF_BLOB_CHILDREN -eq 2 -a $NUMBER_OF_TREE_CHILDREN -eq 1 ]; then
|
||||
TREE_CHILD=$(git cat-file -p $OUTER_TREE | cut -f1 | grep tree | cut -d" " -f3)
|
||||
NUMBER_OF_BLOB_CHILDREN_OF_TREE_CHILD=$(git cat-file -p $TREE_CHILD | cut -f2 -d" " | grep blob | wc -l)
|
||||
if [ $NUMBER_OF_BLOB_CHILDREN_OF_TREE_CHILD -eq 2 ]; then
|
||||
exit 0
|
||||
fi
|
||||
fi
|
||||
done
|
||||
|
||||
exit 1
|
Loading…
Add table
Add a link
Reference in a new issue