1#!/bin/sh 2# Inflate the size of an EXISTING repo. 3# 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. 8# 9# Usage: [-t target_size] [-b branch_name] 10 11set -e 12 13target_size=10000 14branch_name=p0006-ballast 15ballast=ballast 16 17whiletest"$#"-ne0 18do 19case"$1"in 20-b) 21shift; 22test"$#"-ne0|| {echo'error: -b requires an argument'>&2;exit1; } 23 branch_name=$1; 24shift;; 25-t) 26shift; 27test"$#"-ne0|| {echo'error: -t requires an argument'>&2;exit1; } 28 target_size=$1; 29shift;; 30*) 31echo"error: unknown option '$1'">&2;exit1;; 32esac 33done 34 35git ls-tree -r HEAD >GEN_src_list 36nr_src_files=$(cat GEN_src_list | wc -l) 37 38src_branch=$(git symbolic-ref --short HEAD) 39 40echo"Branch$src_branchinitially has$nr_src_filesfiles." 41 42iftest$target_size-le$nr_src_files 43then 44echo"Repository already exceeds target size$target_size." 45rm GEN_src_list 46exit1 47fi 48 49# Create well-known branch and add 1 file change to start 50# if off before the ballast. 51git checkout -b$branch_name HEAD 52echo"$target_size"> inflate-repo.params 53git add inflate-repo.params 54git commit -q -m params 55 56# Create ballast for in our branch. 57copy=1 58nr_files=$nr_src_files 59whiletest$nr_files-lt$target_size 60do 61sed-e"s| |$ballast/$copy/|"<GEN_src_list | 62 git update-index --index-info 63 64 nr_files=$(expr $nr_files + $nr_src_files) 65 copy=$(expr $copy + 1) 66done 67rm GEN_src_list 68git commit -q -m"ballast" 69 70# Modify 1 file and commit. 71echo"$target_size">> inflate-repo.params 72git add inflate-repo.params 73git commit -q -m"ballast plus 1" 74 75nr_files=$(git ls-files | wc -l) 76 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)). 81git checkout $src_branch 82 83echo"Repository inflated. Branch$branch_namehas$nr_filesfiles." 84 85exit0