2021-09-24 20:54:49 +02:00
|
|
|
title = Aggiungere le modifice una per volta
|
2021-02-04 12:01:58 +01:00
|
|
|
cards = add reset-file commit
|
2021-02-02 16:42:55 +01:00
|
|
|
|
|
|
|
[description]
|
|
|
|
|
2021-09-14 17:03:17 +02:00
|
|
|
L'indice è veramente utile perché ci permette di essere precisi su quali cambiamenti vogliamo includere in ogni commit!
|
2021-02-02 16:42:55 +01:00
|
|
|
|
|
|
|
[setup]
|
|
|
|
|
2021-09-14 17:03:17 +02:00
|
|
|
echo "Un martello, in equilibrio sul suo manico." > hammer
|
|
|
|
echo "Una bottiglia contenente un liquido trasparente." > bottle
|
2021-09-24 20:54:49 +02:00
|
|
|
echo "Un cubetto di zucchero bianco." > sugar_cube
|
2021-02-02 16:42:55 +01:00
|
|
|
|
|
|
|
git add .
|
2021-09-14 17:03:17 +02:00
|
|
|
git commit -m "L'inizio"
|
2021-02-02 16:42:55 +01:00
|
|
|
|
|
|
|
[win]
|
|
|
|
|
2021-09-14 17:03:17 +02:00
|
|
|
# Fai dei cambiamenti a tutti e tre gli oggetti per creare una sequenza logica di eventi!
|
2021-02-02 16:42:55 +01:00
|
|
|
test "$(git diff --name-only | wc -l)" -eq 3 || file -f .git/candle-changed && touch .git/candle-changed
|
|
|
|
|
2021-09-14 17:03:17 +02:00
|
|
|
# Aggiungi solo uno dei cambiamenti!
|
2021-02-02 16:42:55 +01:00
|
|
|
test "$(git diff --cached --name-only | wc -l)" -eq 1 || file -f .git/candle-added && touch .git/candle-added
|
|
|
|
|
2021-09-14 17:03:17 +02:00
|
|
|
# E fai un commit
|
2021-02-02 16:42:55 +01:00
|
|
|
COUNT=0
|
|
|
|
for commit in $(git cat-file --batch-check='%(objectname) %(objecttype)' --batch-all-objects | grep 'commit$' | cut -f1 -d' '); do
|
|
|
|
if test "$(git diff --name-only $commit $commit^ | wc -l)" -eq 1; then
|
|
|
|
COUNT=$((COUNT+1))
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
|
|
|
test "$COUNT" -ge 1
|
|
|
|
|
2021-09-14 17:03:17 +02:00
|
|
|
# Fai un secondo commit che registri solo un singolo cambiamento.
|
2021-02-02 16:42:55 +01:00
|
|
|
COUNT=0
|
|
|
|
for commit in $(git cat-file --batch-check='%(objectname) %(objecttype)' --batch-all-objects | grep 'commit$' | cut -f1 -d' '); do
|
|
|
|
if test "$(git diff --name-only $commit $commit^ | wc -l)" -eq 1; then
|
|
|
|
COUNT=$((COUNT+1))
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
|
|
|
test "$COUNT" -ge 2
|
|
|
|
|
2021-09-14 17:03:17 +02:00
|
|
|
# E aggiungine un terzo.
|
2021-02-02 16:42:55 +01:00
|
|
|
COUNT=0
|
|
|
|
for commit in $(git cat-file --batch-check='%(objectname) %(objecttype)' --batch-all-objects | grep 'commit$' | cut -f1 -d' '); do
|
|
|
|
if test "$(git diff --name-only $commit $commit^ | wc -l)" -eq 1; then
|
|
|
|
COUNT=$((COUNT+1))
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
|
|
|
test "$COUNT" -ge 3
|