2 # Generate test data repository using the given parameters.
3 # When omitted, we create "gen-many-files-d-w-f.git".
5 # Usage: [-r repo] [-d depth] [-w width] [-f files]
7 # -r repo: path to the new repo to be generated
8 # -d depth: the depth of sub-directories
9 # -w width: the number of sub-directories at each level
10 # -f files: the number of files created in each directory
12 # Note that all files will have the same SHA-1 and each
13 # directory at a level will have the same SHA-1, so we
14 # will potentially have a large index, but not a large
17 # Ballast will be created under "ballast/".
19 EMPTY_BLOB
=e69de29bb2d1d6434b8b29ae775ad8c2e48c5391
23 # (5, 10, 9) will create 999,999 ballast files.
24 # (4, 10, 9) will create 99,999 ballast files.
34 test "$#" -ne 0 ||
{ echo 'error: -r requires an argument' >&2; exit 1; }
39 test "$#" -ne 0 ||
{ echo 'error: -d requires an argument' >&2; exit 1; }
44 test "$#" -ne 0 ||
{ echo 'error: -w requires an argument' >&2; exit 1; }
49 test "$#" -ne 0 ||
{ echo 'error: -f requires an argument' >&2; exit 1; }
53 echo "error: unknown option '$1'" >&2; exit 1 ;;
57 # Inflate the index with thousands of empty files.
58 # usage: dir depth width files
60 awk -v arg_dir
=$1 -v arg_depth
=$2 -v arg_width
=$3 -v arg_files
=$4 '
61 function make_paths(dir, depth, width, files, f, w) {
62 for (f = 1; f <= files; f++) {
66 for (w = 1; w <= width; w++) {
67 make_paths(dir "/dir" w, depth - 1, width, files)
71 END { make_paths(arg_dir, arg_depth, arg_width, arg_files) }
73 sed "s/^/100644 $EMPTY_BLOB /" |
74 git update-index
--index-info
78 [ -z "$repo" ] && repo
=gen-many-files-
$depth.
$width.
$files.git
84 # Create an initial commit just to define master.
85 touch many-files.empty
86 echo "$depth $width $files" >many-files.params
88 git commit
-q -m params
90 # Create ballast for p0006 based upon the given params and
91 # inflate the index with thousands of empty files and commit.
92 git checkout
-b p0006-ballast
93 fill_index
"ballast" $depth $width $files
94 git commit
-q -m "ballast"
96 nr_files
=$
(git ls-files |
wc -l)
98 # Modify 1 file and commit.
99 echo "$depth $width $files" >>many-files.params
100 git add many-files.params
101 git commit
-q -m "ballast plus 1"
103 # Checkout master to put repo in canonical state (because
104 # the perf test may need to clone and enable sparse-checkout
105 # before attempting to checkout a commit with the ballast
106 # (because it may contain 100K directories and 1M files)).
109 echo "Repository "$repo" ($depth, $width, $files) created. Ballast $nr_files."