File tree Expand file tree Collapse file tree 3 files changed +30
-19
lines changed Expand file tree Collapse file tree 3 files changed +30
-19
lines changed Original file line number Diff line number Diff line change @@ -185,6 +185,36 @@ static void consume_shallow_list(int fd)
185
185
}
186
186
}
187
187
188
+ struct write_shallow_data {
189
+ struct strbuf * out ;
190
+ int use_pack_protocol ;
191
+ int count ;
192
+ };
193
+
194
+ static int write_one_shallow (const struct commit_graft * graft , void * cb_data )
195
+ {
196
+ struct write_shallow_data * data = cb_data ;
197
+ const char * hex = sha1_to_hex (graft -> sha1 );
198
+ data -> count ++ ;
199
+ if (data -> use_pack_protocol )
200
+ packet_buf_write (data -> out , "shallow %s" , hex );
201
+ else {
202
+ strbuf_addstr (data -> out , hex );
203
+ strbuf_addch (data -> out , '\n' );
204
+ }
205
+ return 0 ;
206
+ }
207
+
208
+ static int write_shallow_commits (struct strbuf * out , int use_pack_protocol )
209
+ {
210
+ struct write_shallow_data data ;
211
+ data .out = out ;
212
+ data .use_pack_protocol = use_pack_protocol ;
213
+ data .count = 0 ;
214
+ for_each_commit_graft (write_one_shallow , & data );
215
+ return data .count ;
216
+ }
217
+
188
218
static enum ack_type get_ack (int fd , unsigned char * result_sha1 )
189
219
{
190
220
static char line [1000 ];
Original file line number Diff line number Diff line change @@ -222,24 +222,6 @@ int for_each_commit_graft(each_commit_graft_fn fn, void *cb_data)
222
222
return ret ;
223
223
}
224
224
225
- int write_shallow_commits (struct strbuf * out , int use_pack_protocol )
226
- {
227
- int i , count = 0 ;
228
- for (i = 0 ; i < commit_graft_nr ; i ++ )
229
- if (commit_graft [i ]-> nr_parent < 0 ) {
230
- const char * hex =
231
- sha1_to_hex (commit_graft [i ]-> sha1 );
232
- count ++ ;
233
- if (use_pack_protocol )
234
- packet_buf_write (out , "shallow %s" , hex );
235
- else {
236
- strbuf_addstr (out , hex );
237
- strbuf_addch (out , '\n' );
238
- }
239
- }
240
- return count ;
241
- }
242
-
243
225
int unregister_shallow (const unsigned char * sha1 )
244
226
{
245
227
int pos = commit_graft_pos (sha1 );
Original file line number Diff line number Diff line change @@ -154,7 +154,6 @@ extern struct commit_list *get_octopus_merge_bases(struct commit_list *in);
154
154
155
155
extern int register_shallow (const unsigned char * sha1 );
156
156
extern int unregister_shallow (const unsigned char * sha1 );
157
- extern int write_shallow_commits (struct strbuf * out , int use_pack_protocol );
158
157
extern int for_each_commit_graft (each_commit_graft_fn , void * );
159
158
extern int is_repository_shallow (void );
160
159
extern struct commit_list * get_shallow_commits (struct object_array * heads ,
You can’t perform that action at this time.
0 commit comments