1 #include "git-compat-util.h"
3 #include "repository.h"
6 #include "object-store-ll.h"
12 #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 free_commit_list(commit
->parents
);
43 commit
->parents
= NULL
;
45 return register_commit_graft(r
, graft
, 0);
48 int unregister_shallow(const struct object_id
*oid
)
50 int pos
= commit_graft_pos(the_repository
, oid
);
53 if (pos
+ 1 < the_repository
->parsed_objects
->grafts_nr
)
54 MOVE_ARRAY(the_repository
->parsed_objects
->grafts
+ pos
,
55 the_repository
->parsed_objects
->grafts
+ pos
+ 1,
56 the_repository
->parsed_objects
->grafts_nr
- pos
- 1);
57 the_repository
->parsed_objects
->grafts_nr
--;
61 int is_repository_shallow(struct repository
*r
)
65 const char *path
= r
->parsed_objects
->alternate_shallow_file
;
67 if (r
->parsed_objects
->is_shallow
>= 0)
68 return r
->parsed_objects
->is_shallow
;
71 path
= git_path_shallow(r
);
73 * fetch-pack sets '--shallow-file ""' as an indicator that no
74 * shallow file should be used. We could just open it and it
75 * will likely fail. But let's do an explicit check instead.
77 if (!*path
|| (fp
= fopen(path
, "r")) == NULL
) {
78 stat_validity_clear(r
->parsed_objects
->shallow_stat
);
79 r
->parsed_objects
->is_shallow
= 0;
80 return r
->parsed_objects
->is_shallow
;
82 stat_validity_update(r
->parsed_objects
->shallow_stat
, fileno(fp
));
83 r
->parsed_objects
->is_shallow
= 1;
85 while (fgets(buf
, sizeof(buf
), fp
)) {
87 if (get_oid_hex(buf
, &oid
))
88 die("bad shallow line: %s", buf
);
89 register_shallow(r
, &oid
);
92 return r
->parsed_objects
->is_shallow
;
95 static void reset_repository_shallow(struct repository
*r
)
97 r
->parsed_objects
->is_shallow
= -1;
98 stat_validity_clear(r
->parsed_objects
->shallow_stat
);
99 reset_commit_grafts(r
);
102 int commit_shallow_file(struct repository
*r
, struct shallow_lock
*lk
)
104 int res
= commit_lock_file(&lk
->lock
);
105 reset_repository_shallow(r
);
108 * Update in-memory data structures with the new shallow information,
109 * including unparsing all commits that now have grafts.
111 is_repository_shallow(r
);
116 void rollback_shallow_file(struct repository
*r
, struct shallow_lock
*lk
)
118 rollback_lock_file(&lk
->lock
);
119 reset_repository_shallow(r
);
123 * TODO: use "int" elemtype instead of "int *" when/if commit-slab
124 * supports a "valid" flag.
126 define_commit_slab(commit_depth
, int *);
127 static void free_depth_in_slab(int **ptr
)
131 struct commit_list
*get_shallow_commits(struct object_array
*heads
, int depth
,
132 int shallow_flag
, int not_shallow_flag
)
134 int i
= 0, cur_depth
= 0;
135 struct commit_list
*result
= NULL
;
136 struct object_array stack
= OBJECT_ARRAY_INIT
;
137 struct commit
*commit
= NULL
;
138 struct commit_graft
*graft
;
139 struct commit_depth depths
;
141 init_commit_depth(&depths
);
142 while (commit
|| i
< heads
->nr
|| stack
.nr
) {
143 struct commit_list
*p
;
147 commit
= (struct commit
*)
148 deref_tag(the_repository
,
149 heads
->objects
[i
++].item
,
151 if (!commit
|| commit
->object
.type
!= OBJ_COMMIT
) {
155 depth_slot
= commit_depth_at(&depths
, commit
);
157 *depth_slot
= xmalloc(sizeof(int));
161 commit
= (struct commit
*)
162 object_array_pop(&stack
);
163 cur_depth
= **commit_depth_at(&depths
, commit
);
166 parse_commit_or_die(commit
);
168 if ((depth
!= INFINITE_DEPTH
&& cur_depth
>= depth
) ||
169 (is_repository_shallow(the_repository
) && !commit
->parents
&&
170 (graft
= lookup_commit_graft(the_repository
, &commit
->object
.oid
)) != NULL
&&
171 graft
->nr_parent
< 0)) {
172 commit_list_insert(commit
, &result
);
173 commit
->object
.flags
|= shallow_flag
;
177 commit
->object
.flags
|= not_shallow_flag
;
178 for (p
= commit
->parents
, commit
= NULL
; p
; p
= p
->next
) {
179 int **depth_slot
= commit_depth_at(&depths
, p
->item
);
181 *depth_slot
= xmalloc(sizeof(int));
182 **depth_slot
= cur_depth
;
184 if (cur_depth
>= **depth_slot
)
186 **depth_slot
= cur_depth
;
189 add_object_array(&p
->item
->object
,
193 cur_depth
= **commit_depth_at(&depths
, commit
);
197 deep_clear_commit_depth(&depths
, free_depth_in_slab
);
202 static void show_commit(struct commit
*commit
, void *data
)
204 commit_list_insert(commit
, data
);
208 * Given rev-list arguments, run rev-list. All reachable commits
209 * except border ones are marked with not_shallow_flag. Border commits
210 * are marked with shallow_flag. The list of border/shallow commits
213 struct commit_list
*get_shallow_commits_by_rev_list(int ac
, const char **av
,
215 int not_shallow_flag
)
217 struct commit_list
*result
= NULL
, *p
;
218 struct commit_list
*not_shallow_list
= NULL
;
219 struct rev_info revs
;
220 int both_flags
= shallow_flag
| not_shallow_flag
;
223 * SHALLOW (excluded) and NOT_SHALLOW (included) should not be
224 * set at this point. But better be safe than sorry.
226 clear_object_flags(both_flags
);
228 is_repository_shallow(the_repository
); /* make sure shallows are read */
230 repo_init_revisions(the_repository
, &revs
, NULL
);
231 save_commit_buffer
= 0;
232 setup_revisions(ac
, av
, &revs
, NULL
);
234 if (prepare_revision_walk(&revs
))
235 die("revision walk setup failed");
236 traverse_commit_list(&revs
, show_commit
, NULL
, ¬_shallow_list
);
238 if (!not_shallow_list
)
239 die("no commits selected for shallow requests");
241 /* Mark all reachable commits as NOT_SHALLOW */
242 for (p
= not_shallow_list
; p
; p
= p
->next
)
243 p
->item
->object
.flags
|= not_shallow_flag
;
246 * mark border commits SHALLOW + NOT_SHALLOW.
247 * We cannot clear NOT_SHALLOW right now. Imagine border
248 * commit A is processed first, then commit B, whose parent is
249 * A, later. If NOT_SHALLOW on A is cleared at step 1, B
250 * itself is considered border at step 2, which is incorrect.
252 for (p
= not_shallow_list
; p
; p
= p
->next
) {
253 struct commit
*c
= p
->item
;
254 struct commit_list
*parent
;
256 if (repo_parse_commit(the_repository
, c
))
257 die("unable to parse commit %s",
258 oid_to_hex(&c
->object
.oid
));
260 for (parent
= c
->parents
; parent
; parent
= parent
->next
)
261 if (!(parent
->item
->object
.flags
& not_shallow_flag
)) {
262 c
->object
.flags
|= shallow_flag
;
263 commit_list_insert(c
, &result
);
267 free_commit_list(not_shallow_list
);
270 * Now we can clean up NOT_SHALLOW on border commits. Having
271 * both flags set can confuse the caller.
273 for (p
= result
; p
; p
= p
->next
) {
274 struct object
*o
= &p
->item
->object
;
275 if ((o
->flags
& both_flags
) == both_flags
)
276 o
->flags
&= ~not_shallow_flag
;
278 release_revisions(&revs
);
282 static void check_shallow_file_for_update(struct repository
*r
)
284 if (r
->parsed_objects
->is_shallow
== -1)
285 BUG("shallow must be initialized by now");
287 if (!stat_validity_check(r
->parsed_objects
->shallow_stat
,
288 git_path_shallow(r
)))
289 die("shallow file has changed since we read it");
296 struct write_shallow_data
{
298 int use_pack_protocol
;
303 static int write_one_shallow(const struct commit_graft
*graft
, void *cb_data
)
305 struct write_shallow_data
*data
= cb_data
;
306 const char *hex
= oid_to_hex(&graft
->oid
);
307 if (graft
->nr_parent
!= -1)
309 if (data
->flags
& QUICK
) {
310 if (!repo_has_object_file(the_repository
, &graft
->oid
))
312 } else if (data
->flags
& SEEN_ONLY
) {
313 struct commit
*c
= lookup_commit(the_repository
, &graft
->oid
);
314 if (!c
|| !(c
->object
.flags
& SEEN
)) {
315 if (data
->flags
& VERBOSE
)
316 printf("Removing %s from .git/shallow\n",
317 oid_to_hex(&c
->object
.oid
));
322 if (data
->use_pack_protocol
)
323 packet_buf_write(data
->out
, "shallow %s", hex
);
325 strbuf_addstr(data
->out
, hex
);
326 strbuf_addch(data
->out
, '\n');
331 static int write_shallow_commits_1(struct strbuf
*out
, int use_pack_protocol
,
332 const struct oid_array
*extra
,
335 struct write_shallow_data data
;
338 data
.use_pack_protocol
= use_pack_protocol
;
341 for_each_commit_graft(write_one_shallow
, &data
);
344 for (i
= 0; i
< extra
->nr
; i
++) {
345 strbuf_addstr(out
, oid_to_hex(extra
->oid
+ i
));
346 strbuf_addch(out
, '\n');
352 int write_shallow_commits(struct strbuf
*out
, int use_pack_protocol
,
353 const struct oid_array
*extra
)
355 return write_shallow_commits_1(out
, use_pack_protocol
, extra
, 0);
358 const char *setup_temporary_shallow(const struct oid_array
*extra
)
360 struct tempfile
*temp
;
361 struct strbuf sb
= STRBUF_INIT
;
363 if (write_shallow_commits(&sb
, 0, extra
)) {
364 temp
= xmks_tempfile(git_path("shallow_XXXXXX"));
366 if (write_in_full(temp
->fd
, sb
.buf
, sb
.len
) < 0 ||
367 close_tempfile_gently(temp
) < 0)
368 die_errno("failed to write to %s",
369 get_tempfile_path(temp
));
371 return get_tempfile_path(temp
);
374 * is_repository_shallow() sees empty string as "no shallow
380 void setup_alternate_shallow(struct shallow_lock
*shallow_lock
,
381 const char **alternate_shallow_file
,
382 const struct oid_array
*extra
)
384 struct strbuf sb
= STRBUF_INIT
;
387 fd
= hold_lock_file_for_update(&shallow_lock
->lock
,
388 git_path_shallow(the_repository
),
390 check_shallow_file_for_update(the_repository
);
391 if (write_shallow_commits(&sb
, 0, extra
)) {
392 if (write_in_full(fd
, sb
.buf
, sb
.len
) < 0)
393 die_errno("failed to write to %s",
394 get_lock_file_path(&shallow_lock
->lock
));
395 *alternate_shallow_file
= get_lock_file_path(&shallow_lock
->lock
);
398 * is_repository_shallow() sees empty string as "no
401 *alternate_shallow_file
= "";
405 static int advertise_shallow_grafts_cb(const struct commit_graft
*graft
, void *cb
)
408 if (graft
->nr_parent
== -1)
409 packet_write_fmt(fd
, "shallow %s\n", oid_to_hex(&graft
->oid
));
413 void advertise_shallow_grafts(int fd
)
415 if (!is_repository_shallow(the_repository
))
417 for_each_commit_graft(advertise_shallow_grafts_cb
, &fd
);
421 * mark_reachable_objects() should have been run prior to this and all
422 * reachable commits marked as "SEEN", except when quick_prune is non-zero,
423 * in which case lines are excised from the shallow file if they refer to
424 * commits that do not exist (any longer).
426 void prune_shallow(unsigned options
)
428 struct shallow_lock shallow_lock
= SHALLOW_LOCK_INIT
;
429 struct strbuf sb
= STRBUF_INIT
;
430 unsigned flags
= SEEN_ONLY
;
433 if (options
& PRUNE_QUICK
)
436 if (options
& PRUNE_SHOW_ONLY
) {
438 write_shallow_commits_1(&sb
, 0, NULL
, flags
);
442 fd
= hold_lock_file_for_update(&shallow_lock
.lock
,
443 git_path_shallow(the_repository
),
445 check_shallow_file_for_update(the_repository
);
446 if (write_shallow_commits_1(&sb
, 0, NULL
, flags
)) {
447 if (write_in_full(fd
, sb
.buf
, sb
.len
) < 0)
448 die_errno("failed to write to %s",
449 get_lock_file_path(&shallow_lock
.lock
));
450 commit_shallow_file(the_repository
, &shallow_lock
);
452 unlink(git_path_shallow(the_repository
));
453 rollback_shallow_file(the_repository
, &shallow_lock
);
458 struct trace_key trace_shallow
= TRACE_KEY_INIT(SHALLOW
);
461 * Step 1, split sender shallow commits into "ours" and "theirs"
462 * Step 2, clean "ours" based on .git/shallow
464 void prepare_shallow_info(struct shallow_info
*info
, struct oid_array
*sa
)
467 trace_printf_key(&trace_shallow
, "shallow: prepare_shallow_info\n");
468 memset(info
, 0, sizeof(*info
));
472 ALLOC_ARRAY(info
->ours
, sa
->nr
);
473 ALLOC_ARRAY(info
->theirs
, sa
->nr
);
474 for (i
= 0; i
< sa
->nr
; i
++) {
475 if (repo_has_object_file(the_repository
, sa
->oid
+ i
)) {
476 struct commit_graft
*graft
;
477 graft
= lookup_commit_graft(the_repository
,
479 if (graft
&& graft
->nr_parent
< 0)
481 info
->ours
[info
->nr_ours
++] = i
;
483 info
->theirs
[info
->nr_theirs
++] = i
;
487 void clear_shallow_info(struct shallow_info
*info
)
493 /* Step 4, remove non-existent ones in "theirs" after getting the pack */
495 void remove_nonexistent_theirs_shallow(struct shallow_info
*info
)
497 struct object_id
*oid
= info
->shallow
->oid
;
499 trace_printf_key(&trace_shallow
, "shallow: remove_nonexistent_theirs_shallow\n");
500 for (i
= dst
= 0; i
< info
->nr_theirs
; i
++) {
502 info
->theirs
[dst
] = info
->theirs
[i
];
503 if (repo_has_object_file(the_repository
, oid
+ info
->theirs
[i
]))
506 info
->nr_theirs
= dst
;
509 define_commit_slab(ref_bitmap
, uint32_t *);
511 #define POOL_SIZE (512 * 1024)
514 struct ref_bitmap ref_bitmap
;
521 static uint32_t *paint_alloc(struct paint_info
*info
)
523 unsigned nr
= DIV_ROUND_UP(info
->nr_bits
, 32);
524 unsigned size
= nr
* sizeof(uint32_t);
526 if (!info
->pool_count
|| size
> info
->end
- info
->free
) {
527 if (size
> POOL_SIZE
)
528 BUG("pool size too small for %d in paint_alloc()",
531 REALLOC_ARRAY(info
->pools
, info
->pool_count
);
532 info
->free
= xmalloc(POOL_SIZE
);
533 info
->pools
[info
->pool_count
- 1] = info
->free
;
534 info
->end
= info
->free
+ POOL_SIZE
;
542 * Given a commit SHA-1, walk down to parents until either SEEN,
543 * UNINTERESTING or BOTTOM is hit. Set the id-th bit in ref_bitmap for
544 * all walked commits.
546 static void paint_down(struct paint_info
*info
, const struct object_id
*oid
,
550 struct commit_list
*head
= NULL
;
551 int bitmap_nr
= DIV_ROUND_UP(info
->nr_bits
, 32);
552 size_t bitmap_size
= st_mult(sizeof(uint32_t), bitmap_nr
);
553 struct commit
*c
= lookup_commit_reference_gently(the_repository
, oid
,
555 uint32_t *tmp
; /* to be freed before return */
561 tmp
= xmalloc(bitmap_size
);
562 bitmap
= paint_alloc(info
);
563 memset(bitmap
, 0, bitmap_size
);
564 bitmap
[id
/ 32] |= (1U << (id
% 32));
565 commit_list_insert(c
, &head
);
567 struct commit_list
*p
;
568 struct commit
*c
= pop_commit(&head
);
569 uint32_t **refs
= ref_bitmap_at(&info
->ref_bitmap
, c
);
571 /* XXX check "UNINTERESTING" from pack bitmaps if available */
572 if (c
->object
.flags
& (SEEN
| UNINTERESTING
))
575 c
->object
.flags
|= SEEN
;
580 memcpy(tmp
, *refs
, bitmap_size
);
581 for (i
= 0; i
< bitmap_nr
; i
++)
583 if (memcmp(tmp
, *refs
, bitmap_size
)) {
584 *refs
= paint_alloc(info
);
585 memcpy(*refs
, tmp
, bitmap_size
);
589 if (c
->object
.flags
& BOTTOM
)
592 if (repo_parse_commit(the_repository
, c
))
593 die("unable to parse commit %s",
594 oid_to_hex(&c
->object
.oid
));
596 for (p
= c
->parents
; p
; p
= p
->next
) {
597 if (p
->item
->object
.flags
& SEEN
)
599 commit_list_insert(p
->item
, &head
);
603 nr
= get_max_object_index();
604 for (i
= 0; i
< nr
; i
++) {
605 struct object
*o
= get_indexed_object(i
);
606 if (o
&& o
->type
== OBJ_COMMIT
)
613 static int mark_uninteresting(const char *refname UNUSED
,
614 const struct object_id
*oid
,
616 void *cb_data UNUSED
)
618 struct commit
*commit
= lookup_commit_reference_gently(the_repository
,
622 commit
->object
.flags
|= UNINTERESTING
;
623 mark_parents_uninteresting(NULL
, commit
);
627 static void post_assign_shallow(struct shallow_info
*info
,
628 struct ref_bitmap
*ref_bitmap
,
631 * Step 6(+7), associate shallow commits with new refs
633 * info->ref must be initialized before calling this function.
635 * If used is not NULL, it's an array of info->shallow->nr
636 * bitmaps. The n-th bit set in the m-th bitmap if ref[n] needs the
637 * m-th shallow commit from info->shallow.
639 * If used is NULL, "ours" and "theirs" are updated. And if ref_status
640 * is not NULL it's an array of ref->nr ints. ref_status[i] is true if
641 * the ref needs some shallow commits from either info->ours or
644 void assign_shallow_commits_to_refs(struct shallow_info
*info
,
645 uint32_t **used
, int *ref_status
)
647 struct object_id
*oid
= info
->shallow
->oid
;
648 struct oid_array
*ref
= info
->ref
;
650 int *shallow
, nr_shallow
= 0;
651 struct paint_info pi
;
653 trace_printf_key(&trace_shallow
, "shallow: assign_shallow_commits_to_refs\n");
654 ALLOC_ARRAY(shallow
, info
->nr_ours
+ info
->nr_theirs
);
655 for (i
= 0; i
< info
->nr_ours
; i
++)
656 shallow
[nr_shallow
++] = info
->ours
[i
];
657 for (i
= 0; i
< info
->nr_theirs
; i
++)
658 shallow
[nr_shallow
++] = info
->theirs
[i
];
661 * Prepare the commit graph to track what refs can reach what
662 * (new) shallow commits.
664 nr
= get_max_object_index();
665 for (i
= 0; i
< nr
; i
++) {
666 struct object
*o
= get_indexed_object(i
);
667 if (!o
|| o
->type
!= OBJ_COMMIT
)
670 o
->flags
&= ~(UNINTERESTING
| BOTTOM
| SEEN
);
673 memset(&pi
, 0, sizeof(pi
));
674 init_ref_bitmap(&pi
.ref_bitmap
);
675 pi
.nr_bits
= ref
->nr
;
678 * "--not --all" to cut short the traversal if new refs
679 * connect to old refs. If not (e.g. force ref updates) it'll
680 * have to go down to the current shallow commits.
682 head_ref(mark_uninteresting
, NULL
);
683 for_each_ref(mark_uninteresting
, NULL
);
685 /* Mark potential bottoms so we won't go out of bound */
686 for (i
= 0; i
< nr_shallow
; i
++) {
687 struct commit
*c
= lookup_commit(the_repository
,
689 c
->object
.flags
|= BOTTOM
;
692 for (i
= 0; i
< ref
->nr
; i
++)
693 paint_down(&pi
, ref
->oid
+ i
, i
);
696 int bitmap_size
= DIV_ROUND_UP(pi
.nr_bits
, 32) * sizeof(uint32_t);
697 memset(used
, 0, sizeof(*used
) * info
->shallow
->nr
);
698 for (i
= 0; i
< nr_shallow
; i
++) {
699 const struct commit
*c
= lookup_commit(the_repository
,
701 uint32_t **map
= ref_bitmap_at(&pi
.ref_bitmap
, c
);
703 used
[shallow
[i
]] = xmemdupz(*map
, bitmap_size
);
706 * unreachable shallow commits are not removed from
707 * "ours" and "theirs". The user is supposed to run
708 * step 7 on every ref separately and not trust "ours"
709 * and "theirs" any more.
712 post_assign_shallow(info
, &pi
.ref_bitmap
, ref_status
);
714 clear_ref_bitmap(&pi
.ref_bitmap
);
715 for (i
= 0; i
< pi
.pool_count
; i
++)
721 struct commit_array
{
722 struct commit
**commits
;
726 static int add_ref(const char *refname UNUSED
,
727 const struct object_id
*oid
,
731 struct commit_array
*ca
= cb_data
;
732 ALLOC_GROW(ca
->commits
, ca
->nr
+ 1, ca
->alloc
);
733 ca
->commits
[ca
->nr
] = lookup_commit_reference_gently(the_repository
,
735 if (ca
->commits
[ca
->nr
])
740 static void update_refstatus(int *ref_status
, int nr
, uint32_t *bitmap
)
745 for (i
= 0; i
< nr
; i
++)
746 if (bitmap
[i
/ 32] & (1U << (i
% 32)))
751 * Step 7, reachability test on "ours" at commit level
753 static void post_assign_shallow(struct shallow_info
*info
,
754 struct ref_bitmap
*ref_bitmap
,
757 struct object_id
*oid
= info
->shallow
->oid
;
761 int bitmap_nr
= DIV_ROUND_UP(info
->ref
->nr
, 32);
762 struct commit_array ca
;
764 trace_printf_key(&trace_shallow
, "shallow: post_assign_shallow\n");
766 memset(ref_status
, 0, sizeof(*ref_status
) * info
->ref
->nr
);
768 /* Remove unreachable shallow commits from "theirs" */
769 for (i
= dst
= 0; i
< info
->nr_theirs
; i
++) {
771 info
->theirs
[dst
] = info
->theirs
[i
];
772 c
= lookup_commit(the_repository
, &oid
[info
->theirs
[i
]]);
773 bitmap
= ref_bitmap_at(ref_bitmap
, c
);
776 for (j
= 0; j
< bitmap_nr
; j
++)
778 update_refstatus(ref_status
, info
->ref
->nr
, *bitmap
);
783 info
->nr_theirs
= dst
;
785 memset(&ca
, 0, sizeof(ca
));
786 head_ref(add_ref
, &ca
);
787 for_each_ref(add_ref
, &ca
);
789 /* Remove unreachable shallow commits from "ours" */
790 for (i
= dst
= 0; i
< info
->nr_ours
; i
++) {
792 info
->ours
[dst
] = info
->ours
[i
];
793 c
= lookup_commit(the_repository
, &oid
[info
->ours
[i
]]);
794 bitmap
= ref_bitmap_at(ref_bitmap
, c
);
797 for (j
= 0; j
< bitmap_nr
; j
++)
799 /* Step 7, reachability test at commit level */
800 !repo_in_merge_bases_many(the_repository
, c
, ca
.nr
, ca
.commits
)) {
801 update_refstatus(ref_status
, info
->ref
->nr
, *bitmap
);
811 /* (Delayed) step 7, reachability test at commit level */
812 int delayed_reachability_test(struct shallow_info
*si
, int c
)
814 if (si
->need_reachability_test
[c
]) {
815 struct commit
*commit
= lookup_commit(the_repository
,
816 &si
->shallow
->oid
[c
]);
819 struct commit_array ca
;
821 memset(&ca
, 0, sizeof(ca
));
822 head_ref(add_ref
, &ca
);
823 for_each_ref(add_ref
, &ca
);
824 si
->commits
= ca
.commits
;
825 si
->nr_commits
= ca
.nr
;
828 si
->reachable
[c
] = repo_in_merge_bases_many(the_repository
,
832 si
->need_reachability_test
[c
] = 0;
834 return si
->reachable
[c
];