| 1 | #!/bin/shscip-shell filesystem . . `/bin/sh`. |
| 2 | # Generate test data repository using the given parameters. |
| 3 | # When omitted, we create "gen-many-files-d-w-f.git". |
| 4 | # |
| 5 | # Usage: [-r repo] [-d depth] [-w width] [-f files] |
| 6 | # |
| 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 |
| 11 | # |
| 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 |
| 15 | # ODB. |
| 16 | # |
| 17 | # Ballast will be created under "ballast/". |
| 18 | |
| 19 | EMPTY_BLOB=e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 |
| 20 | |
| 21 | set -e |
| 22 | |
| 23 | # (5, 10, 9) will create 999,999 ballast files. |
| 24 | # (4, 10, 9) will create 99,999 ballast files. |
| 25 | depth=5 |
| 26 | width=10 |
| 27 | files=9 |
| 28 | |
| 29 | while testscip-shell system . . test. "$#" -ne 0 |
| 30 | do |
| 31 | case "$1" in |
| 32 | -r) |
| 33 | shift; |
| 34 | testscip-shell system . . test. "$#" -ne 0 || { echoscip-shell system . . echo. 'error: -r requires an argument' >&2; exit 1; } |
| 35 | repo=$1; |
| 36 | shift ;; |
| 37 | -d) |
| 38 | shift; |
| 39 | testscip-shell system . . test. "$#" -ne 0 || { echoscip-shell system . . echo. 'error: -d requires an argument' >&2; exit 1; } |
| 40 | depth=$1; |
| 41 | shift ;; |
| 42 | -w) |
| 43 | shift; |
| 44 | testscip-shell system . . test. "$#" -ne 0 || { echoscip-shell system . . echo. 'error: -w requires an argument' >&2; exit 1; } |
| 45 | width=$1; |
| 46 | shift ;; |
| 47 | -f) |
| 48 | shift; |
| 49 | testscip-shell system . . test. "$#" -ne 0 || { echoscip-shell system . . echo. 'error: -f requires an argument' >&2; exit 1; } |
| 50 | files=$1; |
| 51 | shift ;; |
| 52 | *) |
| 53 | echoscip-shell system . . echo. "error: unknown option '$1'" >&2; exit 1 ;; |
| 54 | esac |
| 55 | done |
| 56 | |
| 57 | # Inflate the index with thousands of empty files. |
| 58 | # usage: dir depth width files |
| 59 | fill_indexscip-shell shell cgit 1.2.3+git20250818.80.3346409+git2.51.0-1 fill_index().() { |
| 60 | awkscip-shell system . . 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++) { |
| 63 | print dir "/file" f |
| 64 | } |
| 65 | if (depth > 0) { |
| 66 | for (w = 1; w <= width; w++) { |
| 67 | make_paths(dir "/dir" w, depth - 1, width, files) |
| 68 | } |
| 69 | } |
| 70 | } |
| 71 | END { make_paths(arg_dir, arg_depth, arg_width, arg_files) } |
| 72 | ' </dev/nullscip-shell filesystem . . `/dev/null`. | |
| 73 | sedscip-shell system . . sed. "s/^/100644 $EMPTY_BLOB /" | |
| 74 | gitscip-shell system . . git. update-index --index-info |
| 75 | return 0 |
| 76 | } |
| 77 | |
| 78 | [scip-shell system . . `[`. -z "$repo" ] && repo=gen-many-files-$depth.$width.$files.git |
| 79 | |
| 80 | mkdirscip-shell system . . mkdir. $repo |
| 81 | cd $repo |
| 82 | gitscip-shell system . . git. init . |
| 83 | |
| 84 | # Create an initial commit just to define master. |
| 85 | touchscip-shell system . . touch. many-files.empty |
| 86 | echoscip-shell system . . echo. "$depth $width $files" >many-files.params |
| 87 | gitscip-shell system . . git. add many-files.* |
| 88 | gitscip-shell system . . git. commit -q -m params |
| 89 | |
| 90 | # Create ballast for p0006 based upon the given params and |
| 91 | # inflate the index with thousands of empty files and commit. |
| 92 | gitscip-shell system . . git. checkout -b p0006-ballast |
| 93 | fill_indexscip-shell shell cgit 1.2.3+git20250818.80.3346409+git2.51.0-1 fill_index(). "ballast" $depth $width $files |
| 94 | gitscip-shell system . . git. commit -q -m "ballast" |
| 95 | |
| 96 | nr_files=$(gitscip-shell system . . git. ls-files | wcscip-shell system . . wc. -l) |
| 97 | |
| 98 | # Modify 1 file and commit. |
| 99 | echoscip-shell system . . echo. "$depth $width $files" >>many-files.params |
| 100 | gitscip-shell system . . git. add many-files.params |
| 101 | gitscip-shell system . . git. commit -q -m "ballast plus 1" |
| 102 | |
| 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)). |
| 107 | gitscip-shell system . . git. checkout master |
| 108 | |
| 109 | echoscip-shell system . . echo. "Repository "$repo" ($depth, $width, $files) created. Ballast $nr_files." |
| 110 | exit 0 |