mirror of
https://github.com/git-learning-game/oh-my-git.git
synced 2024-11-18 16:20:35 +01:00
28 lines
734 B
Text
28 lines
734 B
Text
[description]
|
|
|
|
Create two trees pointing to the same blob!
|
|
|
|
[setup]
|
|
|
|
[setup goal]
|
|
|
|
BLOB=$(echo "I am precious" | git hash-object -w --stdin)
|
|
git update-index --add --cacheinfo 100644,$BLOB,a
|
|
git write-tree
|
|
git update-index --force-remove a
|
|
git update-index --add --cacheinfo 100644,$BLOB,b
|
|
git write-tree
|
|
git update-index --force-remove b
|
|
|
|
[win]
|
|
|
|
TREES=$(git cat-file --batch-check='%(objectname) %(objecttype)' --batch-all-objects | grep tree | cut -f1 -d" ")
|
|
|
|
ALL_TREE_CHILDREN=$(for TREE in $TREES; do
|
|
git cat-file -p $TREE | cut -f1 | cut -f3 -d" "
|
|
done)
|
|
|
|
NUMBER_OF_CHILDREN=$(echo "$ALL_TREE_CHILDREN" | wc -l)
|
|
UNIQUE_CHILDREN=$(echo "$ALL_TREE_CHILDREN" | sort -u | wc -l)
|
|
|
|
test "$NUMBER_OF_CHILDREN" -gt "$UNIQUE_CHILDREN"
|