#!/usr/bin/env python import os import random import subprocess import sys def die(msg): print >> sys.stderr, msg sys.exit(1) def new_ref(a, b, commit): d = ".git/refs/changes/%d/%d" % (a, b) if not os.path.exists(d): os.makedirs(d) e = 1 p = "%s/%d" % (d, e) while os.path.exists(p): e += 1 p = "%s/%d" % (d, e) f = open(p, "w") f.write(commit) f.close() def make_refs(count, commit): while count > 0: sys.stdout.write("left: %d%s\r" % (count, " " * 30)) a = random.randrange(10, 30) b = random.randrange(10000, 50000) new_ref(a, b, commit) count -= 1 print "refs complete" def main(): if len(sys.argv) != 3: die("usage: %s " % sys.argv[0]) _, name, refs = sys.argv os.mkdir(name) os.chdir(name) if subprocess.call(["git", "init"]) != 0: die("failed to init repo") f = open("foobar.txt", "w") f.write("%s: %s refs\n" % (name, refs)) f.close() if subprocess.call(["git", "add", "foobar.txt"]) != 0: die("failed to add foobar.txt") if subprocess.call(["git", "commit", "-m", "inital commit"]) != 0: die("failed to create initial commit") commit = subprocess.check_output(["git", "show-ref", "-s", "master"]).strip() make_refs(int(refs), commit) if __name__ == "__main__": main()