mirror of
https://github.com/git-learning-game/oh-my-git.git
synced 2025-05-23 21:01:22 +02:00
34 lines
No EOL
1.1 KiB
Text
34 lines
No EOL
1.1 KiB
Text
[descripción]
|
|
|
|
Construye una cadena de tres árboles, que no apunten a nada más.
|
|
|
|
¡Esto es duro! El comando `git mktree` puede resultar útil.
|
|
|
|
[configuración]
|
|
|
|
[objetivo de configuración]
|
|
|
|
git mktree
|
|
ÁRBOL=$(echo -e "040000 árbol 4b825dc642cb6eb9a060e54bf8d69288fbee4904\tdir" | git mktree)
|
|
echo -e "040000 árbol $TREE\tdir" | git mktree
|
|
|
|
[ganar]
|
|
|
|
ÁRBOLES=$(git cat-file --batch-check='%(nombre de objeto) %(tipo de objeto)' --batch-all-objects | árbol grep | cut -f1 -d" ")
|
|
|
|
para ÁRBOL en $ÁRBOLES; hacer
|
|
if [ "$(git cat-file -p $ÁRBOL | wc -l)" -eq 1 ]; entonces
|
|
if [ "$(git cat-file -p $TREE | cut -f1 | grep tree | wc -l)" -eq 1 ]; entonces
|
|
# Entonces el árbol tiene exactamente un hijo, ¡y es un árbol!
|
|
ÁRBOL2=$(git cat-file -p $ÁRBOL | cortar -f1 | árbol grep | cortar -f3 -d" ")
|
|
if [ "$(git cat-file -p $TREE2 | wc -l)" -eq 1 ]; entonces
|
|
if [ "$(git cat-file -p $TREE2 | cut -f1 | grep tree | wc -l)" -eq 1 ]; entonces
|
|
# ¡Lo mismo para su hijo! \o/
|
|
regresar 0
|
|
fi
|
|
fi
|
|
fi
|
|
fi
|
|
hecho
|
|
|
|
regresar 1 |