Hash :
3fd57a75
Author :
Date :
2021-01-04T18:22:43
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67
/*
* Copyright (C) the libgit2 contributors. All rights reserved.
*
* This file is part of libgit2, distributed under the GNU GPL v2 with
* a Linking Exception. For full terms see the included COPYING file.
*/
#ifndef INCLUDE_commit_graph_h__
#define INCLUDE_commit_graph_h__
#include "common.h"
#include "map.h"
/**
* A commit-graph file.
*
* This file contains metadata about commits, particularly the generation
* number for each one. This can help speed up graph operations without
* requiring a full graph traversal.
*
* Support for this feature was added in git 2.19.
*/
typedef struct git_commit_graph_file {
git_map graph_map;
/* The OID Fanout table. */
const uint32_t *oid_fanout;
/* The total number of commits in the graph. */
uint32_t num_commits;
/* The OID Lookup table. */
git_oid *oid_lookup;
/*
* The Commit Data table. Each entry contains the OID of the commit followed
* by two 8-byte fields in network byte order:
* - The indices of the first two parents (32 bits each).
* - The generation number (first 30 bits) and commit time in seconds since
* UNIX epoch (34 bits).
*/
const unsigned char *commit_data;
/*
* The Extra Edge List table. Each 4-byte entry is a network byte order index
* of one of the i-th (i > 0) parents of commits in the `commit_data` table,
* when the commit has more than 2 parents.
*/
const unsigned char *extra_edge_list;
/* The number of entries in the Extra Edge List table. Each entry is 4 bytes wide. */
size_t num_extra_edge_list;
/* The trailer of the file. Contains the SHA1-checksum of the whole file. */
git_oid checksum;
/* something like ".git/objects/info/commit-graph". */
git_buf filename;
} git_commit_graph_file;
int git_commit_graph_open(git_commit_graph_file **cgraph_out, const char *path);
int git_commit_graph_close(git_commit_graph_file *cgraph);
void git_commit_graph_free(git_commit_graph_file *cgraph);
/* This is exposed for use in the fuzzers. */
int git_commit_graph_parse(git_commit_graph_file *cgraph, const unsigned char *data, size_t size);
#endif