]> git.ipfire.org Git - thirdparty/git.git/blob - t/perf/repos/inflate-repo.sh
Merge branch 'pw/checkout-conflict-errorfix'
[thirdparty/git.git] / t / perf / repos / inflate-repo.sh
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
11 set -e
12
13 target_size=10000
14 branch_name=p0006-ballast
15 ballast=ballast
16
17 while test "$#" -ne 0
18 do
19 case "$1" in
20 -b)
21 shift;
22 test "$#" -ne 0 || { echo 'error: -b requires an argument' >&2; exit 1; }
23 branch_name=$1;
24 shift ;;
25 -t)
26 shift;
27 test "$#" -ne 0 || { echo 'error: -t requires an argument' >&2; exit 1; }
28 target_size=$1;
29 shift ;;
30 *)
31 echo "error: unknown option '$1'" >&2; exit 1 ;;
32 esac
33 done
34
35 git ls-tree -r HEAD >GEN_src_list
36 nr_src_files=$(wc -l <GEN_src_list)
37
38 src_branch=$(git symbolic-ref --short HEAD)
39
40 echo "Branch $src_branch initially has $nr_src_files files."
41
42 if test $target_size -le $nr_src_files
43 then
44 echo "Repository already exceeds target size $target_size."
45 rm GEN_src_list
46 exit 1
47 fi
48
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
55
56 # Create ballast for in our branch.
57 copy=1
58 nr_files=$nr_src_files
59 while test $nr_files -lt $target_size
60 do
61 sed -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)
66 done
67 rm GEN_src_list
68 git commit -q -m "ballast"
69
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"
74
75 nr_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)).
81 git checkout $src_branch
82
83 echo "Repository inflated. Branch $branch_name has $nr_files files."
84
85 exit 0