@@ -30,7 +30,8 @@ static int queue_has_nonstale(struct prio_queue *queue)
30
30
}
31
31
32
32
/* all input commits in one and twos[] must have been parsed! */
33
- static struct commit_list * paint_down_to_common (struct commit * one , int n ,
33
+ static struct commit_list * paint_down_to_common (struct repository * r ,
34
+ struct commit * one , int n ,
34
35
struct commit * * twos ,
35
36
int min_generation )
36
37
{
@@ -83,7 +84,7 @@ static struct commit_list *paint_down_to_common(struct commit *one, int n,
83
84
parents = parents -> next ;
84
85
if ((p -> object .flags & flags ) == flags )
85
86
continue ;
86
- if (parse_commit ( p ))
87
+ if (repo_parse_commit ( r , p ))
87
88
return NULL ;
88
89
p -> object .flags |= flags ;
89
90
prio_queue_put (& queue , p );
@@ -94,7 +95,9 @@ static struct commit_list *paint_down_to_common(struct commit *one, int n,
94
95
return result ;
95
96
}
96
97
97
- static struct commit_list * merge_bases_many (struct commit * one , int n , struct commit * * twos )
98
+ static struct commit_list * merge_bases_many (struct repository * r ,
99
+ struct commit * one , int n ,
100
+ struct commit * * twos )
98
101
{
99
102
struct commit_list * list = NULL ;
100
103
struct commit_list * result = NULL ;
@@ -109,14 +112,14 @@ static struct commit_list *merge_bases_many(struct commit *one, int n, struct co
109
112
return commit_list_insert (one , & result );
110
113
}
111
114
112
- if (parse_commit ( one ))
115
+ if (repo_parse_commit ( r , one ))
113
116
return NULL ;
114
117
for (i = 0 ; i < n ; i ++ ) {
115
- if (parse_commit ( twos [i ]))
118
+ if (repo_parse_commit ( r , twos [i ]))
116
119
return NULL ;
117
120
}
118
121
119
- list = paint_down_to_common (one , n , twos , 0 );
122
+ list = paint_down_to_common (r , one , n , twos , 0 );
120
123
121
124
while (list ) {
122
125
struct commit * commit = pop_commit (& list );
@@ -153,7 +156,7 @@ struct commit_list *get_octopus_merge_bases(struct commit_list *in)
153
156
return ret ;
154
157
}
155
158
156
- static int remove_redundant (struct commit * * array , int cnt )
159
+ static int remove_redundant (struct repository * r , struct commit * * array , int cnt )
157
160
{
158
161
/*
159
162
* Some commit in the array may be an ancestor of
@@ -171,7 +174,7 @@ static int remove_redundant(struct commit **array, int cnt)
171
174
ALLOC_ARRAY (filled_index , cnt - 1 );
172
175
173
176
for (i = 0 ; i < cnt ; i ++ )
174
- parse_commit ( array [i ]);
177
+ repo_parse_commit ( r , array [i ]);
175
178
for (i = 0 ; i < cnt ; i ++ ) {
176
179
struct commit_list * common ;
177
180
uint32_t min_generation = array [i ]-> generation ;
@@ -187,8 +190,8 @@ static int remove_redundant(struct commit **array, int cnt)
187
190
if (array [j ]-> generation < min_generation )
188
191
min_generation = array [j ]-> generation ;
189
192
}
190
- common = paint_down_to_common (array [i ], filled , work ,
191
- min_generation );
193
+ common = paint_down_to_common (r , array [i ], filled ,
194
+ work , min_generation );
192
195
if (array [i ]-> object .flags & PARENT2 )
193
196
redundant [i ] = 1 ;
194
197
for (j = 0 ; j < filled ; j ++ )
@@ -213,7 +216,8 @@ static int remove_redundant(struct commit **array, int cnt)
213
216
return filled ;
214
217
}
215
218
216
- static struct commit_list * get_merge_bases_many_0 (struct commit * one ,
219
+ static struct commit_list * get_merge_bases_many_0 (struct repository * r ,
220
+ struct commit * one ,
217
221
int n ,
218
222
struct commit * * twos ,
219
223
int cleanup )
@@ -223,7 +227,7 @@ static struct commit_list *get_merge_bases_many_0(struct commit *one,
223
227
struct commit_list * result ;
224
228
int cnt , i ;
225
229
226
- result = merge_bases_many (one , n , twos );
230
+ result = merge_bases_many (r , one , n , twos );
227
231
for (i = 0 ; i < n ; i ++ ) {
228
232
if (one == twos [i ])
229
233
return result ;
@@ -246,31 +250,35 @@ static struct commit_list *get_merge_bases_many_0(struct commit *one,
246
250
clear_commit_marks (one , all_flags );
247
251
clear_commit_marks_many (n , twos , all_flags );
248
252
249
- cnt = remove_redundant (rslt , cnt );
253
+ cnt = remove_redundant (r , rslt , cnt );
250
254
result = NULL ;
251
255
for (i = 0 ; i < cnt ; i ++ )
252
256
commit_list_insert_by_date (rslt [i ], & result );
253
257
free (rslt );
254
258
return result ;
255
259
}
256
260
257
- struct commit_list * get_merge_bases_many (struct commit * one ,
258
- int n ,
259
- struct commit * * twos )
261
+ struct commit_list * repo_get_merge_bases_many (struct repository * r ,
262
+ struct commit * one ,
263
+ int n ,
264
+ struct commit * * twos )
260
265
{
261
- return get_merge_bases_many_0 (one , n , twos , 1 );
266
+ return get_merge_bases_many_0 (r , one , n , twos , 1 );
262
267
}
263
268
264
- struct commit_list * get_merge_bases_many_dirty (struct commit * one ,
265
- int n ,
266
- struct commit * * twos )
269
+ struct commit_list * repo_get_merge_bases_many_dirty (struct repository * r ,
270
+ struct commit * one ,
271
+ int n ,
272
+ struct commit * * twos )
267
273
{
268
- return get_merge_bases_many_0 (one , n , twos , 0 );
274
+ return get_merge_bases_many_0 (r , one , n , twos , 0 );
269
275
}
270
276
271
- struct commit_list * get_merge_bases (struct commit * one , struct commit * two )
277
+ struct commit_list * repo_get_merge_bases (struct repository * r ,
278
+ struct commit * one ,
279
+ struct commit * two )
272
280
{
273
- return get_merge_bases_many_0 (one , 1 , & two , 1 );
281
+ return get_merge_bases_many_0 (r , one , 1 , & two , 1 );
274
282
}
275
283
276
284
/*
@@ -304,16 +312,17 @@ int is_descendant_of(struct commit *commit, struct commit_list *with_commit)
304
312
/*
305
313
* Is "commit" an ancestor of one of the "references"?
306
314
*/
307
- int in_merge_bases_many (struct commit * commit , int nr_reference , struct commit * * reference )
315
+ int repo_in_merge_bases_many (struct repository * r , struct commit * commit ,
316
+ int nr_reference , struct commit * * reference )
308
317
{
309
318
struct commit_list * bases ;
310
319
int ret = 0 , i ;
311
320
uint32_t min_generation = GENERATION_NUMBER_INFINITY ;
312
321
313
- if (parse_commit ( commit ))
322
+ if (repo_parse_commit ( r , commit ))
314
323
return ret ;
315
324
for (i = 0 ; i < nr_reference ; i ++ ) {
316
- if (parse_commit ( reference [i ]))
325
+ if (repo_parse_commit ( r , reference [i ]))
317
326
return ret ;
318
327
if (reference [i ]-> generation < min_generation )
319
328
min_generation = reference [i ]-> generation ;
@@ -322,7 +331,9 @@ int in_merge_bases_many(struct commit *commit, int nr_reference, struct commit *
322
331
if (commit -> generation > min_generation )
323
332
return ret ;
324
333
325
- bases = paint_down_to_common (commit , nr_reference , reference , commit -> generation );
334
+ bases = paint_down_to_common (r , commit ,
335
+ nr_reference , reference ,
336
+ commit -> generation );
326
337
if (commit -> object .flags & PARENT2 )
327
338
ret = 1 ;
328
339
clear_commit_marks (commit , all_flags );
@@ -334,9 +345,11 @@ int in_merge_bases_many(struct commit *commit, int nr_reference, struct commit *
334
345
/*
335
346
* Is "commit" an ancestor of (i.e. reachable from) the "reference"?
336
347
*/
337
- int in_merge_bases (struct commit * commit , struct commit * reference )
348
+ int repo_in_merge_bases (struct repository * r ,
349
+ struct commit * commit ,
350
+ struct commit * reference )
338
351
{
339
- return in_merge_bases_many ( commit , 1 , & reference );
352
+ return repo_in_merge_bases_many ( r , commit , 1 , & reference );
340
353
}
341
354
342
355
struct commit_list * reduce_heads (struct commit_list * heads )
@@ -365,7 +378,7 @@ struct commit_list *reduce_heads(struct commit_list *heads)
365
378
p -> item -> object .flags &= ~STALE ;
366
379
}
367
380
}
368
- num_head = remove_redundant (array , num_head );
381
+ num_head = remove_redundant (the_repository , array , num_head );
369
382
for (i = 0 ; i < num_head ; i ++ )
370
383
tail = & commit_list_insert (array [i ], tail )-> next ;
371
384
free (array );
0 commit comments