'Complete a thin pack by adding external references.
:param f: Open file object for the pack.
:param indexer: A PackIndexer for indexing the pack.'

def _complete_thin_pack(self, f, indexer):

    entries = list(indexer)
    f.seek(0)
    write_pack_header(f, (len(entries) + len(indexer.ext_refs())))
    new_sha = compute_file_sha(f, end_ofs=(-20))
    for ext_sha in indexer.ext_refs():
        assert (len(ext_sha) == 20)
        (type_num, data) = self.get_raw(ext_sha)
        write_pack_object(f, type_num, data, sha=new_sha)
    pack_sha = new_sha.digest()
    f.write(pack_sha)
