Created
January 14, 2016 12:52
-
-
Save mhagger/46fd6d3dd835f089c512 to your computer and use it in GitHub Desktop.
Aid to reproducing libgit2 issue
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /bin/sh | |
set -e | |
usage() { | |
echo "usage: $0 (--one-level | --two-level | with-ref) <git-dir> <count>" | |
} | |
make_one_level() { | |
base="$1" | |
mkdir -p "$base" | |
} | |
make_two_level() { | |
base="$1" | |
mkdir -p "$base/d" | |
} | |
make_with_ref() { | |
base="$1" | |
mkdir -p "$base" | |
echo $sha1 >"$base/r" | |
} | |
count() { | |
type="$1" | |
find "$gunk_dir" -type $type -print | wc -l | |
} | |
if test $# != 3 | |
then | |
usage | |
exit 1 | |
fi | |
case "$1" in | |
--one-level) | |
func=make_one_level | |
;; | |
--two-level) | |
func=make_two_level | |
;; | |
--with-ref) | |
func=make_with_ref | |
;; | |
*) | |
usage | |
exit 1 | |
;; | |
esac | |
git_dir="$2" | |
count="$3" | |
gunk_dir="$git_dir/refs/gunk" | |
sha1=$(GIT_DIR="$git_dir" git rev-parse HEAD) | |
test -d "$gunk_dir" && rm -r "$gunk_dir" | |
echo "Creating approximately $count repetitions" | |
seq 0 $((count-1)) | | |
xargs printf "%08d\n" | | |
sed -Ee "s#(..)#/\1#g" | | |
sed -Ee "s#(.*)#$gunk_dir\1#" | | |
while read base | |
do | |
$func $base | |
done | |
echo "Created $(count d) directories and $(count f) files" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment