def METHOD_NAME(working_dir, bundler_dir, thresh, new_bundles):
    if path_exists(join(working_dir, '.git')):
        last_bundle = None
        last_bundlename = newest_bundle_filename(bundler_dir)
        # "git gc" before bundling is *very* important, since
        # otherwise the bundles mushroom for no good reason.
        os.chdir(working_dir)
        cmd(['git', 'commit', '-a', '-m', 'Salvus save'], ignore_errors=True)
        cmd(['git', 'gc'])
        # Try making a new bundle first
        cmd([diffbundler, 'create', working_dir, bundler_dir], dry_run=False)
        new_bundlename = newest_bundle_filename(bundler_dir)
        if new_bundlename != last_bundlename:
            # There were changes to the repo that we had not already bundled up.
            # First, check if we should merge the last two bundles.
            if thresh > 0 and last_bundlename is not None and getsize(last_bundlename)/1000000.0 < thresh:
                os.unlink(last_bundlename)
                os.unlink(new_bundlename)
                cmd([diffbundler, 'create', working_dir, bundler_dir], dry_run=False)
                new_bundles.append(last_bundlename)
            else:
                new_bundles.append(new_bundlename)
    for path in listdir(working_dir):
        p = join(working_dir, path)
        if isdir(p) and not islink(p):
            METHOD_NAME(p, join(bundler_dir, path), thresh, new_bundles)