summaryrefslogtreecommitdiff
path: root/t/t3305-notes-fanout.sh
diff options
context:
space:
mode:
authorJohan Herland <johan@herland.net>2010-02-13 21:28:22 (GMT)
committerJunio C Hamano <gitster@pobox.com>2010-02-14 03:36:13 (GMT)
commit048cdd4665efafde2902cb72376f2ca497254246 (patch)
tree6c637cff0bac0e73b54f9f3e3b6d4545113ffedb /t/t3305-notes-fanout.sh
parentb24bb99756c8b6fde01c23ebbb4abc37d12fb1eb (diff)
downloadgit-048cdd4665efafde2902cb72376f2ca497254246.zip
git-048cdd4665efafde2902cb72376f2ca497254246.tar.gz
git-048cdd4665efafde2902cb72376f2ca497254246.tar.bz2
t3305: Verify that adding many notes with git-notes triggers increased fanout
Add a test verifying that the notes code automatically restructures the notes tree into a deeper fanout level, when many notes are added with "git notes". Signed-off-by: Johan Herland <johan@herland.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't/t3305-notes-fanout.sh')
-rwxr-xr-xt/t3305-notes-fanout.sh50
1 files changed, 50 insertions, 0 deletions
diff --git a/t/t3305-notes-fanout.sh b/t/t3305-notes-fanout.sh
new file mode 100755
index 0000000..823b0ff
--- /dev/null
+++ b/t/t3305-notes-fanout.sh
@@ -0,0 +1,50 @@
+#!/bin/sh
+
+test_description='Test that adding many notes triggers automatic fanout restructuring'
+
+. ./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" &&
+ git notes edit -m "note #$i" || return 1
+ 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
+ case "$path" in
+ ??/??????????????????????????????????????)
+ : true
+ ;;
+ *)
+ echo "Invalid path \"$path\"" &&
+ return 1
+ ;;
+ esac
+ done
+'
+
+test_done