@@ -34,39 +34,17 @@ static int write_oid(const struct object_id *oid,
3434 return 0 ;
3535}
3636
37- void repack_promisor_objects (struct repository * repo ,
38- const struct pack_objects_args * args ,
39- struct string_list * names , const char * packtmp )
37+ static void finish_repacking_promisor_objects (struct repository * repo ,
38+ struct child_process * cmd ,
39+ struct string_list * names ,
40+ const char * packtmp )
4041{
41- struct write_oid_context ctx ;
42- struct child_process cmd = CHILD_PROCESS_INIT ;
43- FILE * out ;
4442 struct strbuf line = STRBUF_INIT ;
43+ FILE * out ;
4544
46- prepare_pack_objects (& cmd , args , packtmp );
47- cmd .in = -1 ;
48-
49- /*
50- * NEEDSWORK: Giving pack-objects only the OIDs without any ordering
51- * hints may result in suboptimal deltas in the resulting pack. See if
52- * the OIDs can be sent with fake paths such that pack-objects can use a
53- * {type -> existing pack order} ordering when computing deltas instead
54- * of a {type -> size} ordering, which may produce better deltas.
55- */
56- ctx .cmd = & cmd ;
57- ctx .algop = repo -> hash_algo ;
58- for_each_packed_object (repo , write_oid , & ctx ,
59- FOR_EACH_OBJECT_PROMISOR_ONLY );
60-
61- if (cmd .in == -1 ) {
62- /* No packed objects; cmd was never started */
63- child_process_clear (& cmd );
64- return ;
65- }
66-
67- close (cmd .in );
45+ close (cmd -> in );
6846
69- out = xfdopen (cmd . out , "r" );
47+ out = xfdopen (cmd -> out , "r" );
7048 while (strbuf_getline_lf (& line , out ) != EOF ) {
7149 struct string_list_item * item ;
7250 char * promisor_name ;
@@ -96,7 +74,38 @@ void repack_promisor_objects(struct repository *repo,
9674 }
9775
9876 fclose (out );
99- if (finish_command (& cmd ))
77+ if (finish_command (cmd ))
10078 die (_ ("could not finish pack-objects to repack promisor objects" ));
10179 strbuf_release (& line );
10280}
81+
82+ void repack_promisor_objects (struct repository * repo ,
83+ const struct pack_objects_args * args ,
84+ struct string_list * names , const char * packtmp )
85+ {
86+ struct write_oid_context ctx ;
87+ struct child_process cmd = CHILD_PROCESS_INIT ;
88+
89+ prepare_pack_objects (& cmd , args , packtmp );
90+ cmd .in = -1 ;
91+
92+ /*
93+ * NEEDSWORK: Giving pack-objects only the OIDs without any ordering
94+ * hints may result in suboptimal deltas in the resulting pack. See if
95+ * the OIDs can be sent with fake paths such that pack-objects can use a
96+ * {type -> existing pack order} ordering when computing deltas instead
97+ * of a {type -> size} ordering, which may produce better deltas.
98+ */
99+ ctx .cmd = & cmd ;
100+ ctx .algop = repo -> hash_algo ;
101+ for_each_packed_object (repo , write_oid , & ctx ,
102+ FOR_EACH_OBJECT_PROMISOR_ONLY );
103+
104+ if (cmd .in == -1 ) {
105+ /* No packed objects; cmd was never started */
106+ child_process_clear (& cmd );
107+ return ;
108+ }
109+
110+ finish_repacking_promisor_objects (repo , & cmd , names , packtmp );
111+ }
0 commit comments