@@ -69,8 +69,7 @@ static void packed_commit_free(struct packed_commit *p)
6969static struct packed_commit * packed_commit_new (git_commit * commit )
7070{
7171 unsigned int i , parentcount = git_commit_parentcount (commit );
72- struct packed_commit * p
73- = (struct packed_commit * )git__calloc (1 , sizeof (struct packed_commit ));
72+ struct packed_commit * p = git__calloc (1 , sizeof (struct packed_commit ));
7473 if (!p )
7574 goto cleanup ;
7675
@@ -436,8 +435,8 @@ static int git_commit_graph_entry_get_byindex(
436435 commit_data = file -> commit_data + pos * (GIT_OID_RAWSZ + 4 * sizeof (uint32_t ));
437436 git_oid_cpy (& e -> tree_oid , (const git_oid * )commit_data );
438437 e -> parent_indices [0 ] = ntohl (* ((uint32_t * )(commit_data + GIT_OID_RAWSZ )));
439- e -> parent_indices [1 ]
440- = ntohl ( * ((uint32_t * )(commit_data + GIT_OID_RAWSZ + sizeof (uint32_t ))));
438+ e -> parent_indices [1 ] = ntohl (
439+ * ((uint32_t * )(commit_data + GIT_OID_RAWSZ + sizeof (uint32_t ))));
441440 e -> parent_count = (e -> parent_indices [0 ] != GIT_COMMIT_GRAPH_MISSING_PARENT )
442441 + (e -> parent_indices [1 ] != GIT_COMMIT_GRAPH_MISSING_PARENT );
443442 e -> generation = ntohl (* ((uint32_t * )(commit_data + GIT_OID_RAWSZ + 2 * sizeof (uint32_t ))));
@@ -700,11 +699,9 @@ int git_commit_graph_writer_add_index_file(
700699{
701700 int error ;
702701 struct git_pack_file * p = NULL ;
703- struct object_entry_cb_state state = {
704- .repo = repo ,
705- .db = NULL ,
706- .commits = & w -> commits ,
707- };
702+ struct object_entry_cb_state state = {0 };
703+ state .repo = repo ;
704+ state .commits = & w -> commits ;
708705
709706 error = git_repository_odb (& state .db , repo );
710707 if (error < 0 )
@@ -941,8 +938,7 @@ struct commit_graph_write_hash_context {
941938
942939static int commit_graph_write_hash (const char * buf , size_t size , void * data )
943940{
944- struct commit_graph_write_hash_context * ctx
945- = (struct commit_graph_write_hash_context * )data ;
941+ struct commit_graph_write_hash_context * ctx = data ;
946942 int error ;
947943
948944 error = git_hash_update (ctx -> ctx , buf , size );
@@ -963,26 +959,25 @@ commit_graph_write(git_commit_graph_writer *w, commit_graph_write_cb write_cb, v
963959 int error = 0 ;
964960 size_t i ;
965961 struct packed_commit * packed_commit ;
966- struct git_commit_graph_header hdr = {
967- .signature = htonl (COMMIT_GRAPH_SIGNATURE ),
968- .version = COMMIT_GRAPH_VERSION ,
969- .object_id_version = COMMIT_GRAPH_OBJECT_ID_VERSION ,
970- .chunks = 0 ,
971- .base_graph_files = 0 ,
972- };
962+ struct git_commit_graph_header hdr = {0 };
973963 uint32_t oid_fanout_count ;
974964 uint32_t extra_edge_list_count ;
975965 uint32_t oid_fanout [256 ];
976966 off64_t offset ;
977- git_buf oid_lookup = GIT_BUF_INIT ,
978- commit_data = GIT_BUF_INIT , extra_edge_list = GIT_BUF_INIT ;
967+ git_buf oid_lookup = GIT_BUF_INIT , commit_data = GIT_BUF_INIT ,
968+ extra_edge_list = GIT_BUF_INIT ;
979969 git_oid cgraph_checksum = {{0 }};
980970 git_hash_ctx ctx ;
981- struct commit_graph_write_hash_context hash_cb_data = {
982- .write_cb = write_cb ,
983- .cb_data = cb_data ,
984- .ctx = & ctx ,
985- };
971+ struct commit_graph_write_hash_context hash_cb_data = {0 };
972+
973+ hdr .signature = htonl (COMMIT_GRAPH_SIGNATURE );
974+ hdr .version = COMMIT_GRAPH_VERSION ;
975+ hdr .object_id_version = COMMIT_GRAPH_OBJECT_ID_VERSION ;
976+ hdr .chunks = 0 ;
977+ hdr .base_graph_files = 0 ;
978+ hash_cb_data .write_cb = write_cb ;
979+ hash_cb_data .cb_data = cb_data ;
980+ hash_cb_data .ctx = & ctx ;
986981
987982 error = git_hash_ctx_init (& ctx );
988983 if (error < 0 )
@@ -1024,10 +1019,10 @@ commit_graph_write(git_commit_graph_writer *w, commit_graph_write_cb write_cb, v
10241019 uint32_t word ;
10251020 unsigned int parentcount = (unsigned int )git_array_size (packed_commit -> parents );
10261021
1027- error
1028- = git_buf_put ( & commit_data ,
1029- (const char * )& packed_commit -> tree_oid ,
1030- sizeof (git_oid ));
1022+ error = git_buf_put (
1023+ & commit_data ,
1024+ (const char * )& packed_commit -> tree_oid ,
1025+ sizeof (git_oid ));
10311026 if (error < 0 )
10321027 goto cleanup ;
10331028
@@ -1055,10 +1050,10 @@ commit_graph_write(git_commit_graph_writer *w, commit_graph_write_cb write_cb, v
10551050 word = htonl ((uint32_t )(
10561051 * git_array_get (packed_commit -> parent_indices , parent_i )
10571052 | (parent_i + 1 == parentcount ? 0x80000000u : 0 )));
1058- error
1059- = git_buf_put ( & extra_edge_list ,
1060- (const char * )& word ,
1061- sizeof (word ));
1053+ error = git_buf_put (
1054+ & extra_edge_list ,
1055+ (const char * )& word ,
1056+ sizeof (word ));
10621057 if (error < 0 )
10631058 goto cleanup ;
10641059 }
@@ -1122,10 +1117,7 @@ commit_graph_write(git_commit_graph_writer *w, commit_graph_write_cb write_cb, v
11221117 error = write_cb (git_buf_cstr (& commit_data ), git_buf_len (& commit_data ), cb_data );
11231118 if (error < 0 )
11241119 goto cleanup ;
1125- error
1126- = write_cb (git_buf_cstr (& extra_edge_list ),
1127- git_buf_len (& extra_edge_list ),
1128- cb_data );
1120+ error = write_cb (git_buf_cstr (& extra_edge_list ), git_buf_len (& extra_edge_list ), cb_data );
11291121 if (error < 0 )
11301122 goto cleanup ;
11311123
@@ -1160,6 +1152,7 @@ int git_commit_graph_writer_commit(
11601152 git_buf commit_graph_path = GIT_BUF_INIT ;
11611153 git_filebuf output = GIT_FILEBUF_INIT ;
11621154
1155+ /* TODO: support options. */
11631156 GIT_UNUSED (opts );
11641157
11651158 error = git_buf_joinpath (
@@ -1188,6 +1181,7 @@ int git_commit_graph_writer_dump(
11881181 git_commit_graph_writer * w ,
11891182 git_commit_graph_writer_options * opts )
11901183{
1184+ /* TODO: support options. */
11911185 GIT_UNUSED (opts );
11921186 return commit_graph_write (w , commit_graph_write_buf , cgraph );
11931187}
0 commit comments