4 #include "repository.h"
7 #include "object-store.h"
13 #include "oid-array.h"
16 #include "commit-slab.h"
17 #include "list-objects.h"
18 #include "commit-reach.h"
23 void set_alternate_shallow_file(struct repository
*r
, const char *path
, int override
)
25 if (r
->parsed_objects
->is_shallow
!= -1)
26 BUG("is_repository_shallow must not be called before set_alternate_shallow_file");
27 if (r
->parsed_objects
->alternate_shallow_file
&& !override
)
29 free(r
->parsed_objects
->alternate_shallow_file
);
30 r
->parsed_objects
->alternate_shallow_file
= xstrdup_or_null(path
);
33 int register_shallow(struct repository
*r
, const struct object_id
*oid
)
35 struct commit_graft
*graft
=
36 xmalloc(sizeof(struct commit_graft
));
37 struct commit
*commit
= lookup_commit(r
, oid
);
39 oidcpy(&graft
->oid
, oid
);
40 graft
->nr_parent
= -1;
41 if (commit
&& commit
->object
.parsed
)
42 commit
->parents
= NULL
;
43 return register_commit_graft(r
, graft
, 0);
46 int unregister_shallow(const struct object_id
*oid
)
48 int pos
= commit_graft_pos(the_repository
, oid
);
51 if (pos
+ 1 < the_repository
->parsed_objects
->grafts_nr
)
52 MOVE_ARRAY(the_repository
->parsed_objects
->grafts
+ pos
,
53 the_repository
->parsed_objects
->grafts
+ pos
+ 1,
54 the_repository
->parsed_objects
->grafts_nr
- pos
- 1);
55 the_repository
->parsed_objects
->grafts_nr
--;
59 int is_repository_shallow(struct repository
*r
)
63 const char *path
= r
->parsed_objects
->alternate_shallow_file
;
65 if (r
->parsed_objects
->is_shallow
>= 0)
66 return r
->parsed_objects
->is_shallow
;
69 path
= git_path_shallow(r
);
71 * fetch-pack sets '--shallow-file ""' as an indicator that no
72 * shallow file should be used. We could just open it and it
73 * will likely fail. But let's do an explicit check instead.
75 if (!*path
|| (fp
= fopen(path
, "r")) == NULL
) {
76 stat_validity_clear(r
->parsed_objects
->shallow_stat
);
77 r
->parsed_objects
->is_shallow
= 0;
78 return r
->parsed_objects
->is_shallow
;
80 stat_validity_update(r
->parsed_objects
->shallow_stat
, fileno(fp
));
81 r
->parsed_objects
->is_shallow
= 1;
83 while (fgets(buf
, sizeof(buf
), fp
)) {
85 if (get_oid_hex(buf
, &oid
))
86 die("bad shallow line: %s", buf
);
87 register_shallow(r
, &oid
);
90 return r
->parsed_objects
->is_shallow
;
93 static void reset_repository_shallow(struct repository
*r
)
95 r
->parsed_objects
->is_shallow
= -1;
96 stat_validity_clear(r
->parsed_objects
->shallow_stat
);
97 reset_commit_grafts(r
);
100 int commit_shallow_file(struct repository
*r
, struct shallow_lock
*lk
)
102 int res
= commit_lock_file(&lk
->lock
);
103 reset_repository_shallow(r
);
106 * Update in-memory data structures with the new shallow information,
107 * including unparsing all commits that now have grafts.
109 is_repository_shallow(r
);
114 void rollback_shallow_file(struct repository
*r
, struct shallow_lock
*lk
)
116 rollback_lock_file(&lk
->lock
);
117 reset_repository_shallow(r
);
121 * TODO: use "int" elemtype instead of "int *" when/if commit-slab
122 * supports a "valid" flag.
124 define_commit_slab(commit_depth
, int *);
125 static void free_depth_in_slab(int **ptr
)
129 struct commit_list
*get_shallow_commits(struct object_array
*heads
, int depth
,
130 int shallow_flag
, int not_shallow_flag
)
132 int i
= 0, cur_depth
= 0;
133 struct commit_list
*result
= NULL
;
134 struct object_array stack
= OBJECT_ARRAY_INIT
;
135 struct commit
*commit
= NULL
;
136 struct commit_graft
*graft
;
137 struct commit_depth depths
;
139 init_commit_depth(&depths
);
140 while (commit
|| i
< heads
->nr
|| stack
.nr
) {
141 struct commit_list
*p
;
145 commit
= (struct commit
*)
146 deref_tag(the_repository
,
147 heads
->objects
[i
++].item
,
149 if (!commit
|| commit
->object
.type
!= OBJ_COMMIT
) {
153 depth_slot
= commit_depth_at(&depths
, commit
);
155 *depth_slot
= xmalloc(sizeof(int));
159 commit
= (struct commit
*)
160 object_array_pop(&stack
);
161 cur_depth
= **commit_depth_at(&depths
, commit
);
164 parse_commit_or_die(commit
);
166 if ((depth
!= INFINITE_DEPTH
&& cur_depth
>= depth
) ||
167 (is_repository_shallow(the_repository
) && !commit
->parents
&&
168 (graft
= lookup_commit_graft(the_repository
, &commit
->object
.oid
)) != NULL
&&
169 graft
->nr_parent
< 0)) {
170 commit_list_insert(commit
, &result
);
171 commit
->object
.flags
|= shallow_flag
;
175 commit
->object
.flags
|= not_shallow_flag
;
176 for (p
= commit
->parents
, commit
= NULL
; p
; p
= p
->next
) {
177 int **depth_slot
= commit_depth_at(&depths
, p
->item
);
179 *depth_slot
= xmalloc(sizeof(int));
180 **depth_slot
= cur_depth
;
182 if (cur_depth
>= **depth_slot
)
184 **depth_slot
= cur_depth
;
187 add_object_array(&p
->item
->object
,
191 cur_depth
= **commit_depth_at(&depths
, commit
);
195 deep_clear_commit_depth(&depths
, free_depth_in_slab
);
200 static void show_commit(struct commit
*commit
, void *data
)
202 commit_list_insert(commit
, data
);
206 * Given rev-list arguments, run rev-list. All reachable commits
207 * except border ones are marked with not_shallow_flag. Border commits
208 * are marked with shallow_flag. The list of border/shallow commits
211 struct commit_list
*get_shallow_commits_by_rev_list(int ac
, const char **av
,
213 int not_shallow_flag
)
215 struct commit_list
*result
= NULL
, *p
;
216 struct commit_list
*not_shallow_list
= NULL
;
217 struct rev_info revs
;
218 int both_flags
= shallow_flag
| not_shallow_flag
;
221 * SHALLOW (excluded) and NOT_SHALLOW (included) should not be
222 * set at this point. But better be safe than sorry.
224 clear_object_flags(both_flags
);
226 is_repository_shallow(the_repository
); /* make sure shallows are read */
228 repo_init_revisions(the_repository
, &revs
, NULL
);
229 save_commit_buffer
= 0;
230 setup_revisions(ac
, av
, &revs
, NULL
);
232 if (prepare_revision_walk(&revs
))
233 die("revision walk setup failed");
234 traverse_commit_list(&revs
, show_commit
, NULL
, ¬_shallow_list
);
236 if (!not_shallow_list
)
237 die("no commits selected for shallow requests");
239 /* Mark all reachable commits as NOT_SHALLOW */
240 for (p
= not_shallow_list
; p
; p
= p
->next
)
241 p
->item
->object
.flags
|= not_shallow_flag
;
244 * mark border commits SHALLOW + NOT_SHALLOW.
245 * We cannot clear NOT_SHALLOW right now. Imagine border
246 * commit A is processed first, then commit B, whose parent is
247 * A, later. If NOT_SHALLOW on A is cleared at step 1, B
248 * itself is considered border at step 2, which is incorrect.
250 for (p
= not_shallow_list
; p
; p
= p
->next
) {
251 struct commit
*c
= p
->item
;
252 struct commit_list
*parent
;
254 if (repo_parse_commit(the_repository
, c
))
255 die("unable to parse commit %s",
256 oid_to_hex(&c
->object
.oid
));
258 for (parent
= c
->parents
; parent
; parent
= parent
->next
)
259 if (!(parent
->item
->object
.flags
& not_shallow_flag
)) {
260 c
->object
.flags
|= shallow_flag
;
261 commit_list_insert(c
, &result
);
265 free_commit_list(not_shallow_list
);
268 * Now we can clean up NOT_SHALLOW on border commits. Having
269 * both flags set can confuse the caller.
271 for (p
= result
; p
; p
= p
->next
) {
272 struct object
*o
= &p
->item
->object
;
273 if ((o
->flags
& both_flags
) == both_flags
)
274 o
->flags
&= ~not_shallow_flag
;
276 release_revisions(&revs
);
280 static void check_shallow_file_for_update(struct repository
*r
)
282 if (r
->parsed_objects
->is_shallow
== -1)
283 BUG("shallow must be initialized by now");
285 if (!stat_validity_check(r
->parsed_objects
->shallow_stat
,
286 git_path_shallow(r
)))
287 die("shallow file has changed since we read it");
294 struct write_shallow_data
{
296 int use_pack_protocol
;
301 static int write_one_shallow(const struct commit_graft
*graft
, void *cb_data
)
303 struct write_shallow_data
*data
= cb_data
;
304 const char *hex
= oid_to_hex(&graft
->oid
);
305 if (graft
->nr_parent
!= -1)
307 if (data
->flags
& QUICK
) {
308 if (!repo_has_object_file(the_repository
, &graft
->oid
))
310 } else if (data
->flags
& SEEN_ONLY
) {
311 struct commit
*c
= lookup_commit(the_repository
, &graft
->oid
);
312 if (!c
|| !(c
->object
.flags
& SEEN
)) {
313 if (data
->flags
& VERBOSE
)
314 printf("Removing %s from .git/shallow\n",
315 oid_to_hex(&c
->object
.oid
));
320 if (data
->use_pack_protocol
)
321 packet_buf_write(data
->out
, "shallow %s", hex
);
323 strbuf_addstr(data
->out
, hex
);
324 strbuf_addch(data
->out
, '\n');
329 static int write_shallow_commits_1(struct strbuf
*out
, int use_pack_protocol
,
330 const struct oid_array
*extra
,
333 struct write_shallow_data data
;
336 data
.use_pack_protocol
= use_pack_protocol
;
339 for_each_commit_graft(write_one_shallow
, &data
);
342 for (i
= 0; i
< extra
->nr
; i
++) {
343 strbuf_addstr(out
, oid_to_hex(extra
->oid
+ i
));
344 strbuf_addch(out
, '\n');
350 int write_shallow_commits(struct strbuf
*out
, int use_pack_protocol
,
351 const struct oid_array
*extra
)
353 return write_shallow_commits_1(out
, use_pack_protocol
, extra
, 0);
356 const char *setup_temporary_shallow(const struct oid_array
*extra
)
358 struct tempfile
*temp
;
359 struct strbuf sb
= STRBUF_INIT
;
361 if (write_shallow_commits(&sb
, 0, extra
)) {
362 temp
= xmks_tempfile(git_path("shallow_XXXXXX"));
364 if (write_in_full(temp
->fd
, sb
.buf
, sb
.len
) < 0 ||
365 close_tempfile_gently(temp
) < 0)
366 die_errno("failed to write to %s",
367 get_tempfile_path(temp
));
369 return get_tempfile_path(temp
);
372 * is_repository_shallow() sees empty string as "no shallow
378 void setup_alternate_shallow(struct shallow_lock
*shallow_lock
,
379 const char **alternate_shallow_file
,
380 const struct oid_array
*extra
)
382 struct strbuf sb
= STRBUF_INIT
;
385 fd
= hold_lock_file_for_update(&shallow_lock
->lock
,
386 git_path_shallow(the_repository
),
388 check_shallow_file_for_update(the_repository
);
389 if (write_shallow_commits(&sb
, 0, extra
)) {
390 if (write_in_full(fd
, sb
.buf
, sb
.len
) < 0)
391 die_errno("failed to write to %s",
392 get_lock_file_path(&shallow_lock
->lock
));
393 *alternate_shallow_file
= get_lock_file_path(&shallow_lock
->lock
);
396 * is_repository_shallow() sees empty string as "no
399 *alternate_shallow_file
= "";
403 static int advertise_shallow_grafts_cb(const struct commit_graft
*graft
, void *cb
)
406 if (graft
->nr_parent
== -1)
407 packet_write_fmt(fd
, "shallow %s\n", oid_to_hex(&graft
->oid
));
411 void advertise_shallow_grafts(int fd
)
413 if (!is_repository_shallow(the_repository
))
415 for_each_commit_graft(advertise_shallow_grafts_cb
, &fd
);
419 * mark_reachable_objects() should have been run prior to this and all
420 * reachable commits marked as "SEEN", except when quick_prune is non-zero,
421 * in which case lines are excised from the shallow file if they refer to
422 * commits that do not exist (any longer).
424 void prune_shallow(unsigned options
)
426 struct shallow_lock shallow_lock
= SHALLOW_LOCK_INIT
;
427 struct strbuf sb
= STRBUF_INIT
;
428 unsigned flags
= SEEN_ONLY
;
431 if (options
& PRUNE_QUICK
)
434 if (options
& PRUNE_SHOW_ONLY
) {
436 write_shallow_commits_1(&sb
, 0, NULL
, flags
);
440 fd
= hold_lock_file_for_update(&shallow_lock
.lock
,
441 git_path_shallow(the_repository
),
443 check_shallow_file_for_update(the_repository
);
444 if (write_shallow_commits_1(&sb
, 0, NULL
, flags
)) {
445 if (write_in_full(fd
, sb
.buf
, sb
.len
) < 0)
446 die_errno("failed to write to %s",
447 get_lock_file_path(&shallow_lock
.lock
));
448 commit_shallow_file(the_repository
, &shallow_lock
);
450 unlink(git_path_shallow(the_repository
));
451 rollback_shallow_file(the_repository
, &shallow_lock
);
456 struct trace_key trace_shallow
= TRACE_KEY_INIT(SHALLOW
);
459 * Step 1, split sender shallow commits into "ours" and "theirs"
460 * Step 2, clean "ours" based on .git/shallow
462 void prepare_shallow_info(struct shallow_info
*info
, struct oid_array
*sa
)
465 trace_printf_key(&trace_shallow
, "shallow: prepare_shallow_info\n");
466 memset(info
, 0, sizeof(*info
));
470 ALLOC_ARRAY(info
->ours
, sa
->nr
);
471 ALLOC_ARRAY(info
->theirs
, sa
->nr
);
472 for (i
= 0; i
< sa
->nr
; i
++) {
473 if (repo_has_object_file(the_repository
, sa
->oid
+ i
)) {
474 struct commit_graft
*graft
;
475 graft
= lookup_commit_graft(the_repository
,
477 if (graft
&& graft
->nr_parent
< 0)
479 info
->ours
[info
->nr_ours
++] = i
;
481 info
->theirs
[info
->nr_theirs
++] = i
;
485 void clear_shallow_info(struct shallow_info
*info
)
491 /* Step 4, remove non-existent ones in "theirs" after getting the pack */
493 void remove_nonexistent_theirs_shallow(struct shallow_info
*info
)
495 struct object_id
*oid
= info
->shallow
->oid
;
497 trace_printf_key(&trace_shallow
, "shallow: remove_nonexistent_theirs_shallow\n");
498 for (i
= dst
= 0; i
< info
->nr_theirs
; i
++) {
500 info
->theirs
[dst
] = info
->theirs
[i
];
501 if (repo_has_object_file(the_repository
, oid
+ info
->theirs
[i
]))
504 info
->nr_theirs
= dst
;
507 define_commit_slab(ref_bitmap
, uint32_t *);
509 #define POOL_SIZE (512 * 1024)
512 struct ref_bitmap ref_bitmap
;
519 static uint32_t *paint_alloc(struct paint_info
*info
)
521 unsigned nr
= DIV_ROUND_UP(info
->nr_bits
, 32);
522 unsigned size
= nr
* sizeof(uint32_t);
524 if (!info
->pool_count
|| size
> info
->end
- info
->free
) {
525 if (size
> POOL_SIZE
)
526 BUG("pool size too small for %d in paint_alloc()",
529 REALLOC_ARRAY(info
->pools
, info
->pool_count
);
530 info
->free
= xmalloc(POOL_SIZE
);
531 info
->pools
[info
->pool_count
- 1] = info
->free
;
532 info
->end
= info
->free
+ POOL_SIZE
;
540 * Given a commit SHA-1, walk down to parents until either SEEN,
541 * UNINTERESTING or BOTTOM is hit. Set the id-th bit in ref_bitmap for
542 * all walked commits.
544 static void paint_down(struct paint_info
*info
, const struct object_id
*oid
,
548 struct commit_list
*head
= NULL
;
549 int bitmap_nr
= DIV_ROUND_UP(info
->nr_bits
, 32);
550 size_t bitmap_size
= st_mult(sizeof(uint32_t), bitmap_nr
);
551 struct commit
*c
= lookup_commit_reference_gently(the_repository
, oid
,
553 uint32_t *tmp
; /* to be freed before return */
559 tmp
= xmalloc(bitmap_size
);
560 bitmap
= paint_alloc(info
);
561 memset(bitmap
, 0, bitmap_size
);
562 bitmap
[id
/ 32] |= (1U << (id
% 32));
563 commit_list_insert(c
, &head
);
565 struct commit_list
*p
;
566 struct commit
*c
= pop_commit(&head
);
567 uint32_t **refs
= ref_bitmap_at(&info
->ref_bitmap
, c
);
569 /* XXX check "UNINTERESTING" from pack bitmaps if available */
570 if (c
->object
.flags
& (SEEN
| UNINTERESTING
))
573 c
->object
.flags
|= SEEN
;
578 memcpy(tmp
, *refs
, bitmap_size
);
579 for (i
= 0; i
< bitmap_nr
; i
++)
581 if (memcmp(tmp
, *refs
, bitmap_size
)) {
582 *refs
= paint_alloc(info
);
583 memcpy(*refs
, tmp
, bitmap_size
);
587 if (c
->object
.flags
& BOTTOM
)
590 if (repo_parse_commit(the_repository
, c
))
591 die("unable to parse commit %s",
592 oid_to_hex(&c
->object
.oid
));
594 for (p
= c
->parents
; p
; p
= p
->next
) {
595 if (p
->item
->object
.flags
& SEEN
)
597 commit_list_insert(p
->item
, &head
);
601 nr
= get_max_object_index();
602 for (i
= 0; i
< nr
; i
++) {
603 struct object
*o
= get_indexed_object(i
);
604 if (o
&& o
->type
== OBJ_COMMIT
)
611 static int mark_uninteresting(const char *refname UNUSED
,
612 const struct object_id
*oid
,
614 void *cb_data UNUSED
)
616 struct commit
*commit
= lookup_commit_reference_gently(the_repository
,
620 commit
->object
.flags
|= UNINTERESTING
;
621 mark_parents_uninteresting(NULL
, commit
);
625 static void post_assign_shallow(struct shallow_info
*info
,
626 struct ref_bitmap
*ref_bitmap
,
629 * Step 6(+7), associate shallow commits with new refs
631 * info->ref must be initialized before calling this function.
633 * If used is not NULL, it's an array of info->shallow->nr
634 * bitmaps. The n-th bit set in the m-th bitmap if ref[n] needs the
635 * m-th shallow commit from info->shallow.
637 * If used is NULL, "ours" and "theirs" are updated. And if ref_status
638 * is not NULL it's an array of ref->nr ints. ref_status[i] is true if
639 * the ref needs some shallow commits from either info->ours or
642 void assign_shallow_commits_to_refs(struct shallow_info
*info
,
643 uint32_t **used
, int *ref_status
)
645 struct object_id
*oid
= info
->shallow
->oid
;
646 struct oid_array
*ref
= info
->ref
;
648 int *shallow
, nr_shallow
= 0;
649 struct paint_info pi
;
651 trace_printf_key(&trace_shallow
, "shallow: assign_shallow_commits_to_refs\n");
652 ALLOC_ARRAY(shallow
, info
->nr_ours
+ info
->nr_theirs
);
653 for (i
= 0; i
< info
->nr_ours
; i
++)
654 shallow
[nr_shallow
++] = info
->ours
[i
];
655 for (i
= 0; i
< info
->nr_theirs
; i
++)
656 shallow
[nr_shallow
++] = info
->theirs
[i
];
659 * Prepare the commit graph to track what refs can reach what
660 * (new) shallow commits.
662 nr
= get_max_object_index();
663 for (i
= 0; i
< nr
; i
++) {
664 struct object
*o
= get_indexed_object(i
);
665 if (!o
|| o
->type
!= OBJ_COMMIT
)
668 o
->flags
&= ~(UNINTERESTING
| BOTTOM
| SEEN
);
671 memset(&pi
, 0, sizeof(pi
));
672 init_ref_bitmap(&pi
.ref_bitmap
);
673 pi
.nr_bits
= ref
->nr
;
676 * "--not --all" to cut short the traversal if new refs
677 * connect to old refs. If not (e.g. force ref updates) it'll
678 * have to go down to the current shallow commits.
680 head_ref(mark_uninteresting
, NULL
);
681 for_each_ref(mark_uninteresting
, NULL
);
683 /* Mark potential bottoms so we won't go out of bound */
684 for (i
= 0; i
< nr_shallow
; i
++) {
685 struct commit
*c
= lookup_commit(the_repository
,
687 c
->object
.flags
|= BOTTOM
;
690 for (i
= 0; i
< ref
->nr
; i
++)
691 paint_down(&pi
, ref
->oid
+ i
, i
);
694 int bitmap_size
= DIV_ROUND_UP(pi
.nr_bits
, 32) * sizeof(uint32_t);
695 memset(used
, 0, sizeof(*used
) * info
->shallow
->nr
);
696 for (i
= 0; i
< nr_shallow
; i
++) {
697 const struct commit
*c
= lookup_commit(the_repository
,
699 uint32_t **map
= ref_bitmap_at(&pi
.ref_bitmap
, c
);
701 used
[shallow
[i
]] = xmemdupz(*map
, bitmap_size
);
704 * unreachable shallow commits are not removed from
705 * "ours" and "theirs". The user is supposed to run
706 * step 7 on every ref separately and not trust "ours"
707 * and "theirs" any more.
710 post_assign_shallow(info
, &pi
.ref_bitmap
, ref_status
);
712 clear_ref_bitmap(&pi
.ref_bitmap
);
713 for (i
= 0; i
< pi
.pool_count
; i
++)
719 struct commit_array
{
720 struct commit
**commits
;
724 static int add_ref(const char *refname UNUSED
,
725 const struct object_id
*oid
,
729 struct commit_array
*ca
= cb_data
;
730 ALLOC_GROW(ca
->commits
, ca
->nr
+ 1, ca
->alloc
);
731 ca
->commits
[ca
->nr
] = lookup_commit_reference_gently(the_repository
,
733 if (ca
->commits
[ca
->nr
])
738 static void update_refstatus(int *ref_status
, int nr
, uint32_t *bitmap
)
743 for (i
= 0; i
< nr
; i
++)
744 if (bitmap
[i
/ 32] & (1U << (i
% 32)))
749 * Step 7, reachability test on "ours" at commit level
751 static void post_assign_shallow(struct shallow_info
*info
,
752 struct ref_bitmap
*ref_bitmap
,
755 struct object_id
*oid
= info
->shallow
->oid
;
759 int bitmap_nr
= DIV_ROUND_UP(info
->ref
->nr
, 32);
760 struct commit_array ca
;
762 trace_printf_key(&trace_shallow
, "shallow: post_assign_shallow\n");
764 memset(ref_status
, 0, sizeof(*ref_status
) * info
->ref
->nr
);
766 /* Remove unreachable shallow commits from "theirs" */
767 for (i
= dst
= 0; i
< info
->nr_theirs
; i
++) {
769 info
->theirs
[dst
] = info
->theirs
[i
];
770 c
= lookup_commit(the_repository
, &oid
[info
->theirs
[i
]]);
771 bitmap
= ref_bitmap_at(ref_bitmap
, c
);
774 for (j
= 0; j
< bitmap_nr
; j
++)
776 update_refstatus(ref_status
, info
->ref
->nr
, *bitmap
);
781 info
->nr_theirs
= dst
;
783 memset(&ca
, 0, sizeof(ca
));
784 head_ref(add_ref
, &ca
);
785 for_each_ref(add_ref
, &ca
);
787 /* Remove unreachable shallow commits from "ours" */
788 for (i
= dst
= 0; i
< info
->nr_ours
; i
++) {
790 info
->ours
[dst
] = info
->ours
[i
];
791 c
= lookup_commit(the_repository
, &oid
[info
->ours
[i
]]);
792 bitmap
= ref_bitmap_at(ref_bitmap
, c
);
795 for (j
= 0; j
< bitmap_nr
; j
++)
797 /* Step 7, reachability test at commit level */
798 !repo_in_merge_bases_many(the_repository
, c
, ca
.nr
, ca
.commits
)) {
799 update_refstatus(ref_status
, info
->ref
->nr
, *bitmap
);
809 /* (Delayed) step 7, reachability test at commit level */
810 int delayed_reachability_test(struct shallow_info
*si
, int c
)
812 if (si
->need_reachability_test
[c
]) {
813 struct commit
*commit
= lookup_commit(the_repository
,
814 &si
->shallow
->oid
[c
]);
817 struct commit_array ca
;
819 memset(&ca
, 0, sizeof(ca
));
820 head_ref(add_ref
, &ca
);
821 for_each_ref(add_ref
, &ca
);
822 si
->commits
= ca
.commits
;
823 si
->nr_commits
= ca
.nr
;
826 si
->reachable
[c
] = repo_in_merge_bases_many(the_repository
,
830 si
->need_reachability_test
[c
] = 0;
832 return si
->reachable
[c
];