@matheusbsbs / matheus-bagliano / commits / 048cdd4665
Fork 0

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>

Johan Herland committed Feb 13, 2010 at 22:28 UTC 048cdd4665efafde2902cb72376f2ca497254246
1 file changed +50
t/t3305-notes-fanout.sh new
+50
@@ -0,0 +1,50 @@
1 +#!/bin/sh
2 +
3 +test_description='Test that adding many notes triggers automatic fanout restructuring'
4 +
5 +. ./test-lib.sh
6 +
7 +test_expect_success 'creating many notes with git-notes' '
8 + num_notes=300 &&
9 + i=0 &&
10 + while test $i -lt $num_notes
11 + do
12 + i=$(($i + 1)) &&
13 + test_tick &&
14 + echo "file for commit #$i" > file &&
15 + git add file &&
16 + git commit -q -m "commit #$i" &&
17 + git notes edit -m "note #$i" || return 1
18 + done
19 +'
20 +
21 +test_expect_success 'many notes created correctly with git-notes' '
22 + git log | grep "^ " > output &&
23 + i=300 &&
24 + while test $i -gt 0
25 + do
26 + echo " commit #$i" &&
27 + echo " note #$i" &&
28 + i=$(($i - 1));
29 + done > expect &&
30 + test_cmp expect output
31 +'
32 +
33 +test_expect_success 'many notes created with git-notes triggers fanout' '
34 + # Expect entire notes tree to have a fanout == 1
35 + git ls-tree -r --name-only refs/notes/commits |
36 + while read path
37 + do
38 + case "$path" in
39 + ??/??????????????????????????????????????)
40 + : true
41 + ;;
42 + *)
43 + echo "Invalid path \"$path\"" &&
44 + return 1
45 + ;;
46 + esac
47 + done
48 +'
49 +
50 +test_done