2 # Inflate the size of an EXISTING repo.
 
   4 # This script should be run inside the worktree of a TEST repo.
 
   5 # It will use the contents of the current HEAD to generate a
 
   6 # commit containing copies of the current worktree such that the
 
   7 # total size of the commit has at least <target_size> files.
 
   9 # Usage: [-t target_size] [-b branch_name]
 
  14 branch_name=p0006-ballast
 
  22             test "$#" -ne 0 || { echo 'error: -b requires an argument' >&2; exit 1; }
 
  27             test "$#" -ne 0 || { echo 'error: -t requires an argument' >&2; exit 1; }
 
  31             echo "error: unknown option '$1'" >&2; exit 1 ;;
 
  35 git ls-tree -r HEAD >GEN_src_list
 
  36 nr_src_files=$(cat GEN_src_list | wc -l)
 
  38 src_branch=$(git symbolic-ref --short HEAD)
 
  40 echo "Branch $src_branch initially has $nr_src_files files."
 
  42 if test $target_size -le $nr_src_files
 
  44     echo "Repository already exceeds target size $target_size."
 
  49 # Create well-known branch and add 1 file change to start
 
  50 # if off before the ballast.
 
  51 git checkout -b $branch_name HEAD
 
  52 echo "$target_size" > inflate-repo.params
 
  53 git add inflate-repo.params
 
  54 git commit -q -m params
 
  56 # Create ballast for in our branch.
 
  58 nr_files=$nr_src_files
 
  59 while test $nr_files -lt $target_size
 
  61     sed -e "s|  |       $ballast/$copy/|" <GEN_src_list |
 
  62         git update-index --index-info
 
  64     nr_files=$(expr $nr_files + $nr_src_files)
 
  65     copy=$(expr $copy + 1)
 
  68 git commit -q -m "ballast"
 
  70 # Modify 1 file and commit.
 
  71 echo "$target_size" >> inflate-repo.params
 
  72 git add inflate-repo.params
 
  73 git commit -q -m "ballast plus 1"
 
  75 nr_files=$(git ls-files | wc -l)
 
  77 # Checkout master to put repo in canonical state (because
 
  78 # the perf test may need to clone and enable sparse-checkout
 
  79 # before attempting to checkout a commit with the ballast
 
  80 # (because it may contain 100K directories and 1M files)).
 
  81 git checkout $src_branch
 
  83 echo "Repository inflated. Branch $branch_name has $nr_files files."