'Move a specific file containing a pack into the pack directory.
:note: The file should be on the same file system as the
packs directory.
:param f: Open file object for the pack.
:param path: Path to the pack file.
:param copier: A PackStreamCopier to use for writing pack data.
:param indexer: A PackIndexer for indexing the pack.'

def _complete_thin_pack(self, f, path, copier, indexer):

    entries = list(indexer)
    f.seek(0)
    write_pack_header(f, (len(entries) + len(indexer.ext_refs())))
    f.flush()
    new_sha = compute_file_sha(f, end_ofs=(-20))
    f.seek(0, os.SEEK_CUR)
    for ext_sha in indexer.ext_refs():
        assert (len(ext_sha) == 20)
        (type_num, data) = self.get_raw(ext_sha)
        offset = f.tell()
        crc32 = write_pack_object(f, type_num, data, sha=new_sha)
        entries.append((ext_sha, offset, crc32))
    pack_sha = new_sha.digest()
    f.write(pack_sha)
    f.close()
    entries.sort()
    pack_base_name = self._get_pack_basepath(entries)
    if (sys.platform == 'win32'):
        try:
            os.rename(path, (pack_base_name + '.pack'))
        except WindowsError:
            os.remove((pack_base_name + '.pack'))
            os.rename(path, (pack_base_name + '.pack'))
    else:
        os.rename(path, (pack_base_name + '.pack'))
    index_file = GitFile((pack_base_name + '.idx'), 'wb')
    try:
        write_pack_index_v2(index_file, entries, pack_sha)
        index_file.close()
    finally:
        index_file.abort()
    final_pack = Pack(pack_base_name)
    final_pack.check_length_and_checksum()
    self._add_known_pack(pack_base_name, final_pack)
    return final_pack
