2010-02-13 21:28:22 +00:00
|
|
|
#!/bin/sh
|
|
|
|
|
2010-02-13 21:28:26 +00:00
|
|
|
test_description='Test that adding/removing many notes triggers automatic fanout restructuring'
|
2010-02-13 21:28:22 +00:00
|
|
|
|
|
|
|
. ./test-lib.sh
|
|
|
|
|
|
|
|
test_expect_success 'creating many notes with git-notes' '
|
|
|
|
num_notes=300 &&
|
|
|
|
i=0 &&
|
|
|
|
while test $i -lt $num_notes
|
|
|
|
do
|
|
|
|
i=$(($i + 1)) &&
|
|
|
|
test_tick &&
|
|
|
|
echo "file for commit #$i" > file &&
|
|
|
|
git add file &&
|
|
|
|
git commit -q -m "commit #$i" &&
|
2010-02-13 21:28:34 +00:00
|
|
|
git notes add -m "note #$i" || return 1
|
2010-02-13 21:28:22 +00:00
|
|
|
done
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'many notes created correctly with git-notes' '
|
|
|
|
git log | grep "^ " > output &&
|
|
|
|
i=300 &&
|
|
|
|
while test $i -gt 0
|
|
|
|
do
|
|
|
|
echo " commit #$i" &&
|
|
|
|
echo " note #$i" &&
|
|
|
|
i=$(($i - 1));
|
|
|
|
done > expect &&
|
|
|
|
test_cmp expect output
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'many notes created with git-notes triggers fanout' '
|
|
|
|
# Expect entire notes tree to have a fanout == 1
|
|
|
|
git ls-tree -r --name-only refs/notes/commits |
|
|
|
|
while read path
|
|
|
|
do
|
2019-08-18 19:16:36 +00:00
|
|
|
echo $path | grep "^../[0-9a-f]*$" || {
|
2010-02-13 21:28:22 +00:00
|
|
|
echo "Invalid path \"$path\"" &&
|
2019-08-18 19:16:36 +00:00
|
|
|
return 1;
|
|
|
|
}
|
2010-02-13 21:28:22 +00:00
|
|
|
done
|
|
|
|
'
|
|
|
|
|
2010-02-13 21:28:26 +00:00
|
|
|
test_expect_success 'deleting most notes with git-notes' '
|
|
|
|
num_notes=250 &&
|
|
|
|
i=0 &&
|
|
|
|
git rev-list HEAD |
|
2015-03-25 05:28:57 +00:00
|
|
|
while test $i -lt $num_notes && read sha1
|
2010-02-13 21:28:26 +00:00
|
|
|
do
|
|
|
|
i=$(($i + 1)) &&
|
|
|
|
test_tick &&
|
2015-03-25 05:28:57 +00:00
|
|
|
git notes remove "$sha1" ||
|
|
|
|
exit 1
|
2010-02-13 21:28:26 +00:00
|
|
|
done
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'most notes deleted correctly with git-notes' '
|
|
|
|
git log HEAD~250 | grep "^ " > output &&
|
|
|
|
i=50 &&
|
|
|
|
while test $i -gt 0
|
|
|
|
do
|
|
|
|
echo " commit #$i" &&
|
|
|
|
echo " note #$i" &&
|
|
|
|
i=$(($i - 1));
|
|
|
|
done > expect &&
|
|
|
|
test_cmp expect output
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'deleting most notes triggers fanout consolidation' '
|
|
|
|
# Expect entire notes tree to have a fanout == 0
|
|
|
|
git ls-tree -r --name-only refs/notes/commits |
|
|
|
|
while read path
|
|
|
|
do
|
2019-08-18 19:16:36 +00:00
|
|
|
echo $path | grep -v "^../.*" || {
|
2010-02-13 21:28:26 +00:00
|
|
|
echo "Invalid path \"$path\"" &&
|
2019-08-18 19:16:36 +00:00
|
|
|
return 1;
|
|
|
|
}
|
2010-02-13 21:28:26 +00:00
|
|
|
done
|
|
|
|
'
|
|
|
|
|
2010-02-13 21:28:22 +00:00
|
|
|
test_done
|