1 #include "git-compat-util.h"
3 #include "repository.h"
6 #include "object-store-ll.h"
11 #include "oid-array.h"
15 #include "commit-slab.h"
16 #include "list-objects.h"
17 #include "commit-reach.h"
22 void set_alternate_shallow_file(struct repository
*r
, const char *path
, int override
)
24 if (r
->parsed_objects
->is_shallow
!= -1)
25 BUG("is_repository_shallow must not be called before set_alternate_shallow_file");
26 if (r
->parsed_objects
->alternate_shallow_file
&& !override
)
28 free(r
->parsed_objects
->alternate_shallow_file
);
29 r
->parsed_objects
->alternate_shallow_file
= xstrdup_or_null(path
);
32 int register_shallow(struct repository
*r
, const struct object_id
*oid
)
34 struct commit_graft
*graft
=
35 xmalloc(sizeof(struct commit_graft
));
36 struct commit
*commit
= lookup_commit(r
, oid
);
38 oidcpy(&graft
->oid
, oid
);
39 graft
->nr_parent
= -1;
40 if (commit
&& commit
->object
.parsed
) {
41 free_commit_list(commit
->parents
);
42 commit
->parents
= NULL
;
44 return register_commit_graft(r
, graft
, 0);
47 int unregister_shallow(const struct object_id
*oid
)
49 int pos
= commit_graft_pos(the_repository
, oid
);
52 if (pos
+ 1 < the_repository
->parsed_objects
->grafts_nr
)
53 MOVE_ARRAY(the_repository
->parsed_objects
->grafts
+ pos
,
54 the_repository
->parsed_objects
->grafts
+ pos
+ 1,
55 the_repository
->parsed_objects
->grafts_nr
- pos
- 1);
56 the_repository
->parsed_objects
->grafts_nr
--;
60 int is_repository_shallow(struct repository
*r
)
64 const char *path
= r
->parsed_objects
->alternate_shallow_file
;
66 if (r
->parsed_objects
->is_shallow
>= 0)
67 return r
->parsed_objects
->is_shallow
;
70 path
= git_path_shallow(r
);
72 * fetch-pack sets '--shallow-file ""' as an indicator that no
73 * shallow file should be used. We could just open it and it
74 * will likely fail. But let's do an explicit check instead.
76 if (!*path
|| (fp
= fopen(path
, "r")) == NULL
) {
77 stat_validity_clear(r
->parsed_objects
->shallow_stat
);
78 r
->parsed_objects
->is_shallow
= 0;
79 return r
->parsed_objects
->is_shallow
;
81 stat_validity_update(r
->parsed_objects
->shallow_stat
, fileno(fp
));
82 r
->parsed_objects
->is_shallow
= 1;
84 while (fgets(buf
, sizeof(buf
), fp
)) {
86 if (get_oid_hex(buf
, &oid
))
87 die("bad shallow line: %s", buf
);
88 register_shallow(r
, &oid
);
91 return r
->parsed_objects
->is_shallow
;
94 static void reset_repository_shallow(struct repository
*r
)
96 r
->parsed_objects
->is_shallow
= -1;
97 stat_validity_clear(r
->parsed_objects
->shallow_stat
);
98 reset_commit_grafts(r
);
101 int commit_shallow_file(struct repository
*r
, struct shallow_lock
*lk
)
103 int res
= commit_lock_file(&lk
->lock
);
104 reset_repository_shallow(r
);
107 * Update in-memory data structures with the new shallow information,
108 * including unparsing all commits that now have grafts.
110 is_repository_shallow(r
);
115 void rollback_shallow_file(struct repository
*r
, struct shallow_lock
*lk
)
117 rollback_lock_file(&lk
->lock
);
118 reset_repository_shallow(r
);
122 * TODO: use "int" elemtype instead of "int *" when/if commit-slab
123 * supports a "valid" flag.
125 define_commit_slab(commit_depth
, int *);
126 static void free_depth_in_slab(int **ptr
)
130 struct commit_list
*get_shallow_commits(struct object_array
*heads
, int depth
,
131 int shallow_flag
, int not_shallow_flag
)
133 int i
= 0, cur_depth
= 0;
134 struct commit_list
*result
= NULL
;
135 struct object_array stack
= OBJECT_ARRAY_INIT
;
136 struct commit
*commit
= NULL
;
137 struct commit_graft
*graft
;
138 struct commit_depth depths
;
140 init_commit_depth(&depths
);
141 while (commit
|| i
< heads
->nr
|| stack
.nr
) {
142 struct commit_list
*p
;
146 commit
= (struct commit
*)
147 deref_tag(the_repository
,
148 heads
->objects
[i
++].item
,
150 if (!commit
|| commit
->object
.type
!= OBJ_COMMIT
) {
154 depth_slot
= commit_depth_at(&depths
, commit
);
156 *depth_slot
= xmalloc(sizeof(int));
160 commit
= (struct commit
*)
161 object_array_pop(&stack
);
162 cur_depth
= **commit_depth_at(&depths
, commit
);
165 parse_commit_or_die(commit
);
167 if ((depth
!= INFINITE_DEPTH
&& cur_depth
>= depth
) ||
168 (is_repository_shallow(the_repository
) && !commit
->parents
&&
169 (graft
= lookup_commit_graft(the_repository
, &commit
->object
.oid
)) != NULL
&&
170 graft
->nr_parent
< 0)) {
171 commit_list_insert(commit
, &result
);
172 commit
->object
.flags
|= shallow_flag
;
176 commit
->object
.flags
|= not_shallow_flag
;
177 for (p
= commit
->parents
, commit
= NULL
; p
; p
= p
->next
) {
178 int **depth_slot
= commit_depth_at(&depths
, p
->item
);
180 *depth_slot
= xmalloc(sizeof(int));
181 **depth_slot
= cur_depth
;
183 if (cur_depth
>= **depth_slot
)
185 **depth_slot
= cur_depth
;
188 add_object_array(&p
->item
->object
,
192 cur_depth
= **commit_depth_at(&depths
, commit
);
196 deep_clear_commit_depth(&depths
, free_depth_in_slab
);
201 static void show_commit(struct commit
*commit
, void *data
)
203 commit_list_insert(commit
, data
);
207 * Given rev-list arguments, run rev-list. All reachable commits
208 * except border ones are marked with not_shallow_flag. Border commits
209 * are marked with shallow_flag. The list of border/shallow commits
212 struct commit_list
*get_shallow_commits_by_rev_list(int ac
, const char **av
,
214 int not_shallow_flag
)
216 struct commit_list
*result
= NULL
, *p
;
217 struct commit_list
*not_shallow_list
= NULL
;
218 struct rev_info revs
;
219 int both_flags
= shallow_flag
| not_shallow_flag
;
222 * SHALLOW (excluded) and NOT_SHALLOW (included) should not be
223 * set at this point. But better be safe than sorry.
225 clear_object_flags(both_flags
);
227 is_repository_shallow(the_repository
); /* make sure shallows are read */
229 repo_init_revisions(the_repository
, &revs
, NULL
);
230 save_commit_buffer
= 0;
231 setup_revisions(ac
, av
, &revs
, NULL
);
233 if (prepare_revision_walk(&revs
))
234 die("revision walk setup failed");
235 traverse_commit_list(&revs
, show_commit
, NULL
, ¬_shallow_list
);
237 if (!not_shallow_list
)
238 die("no commits selected for shallow requests");
240 /* Mark all reachable commits as NOT_SHALLOW */
241 for (p
= not_shallow_list
; p
; p
= p
->next
)
242 p
->item
->object
.flags
|= not_shallow_flag
;
245 * mark border commits SHALLOW + NOT_SHALLOW.
246 * We cannot clear NOT_SHALLOW right now. Imagine border
247 * commit A is processed first, then commit B, whose parent is
248 * A, later. If NOT_SHALLOW on A is cleared at step 1, B
249 * itself is considered border at step 2, which is incorrect.
251 for (p
= not_shallow_list
; p
; p
= p
->next
) {
252 struct commit
*c
= p
->item
;
253 struct commit_list
*parent
;
255 if (repo_parse_commit(the_repository
, c
))
256 die("unable to parse commit %s",
257 oid_to_hex(&c
->object
.oid
));
259 for (parent
= c
->parents
; parent
; parent
= parent
->next
)
260 if (!(parent
->item
->object
.flags
& not_shallow_flag
)) {
261 c
->object
.flags
|= shallow_flag
;
262 commit_list_insert(c
, &result
);
266 free_commit_list(not_shallow_list
);
269 * Now we can clean up NOT_SHALLOW on border commits. Having
270 * both flags set can confuse the caller.
272 for (p
= result
; p
; p
= p
->next
) {
273 struct object
*o
= &p
->item
->object
;
274 if ((o
->flags
& both_flags
) == both_flags
)
275 o
->flags
&= ~not_shallow_flag
;
277 release_revisions(&revs
);
281 static void check_shallow_file_for_update(struct repository
*r
)
283 if (r
->parsed_objects
->is_shallow
== -1)
284 BUG("shallow must be initialized by now");
286 if (!stat_validity_check(r
->parsed_objects
->shallow_stat
,
287 git_path_shallow(r
)))
288 die("shallow file has changed since we read it");
295 struct write_shallow_data
{
297 int use_pack_protocol
;
302 static int write_one_shallow(const struct commit_graft
*graft
, void *cb_data
)
304 struct write_shallow_data
*data
= cb_data
;
305 const char *hex
= oid_to_hex(&graft
->oid
);
306 if (graft
->nr_parent
!= -1)
308 if (data
->flags
& QUICK
) {
309 if (!repo_has_object_file(the_repository
, &graft
->oid
))
311 } else if (data
->flags
& SEEN_ONLY
) {
312 struct commit
*c
= lookup_commit(the_repository
, &graft
->oid
);
313 if (!c
|| !(c
->object
.flags
& SEEN
)) {
314 if (data
->flags
& VERBOSE
)
315 printf("Removing %s from .git/shallow\n",
316 oid_to_hex(&c
->object
.oid
));
321 if (data
->use_pack_protocol
)
322 packet_buf_write(data
->out
, "shallow %s", hex
);
324 strbuf_addstr(data
->out
, hex
);
325 strbuf_addch(data
->out
, '\n');
330 static int write_shallow_commits_1(struct strbuf
*out
, int use_pack_protocol
,
331 const struct oid_array
*extra
,
334 struct write_shallow_data data
;
337 data
.use_pack_protocol
= use_pack_protocol
;
340 for_each_commit_graft(write_one_shallow
, &data
);
343 for (i
= 0; i
< extra
->nr
; i
++) {
344 strbuf_addstr(out
, oid_to_hex(extra
->oid
+ i
));
345 strbuf_addch(out
, '\n');
351 int write_shallow_commits(struct strbuf
*out
, int use_pack_protocol
,
352 const struct oid_array
*extra
)
354 return write_shallow_commits_1(out
, use_pack_protocol
, extra
, 0);
357 const char *setup_temporary_shallow(const struct oid_array
*extra
)
359 struct tempfile
*temp
;
360 struct strbuf sb
= STRBUF_INIT
;
362 if (write_shallow_commits(&sb
, 0, extra
)) {
363 temp
= xmks_tempfile(git_path("shallow_XXXXXX"));
365 if (write_in_full(temp
->fd
, sb
.buf
, sb
.len
) < 0 ||
366 close_tempfile_gently(temp
) < 0)
367 die_errno("failed to write to %s",
368 get_tempfile_path(temp
));
370 return get_tempfile_path(temp
);
373 * is_repository_shallow() sees empty string as "no shallow
379 void setup_alternate_shallow(struct shallow_lock
*shallow_lock
,
380 const char **alternate_shallow_file
,
381 const struct oid_array
*extra
)
383 struct strbuf sb
= STRBUF_INIT
;
386 fd
= hold_lock_file_for_update(&shallow_lock
->lock
,
387 git_path_shallow(the_repository
),
389 check_shallow_file_for_update(the_repository
);
390 if (write_shallow_commits(&sb
, 0, extra
)) {
391 if (write_in_full(fd
, sb
.buf
, sb
.len
) < 0)
392 die_errno("failed to write to %s",
393 get_lock_file_path(&shallow_lock
->lock
));
394 *alternate_shallow_file
= get_lock_file_path(&shallow_lock
->lock
);
397 * is_repository_shallow() sees empty string as "no
400 *alternate_shallow_file
= "";
404 static int advertise_shallow_grafts_cb(const struct commit_graft
*graft
, void *cb
)
407 if (graft
->nr_parent
== -1)
408 packet_write_fmt(fd
, "shallow %s\n", oid_to_hex(&graft
->oid
));
412 void advertise_shallow_grafts(int fd
)
414 if (!is_repository_shallow(the_repository
))
416 for_each_commit_graft(advertise_shallow_grafts_cb
, &fd
);
420 * mark_reachable_objects() should have been run prior to this and all
421 * reachable commits marked as "SEEN", except when quick_prune is non-zero,
422 * in which case lines are excised from the shallow file if they refer to
423 * commits that do not exist (any longer).
425 void prune_shallow(unsigned options
)
427 struct shallow_lock shallow_lock
= SHALLOW_LOCK_INIT
;
428 struct strbuf sb
= STRBUF_INIT
;
429 unsigned flags
= SEEN_ONLY
;
432 if (options
& PRUNE_QUICK
)
435 if (options
& PRUNE_SHOW_ONLY
) {
437 write_shallow_commits_1(&sb
, 0, NULL
, flags
);
441 fd
= hold_lock_file_for_update(&shallow_lock
.lock
,
442 git_path_shallow(the_repository
),
444 check_shallow_file_for_update(the_repository
);
445 if (write_shallow_commits_1(&sb
, 0, NULL
, flags
)) {
446 if (write_in_full(fd
, sb
.buf
, sb
.len
) < 0)
447 die_errno("failed to write to %s",
448 get_lock_file_path(&shallow_lock
.lock
));
449 commit_shallow_file(the_repository
, &shallow_lock
);
451 unlink(git_path_shallow(the_repository
));
452 rollback_shallow_file(the_repository
, &shallow_lock
);
457 struct trace_key trace_shallow
= TRACE_KEY_INIT(SHALLOW
);
460 * Step 1, split sender shallow commits into "ours" and "theirs"
461 * Step 2, clean "ours" based on .git/shallow
463 void prepare_shallow_info(struct shallow_info
*info
, struct oid_array
*sa
)
466 trace_printf_key(&trace_shallow
, "shallow: prepare_shallow_info\n");
467 memset(info
, 0, sizeof(*info
));
471 ALLOC_ARRAY(info
->ours
, sa
->nr
);
472 ALLOC_ARRAY(info
->theirs
, sa
->nr
);
473 for (i
= 0; i
< sa
->nr
; i
++) {
474 if (repo_has_object_file(the_repository
, sa
->oid
+ i
)) {
475 struct commit_graft
*graft
;
476 graft
= lookup_commit_graft(the_repository
,
478 if (graft
&& graft
->nr_parent
< 0)
480 info
->ours
[info
->nr_ours
++] = i
;
482 info
->theirs
[info
->nr_theirs
++] = i
;
486 void clear_shallow_info(struct shallow_info
*info
)
492 /* Step 4, remove non-existent ones in "theirs" after getting the pack */
494 void remove_nonexistent_theirs_shallow(struct shallow_info
*info
)
496 struct object_id
*oid
= info
->shallow
->oid
;
498 trace_printf_key(&trace_shallow
, "shallow: remove_nonexistent_theirs_shallow\n");
499 for (i
= dst
= 0; i
< info
->nr_theirs
; i
++) {
501 info
->theirs
[dst
] = info
->theirs
[i
];
502 if (repo_has_object_file(the_repository
, oid
+ info
->theirs
[i
]))
505 info
->nr_theirs
= dst
;
508 define_commit_slab(ref_bitmap
, uint32_t *);
510 #define POOL_SIZE (512 * 1024)
513 struct ref_bitmap ref_bitmap
;
520 static uint32_t *paint_alloc(struct paint_info
*info
)
522 unsigned nr
= DIV_ROUND_UP(info
->nr_bits
, 32);
523 unsigned size
= nr
* sizeof(uint32_t);
525 if (!info
->pool_count
|| size
> info
->end
- info
->free
) {
526 if (size
> POOL_SIZE
)
527 BUG("pool size too small for %d in paint_alloc()",
530 REALLOC_ARRAY(info
->pools
, info
->pool_count
);
531 info
->free
= xmalloc(POOL_SIZE
);
532 info
->pools
[info
->pool_count
- 1] = info
->free
;
533 info
->end
= info
->free
+ POOL_SIZE
;
541 * Given a commit SHA-1, walk down to parents until either SEEN,
542 * UNINTERESTING or BOTTOM is hit. Set the id-th bit in ref_bitmap for
543 * all walked commits.
545 static void paint_down(struct paint_info
*info
, const struct object_id
*oid
,
549 struct commit_list
*head
= NULL
;
550 int bitmap_nr
= DIV_ROUND_UP(info
->nr_bits
, 32);
551 size_t bitmap_size
= st_mult(sizeof(uint32_t), bitmap_nr
);
552 struct commit
*c
= lookup_commit_reference_gently(the_repository
, oid
,
554 uint32_t *tmp
; /* to be freed before return */
560 tmp
= xmalloc(bitmap_size
);
561 bitmap
= paint_alloc(info
);
562 memset(bitmap
, 0, bitmap_size
);
563 bitmap
[id
/ 32] |= (1U << (id
% 32));
564 commit_list_insert(c
, &head
);
566 struct commit_list
*p
;
567 struct commit
*c
= pop_commit(&head
);
568 uint32_t **refs
= ref_bitmap_at(&info
->ref_bitmap
, c
);
570 /* XXX check "UNINTERESTING" from pack bitmaps if available */
571 if (c
->object
.flags
& (SEEN
| UNINTERESTING
))
574 c
->object
.flags
|= SEEN
;
579 memcpy(tmp
, *refs
, bitmap_size
);
580 for (i
= 0; i
< bitmap_nr
; i
++)
582 if (memcmp(tmp
, *refs
, bitmap_size
)) {
583 *refs
= paint_alloc(info
);
584 memcpy(*refs
, tmp
, bitmap_size
);
588 if (c
->object
.flags
& BOTTOM
)
591 if (repo_parse_commit(the_repository
, c
))
592 die("unable to parse commit %s",
593 oid_to_hex(&c
->object
.oid
));
595 for (p
= c
->parents
; p
; p
= p
->next
) {
596 if (p
->item
->object
.flags
& SEEN
)
598 commit_list_insert(p
->item
, &head
);
602 nr
= get_max_object_index();
603 for (i
= 0; i
< nr
; i
++) {
604 struct object
*o
= get_indexed_object(i
);
605 if (o
&& o
->type
== OBJ_COMMIT
)
612 static int mark_uninteresting(const char *refname UNUSED
,
613 const struct object_id
*oid
,
615 void *cb_data UNUSED
)
617 struct commit
*commit
= lookup_commit_reference_gently(the_repository
,
621 commit
->object
.flags
|= UNINTERESTING
;
622 mark_parents_uninteresting(NULL
, commit
);
626 static void post_assign_shallow(struct shallow_info
*info
,
627 struct ref_bitmap
*ref_bitmap
,
630 * Step 6(+7), associate shallow commits with new refs
632 * info->ref must be initialized before calling this function.
634 * If used is not NULL, it's an array of info->shallow->nr
635 * bitmaps. The n-th bit set in the m-th bitmap if ref[n] needs the
636 * m-th shallow commit from info->shallow.
638 * If used is NULL, "ours" and "theirs" are updated. And if ref_status
639 * is not NULL it's an array of ref->nr ints. ref_status[i] is true if
640 * the ref needs some shallow commits from either info->ours or
643 void assign_shallow_commits_to_refs(struct shallow_info
*info
,
644 uint32_t **used
, int *ref_status
)
646 struct object_id
*oid
= info
->shallow
->oid
;
647 struct oid_array
*ref
= info
->ref
;
649 int *shallow
, nr_shallow
= 0;
650 struct paint_info pi
;
652 trace_printf_key(&trace_shallow
, "shallow: assign_shallow_commits_to_refs\n");
653 ALLOC_ARRAY(shallow
, info
->nr_ours
+ info
->nr_theirs
);
654 for (i
= 0; i
< info
->nr_ours
; i
++)
655 shallow
[nr_shallow
++] = info
->ours
[i
];
656 for (i
= 0; i
< info
->nr_theirs
; i
++)
657 shallow
[nr_shallow
++] = info
->theirs
[i
];
660 * Prepare the commit graph to track what refs can reach what
661 * (new) shallow commits.
663 nr
= get_max_object_index();
664 for (i
= 0; i
< nr
; i
++) {
665 struct object
*o
= get_indexed_object(i
);
666 if (!o
|| o
->type
!= OBJ_COMMIT
)
669 o
->flags
&= ~(UNINTERESTING
| BOTTOM
| SEEN
);
672 memset(&pi
, 0, sizeof(pi
));
673 init_ref_bitmap(&pi
.ref_bitmap
);
674 pi
.nr_bits
= ref
->nr
;
677 * "--not --all" to cut short the traversal if new refs
678 * connect to old refs. If not (e.g. force ref updates) it'll
679 * have to go down to the current shallow commits.
681 head_ref(mark_uninteresting
, NULL
);
682 for_each_ref(mark_uninteresting
, NULL
);
684 /* Mark potential bottoms so we won't go out of bound */
685 for (i
= 0; i
< nr_shallow
; i
++) {
686 struct commit
*c
= lookup_commit(the_repository
,
688 c
->object
.flags
|= BOTTOM
;
691 for (i
= 0; i
< ref
->nr
; i
++)
692 paint_down(&pi
, ref
->oid
+ i
, i
);
695 int bitmap_size
= DIV_ROUND_UP(pi
.nr_bits
, 32) * sizeof(uint32_t);
696 memset(used
, 0, sizeof(*used
) * info
->shallow
->nr
);
697 for (i
= 0; i
< nr_shallow
; i
++) {
698 const struct commit
*c
= lookup_commit(the_repository
,
700 uint32_t **map
= ref_bitmap_at(&pi
.ref_bitmap
, c
);
702 used
[shallow
[i
]] = xmemdupz(*map
, bitmap_size
);
705 * unreachable shallow commits are not removed from
706 * "ours" and "theirs". The user is supposed to run
707 * step 7 on every ref separately and not trust "ours"
708 * and "theirs" any more.
711 post_assign_shallow(info
, &pi
.ref_bitmap
, ref_status
);
713 clear_ref_bitmap(&pi
.ref_bitmap
);
714 for (i
= 0; i
< pi
.pool_count
; i
++)
720 struct commit_array
{
721 struct commit
**commits
;
725 static int add_ref(const char *refname UNUSED
,
726 const struct object_id
*oid
,
730 struct commit_array
*ca
= cb_data
;
731 ALLOC_GROW(ca
->commits
, ca
->nr
+ 1, ca
->alloc
);
732 ca
->commits
[ca
->nr
] = lookup_commit_reference_gently(the_repository
,
734 if (ca
->commits
[ca
->nr
])
739 static void update_refstatus(int *ref_status
, int nr
, uint32_t *bitmap
)
744 for (i
= 0; i
< nr
; i
++)
745 if (bitmap
[i
/ 32] & (1U << (i
% 32)))
750 * Step 7, reachability test on "ours" at commit level
752 static void post_assign_shallow(struct shallow_info
*info
,
753 struct ref_bitmap
*ref_bitmap
,
756 struct object_id
*oid
= info
->shallow
->oid
;
760 int bitmap_nr
= DIV_ROUND_UP(info
->ref
->nr
, 32);
761 struct commit_array ca
;
763 trace_printf_key(&trace_shallow
, "shallow: post_assign_shallow\n");
765 memset(ref_status
, 0, sizeof(*ref_status
) * info
->ref
->nr
);
767 /* Remove unreachable shallow commits from "theirs" */
768 for (i
= dst
= 0; i
< info
->nr_theirs
; i
++) {
770 info
->theirs
[dst
] = info
->theirs
[i
];
771 c
= lookup_commit(the_repository
, &oid
[info
->theirs
[i
]]);
772 bitmap
= ref_bitmap_at(ref_bitmap
, c
);
775 for (j
= 0; j
< bitmap_nr
; j
++)
777 update_refstatus(ref_status
, info
->ref
->nr
, *bitmap
);
782 info
->nr_theirs
= dst
;
784 memset(&ca
, 0, sizeof(ca
));
785 head_ref(add_ref
, &ca
);
786 for_each_ref(add_ref
, &ca
);
788 /* Remove unreachable shallow commits from "ours" */
789 for (i
= dst
= 0; i
< info
->nr_ours
; i
++) {
791 info
->ours
[dst
] = info
->ours
[i
];
792 c
= lookup_commit(the_repository
, &oid
[info
->ours
[i
]]);
793 bitmap
= ref_bitmap_at(ref_bitmap
, c
);
796 for (j
= 0; j
< bitmap_nr
; j
++)
798 /* Step 7, reachability test at commit level */
799 !repo_in_merge_bases_many(the_repository
, c
, ca
.nr
, ca
.commits
)) {
800 update_refstatus(ref_status
, info
->ref
->nr
, *bitmap
);
810 /* (Delayed) step 7, reachability test at commit level */
811 int delayed_reachability_test(struct shallow_info
*si
, int c
)
813 if (si
->need_reachability_test
[c
]) {
814 struct commit
*commit
= lookup_commit(the_repository
,
815 &si
->shallow
->oid
[c
]);
818 struct commit_array ca
;
820 memset(&ca
, 0, sizeof(ca
));
821 head_ref(add_ref
, &ca
);
822 for_each_ref(add_ref
, &ca
);
823 si
->commits
= ca
.commits
;
824 si
->nr_commits
= ca
.nr
;
827 si
->reachable
[c
] = repo_in_merge_bases_many(the_repository
,
831 si
->need_reachability_test
[c
] = 0;
833 return si
->reachable
[c
];