Commit 34fa6311 by Edward Thomson

commit graph: formatting fixes

parent 7d9ebdc8
...@@ -127,9 +127,8 @@ typedef struct { ...@@ -127,9 +127,8 @@ typedef struct {
} git_commit_graph_writer_options; } git_commit_graph_writer_options;
#define GIT_COMMIT_GRAPH_WRITER_OPTIONS_VERSION 1 #define GIT_COMMIT_GRAPH_WRITER_OPTIONS_VERSION 1
#define GIT_COMMIT_GRAPH_WRITER_OPTIONS_INIT \ #define GIT_COMMIT_GRAPH_WRITER_OPTIONS_INIT { \
{ \ GIT_COMMIT_GRAPH_WRITER_OPTIONS_VERSION \
GIT_COMMIT_GRAPH_WRITER_OPTIONS_VERSION, \
} }
/** /**
......
...@@ -915,8 +915,11 @@ static int write_offset(off64_t offset, commit_graph_write_cb write_cb, void *cb ...@@ -915,8 +915,11 @@ static int write_offset(off64_t offset, commit_graph_write_cb write_cb, void *cb
return 0; return 0;
} }
static int static int write_chunk_header(
write_chunk_header(int chunk_id, off64_t offset, commit_graph_write_cb write_cb, void *cb_data) int chunk_id,
off64_t offset,
commit_graph_write_cb write_cb,
void *cb_data)
{ {
uint32_t word = htonl(chunk_id); uint32_t word = htonl(chunk_id);
int error = write_cb((const char *)&word, sizeof(word), cb_data); int error = write_cb((const char *)&word, sizeof(word), cb_data);
...@@ -954,8 +957,10 @@ static void packed_commit_free_dup(void *packed_commit) ...@@ -954,8 +957,10 @@ static void packed_commit_free_dup(void *packed_commit)
packed_commit_free(packed_commit); packed_commit_free(packed_commit);
} }
static int static int commit_graph_write(
commit_graph_write(git_commit_graph_writer *w, commit_graph_write_cb write_cb, void *cb_data) git_commit_graph_writer *w,
commit_graph_write_cb write_cb,
void *cb_data)
{ {
int error = 0; int error = 0;
size_t i; size_t i;
...@@ -996,18 +1001,17 @@ commit_graph_write(git_commit_graph_writer *w, commit_graph_write_cb write_cb, v ...@@ -996,18 +1001,17 @@ commit_graph_write(git_commit_graph_writer *w, commit_graph_write_cb write_cb, v
/* Fill the OID Fanout table. */ /* Fill the OID Fanout table. */
oid_fanout_count = 0; oid_fanout_count = 0;
for (i = 0; i < 256; i++) { for (i = 0; i < 256; i++) {
while (oid_fanout_count < git_vector_length(&w->commits) while (oid_fanout_count < git_vector_length(&w->commits) &&
&& ((struct packed_commit *)git_vector_get(&w->commits, oid_fanout_count)) (packed_commit = (struct packed_commit *)git_vector_get(&w->commits, oid_fanout_count)) &&
->sha1.id[0] packed_commit->sha1.id[0] <= i)
<= i)
++oid_fanout_count; ++oid_fanout_count;
oid_fanout[i] = htonl(oid_fanout_count); oid_fanout[i] = htonl(oid_fanout_count);
} }
/* Fill the OID Lookup table. */ /* Fill the OID Lookup table. */
git_vector_foreach (&w->commits, i, packed_commit) { git_vector_foreach (&w->commits, i, packed_commit) {
error = git_buf_put( error = git_buf_put(&oid_lookup,
&oid_lookup, (const char *)&packed_commit->sha1, sizeof(git_oid)); (const char *)&packed_commit->sha1, sizeof(git_oid));
if (error < 0) if (error < 0)
goto cleanup; goto cleanup;
} }
...@@ -1021,8 +1025,7 @@ commit_graph_write(git_commit_graph_writer *w, commit_graph_write_cb write_cb, v ...@@ -1021,8 +1025,7 @@ commit_graph_write(git_commit_graph_writer *w, commit_graph_write_cb write_cb, v
size_t *packed_index; size_t *packed_index;
unsigned int parentcount = (unsigned int)git_array_size(packed_commit->parents); unsigned int parentcount = (unsigned int)git_array_size(packed_commit->parents);
error = git_buf_put( error = git_buf_put(&commit_data,
&commit_data,
(const char *)&packed_commit->tree_oid, (const char *)&packed_commit->tree_oid,
sizeof(git_oid)); sizeof(git_oid));
if (error < 0) if (error < 0)
...@@ -1054,14 +1057,10 @@ commit_graph_write(git_commit_graph_writer *w, commit_graph_write_cb write_cb, v ...@@ -1054,14 +1057,10 @@ commit_graph_write(git_commit_graph_writer *w, commit_graph_write_cb write_cb, v
unsigned int parent_i; unsigned int parent_i;
for (parent_i = 1; parent_i < parentcount; ++parent_i) { for (parent_i = 1; parent_i < parentcount; ++parent_i) {
packed_index = git_array_get( packed_index = git_array_get(
packed_commit->parent_indices, parent_i); packed_commit->parent_indices, parent_i);
word = htonl( word = htonl((uint32_t)(*packed_index | (parent_i + 1 == parentcount ? 0x80000000u : 0)));
(uint32_t)(*packed_index
| (parent_i + 1 == parentcount error = git_buf_put(&extra_edge_list,
? 0x80000000u
: 0)));
error = git_buf_put(
&extra_edge_list,
(const char *)&word, (const char *)&word,
sizeof(word)); sizeof(word));
if (error < 0) if (error < 0)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment