2 #include "repository.h"
5 #include "object-store.h"
11 #include "oid-array.h"
14 #include "commit-slab.h"
15 #include "list-objects.h"
16 #include "commit-reach.h"
19 void set_alternate_shallow_file(struct repository
*r
, const char *path
, int override
)
21 if (r
->parsed_objects
->is_shallow
!= -1)
22 BUG("is_repository_shallow must not be called before set_alternate_shallow_file");
23 if (r
->parsed_objects
->alternate_shallow_file
&& !override
)
25 free(r
->parsed_objects
->alternate_shallow_file
);
26 r
->parsed_objects
->alternate_shallow_file
= xstrdup_or_null(path
);
29 int register_shallow(struct repository
*r
, const struct object_id
*oid
)
31 struct commit_graft
*graft
=
32 xmalloc(sizeof(struct commit_graft
));
33 struct commit
*commit
= lookup_commit(the_repository
, oid
);
35 oidcpy(&graft
->oid
, oid
);
36 graft
->nr_parent
= -1;
37 if (commit
&& commit
->object
.parsed
)
38 commit
->parents
= NULL
;
39 return register_commit_graft(r
, graft
, 0);
42 int unregister_shallow(const struct object_id
*oid
)
44 int pos
= commit_graft_pos(the_repository
, oid
->hash
);
47 if (pos
+ 1 < the_repository
->parsed_objects
->grafts_nr
)
48 MOVE_ARRAY(the_repository
->parsed_objects
->grafts
+ pos
,
49 the_repository
->parsed_objects
->grafts
+ pos
+ 1,
50 the_repository
->parsed_objects
->grafts_nr
- pos
- 1);
51 the_repository
->parsed_objects
->grafts_nr
--;
55 int is_repository_shallow(struct repository
*r
)
59 const char *path
= r
->parsed_objects
->alternate_shallow_file
;
61 if (r
->parsed_objects
->is_shallow
>= 0)
62 return r
->parsed_objects
->is_shallow
;
65 path
= git_path_shallow(r
);
67 * fetch-pack sets '--shallow-file ""' as an indicator that no
68 * shallow file should be used. We could just open it and it
69 * will likely fail. But let's do an explicit check instead.
71 if (!*path
|| (fp
= fopen(path
, "r")) == NULL
) {
72 stat_validity_clear(r
->parsed_objects
->shallow_stat
);
73 r
->parsed_objects
->is_shallow
= 0;
74 return r
->parsed_objects
->is_shallow
;
76 stat_validity_update(r
->parsed_objects
->shallow_stat
, fileno(fp
));
77 r
->parsed_objects
->is_shallow
= 1;
79 while (fgets(buf
, sizeof(buf
), fp
)) {
81 if (get_oid_hex(buf
, &oid
))
82 die("bad shallow line: %s", buf
);
83 register_shallow(r
, &oid
);
86 return r
->parsed_objects
->is_shallow
;
89 static void reset_repository_shallow(struct repository
*r
)
91 r
->parsed_objects
->is_shallow
= -1;
92 stat_validity_clear(r
->parsed_objects
->shallow_stat
);
95 int commit_shallow_file(struct repository
*r
, struct shallow_lock
*lk
)
97 int res
= commit_lock_file(&lk
->lock
);
98 reset_repository_shallow(r
);
102 void rollback_shallow_file(struct repository
*r
, struct shallow_lock
*lk
)
104 rollback_lock_file(&lk
->lock
);
105 reset_repository_shallow(r
);
109 * TODO: use "int" elemtype instead of "int *" when/if commit-slab
110 * supports a "valid" flag.
112 define_commit_slab(commit_depth
, int *);
113 static void free_depth_in_slab(int **ptr
)
117 struct commit_list
*get_shallow_commits(struct object_array
*heads
, int depth
,
118 int shallow_flag
, int not_shallow_flag
)
120 int i
= 0, cur_depth
= 0;
121 struct commit_list
*result
= NULL
;
122 struct object_array stack
= OBJECT_ARRAY_INIT
;
123 struct commit
*commit
= NULL
;
124 struct commit_graft
*graft
;
125 struct commit_depth depths
;
127 init_commit_depth(&depths
);
128 while (commit
|| i
< heads
->nr
|| stack
.nr
) {
129 struct commit_list
*p
;
133 commit
= (struct commit
*)
134 deref_tag(the_repository
,
135 heads
->objects
[i
++].item
,
137 if (!commit
|| commit
->object
.type
!= OBJ_COMMIT
) {
141 depth_slot
= commit_depth_at(&depths
, commit
);
143 *depth_slot
= xmalloc(sizeof(int));
147 commit
= (struct commit
*)
148 object_array_pop(&stack
);
149 cur_depth
= **commit_depth_at(&depths
, commit
);
152 parse_commit_or_die(commit
);
154 if ((depth
!= INFINITE_DEPTH
&& cur_depth
>= depth
) ||
155 (is_repository_shallow(the_repository
) && !commit
->parents
&&
156 (graft
= lookup_commit_graft(the_repository
, &commit
->object
.oid
)) != NULL
&&
157 graft
->nr_parent
< 0)) {
158 commit_list_insert(commit
, &result
);
159 commit
->object
.flags
|= shallow_flag
;
163 commit
->object
.flags
|= not_shallow_flag
;
164 for (p
= commit
->parents
, commit
= NULL
; p
; p
= p
->next
) {
165 int **depth_slot
= commit_depth_at(&depths
, p
->item
);
167 *depth_slot
= xmalloc(sizeof(int));
168 **depth_slot
= cur_depth
;
170 if (cur_depth
>= **depth_slot
)
172 **depth_slot
= cur_depth
;
175 add_object_array(&p
->item
->object
,
179 cur_depth
= **commit_depth_at(&depths
, commit
);
183 deep_clear_commit_depth(&depths
, free_depth_in_slab
);
188 static void show_commit(struct commit
*commit
, void *data
)
190 commit_list_insert(commit
, data
);
194 * Given rev-list arguments, run rev-list. All reachable commits
195 * except border ones are marked with not_shallow_flag. Border commits
196 * are marked with shallow_flag. The list of border/shallow commits
199 struct commit_list
*get_shallow_commits_by_rev_list(int ac
, const char **av
,
201 int not_shallow_flag
)
203 struct commit_list
*result
= NULL
, *p
;
204 struct commit_list
*not_shallow_list
= NULL
;
205 struct rev_info revs
;
206 int both_flags
= shallow_flag
| not_shallow_flag
;
209 * SHALLOW (excluded) and NOT_SHALLOW (included) should not be
210 * set at this point. But better be safe than sorry.
212 clear_object_flags(both_flags
);
214 is_repository_shallow(the_repository
); /* make sure shallows are read */
216 repo_init_revisions(the_repository
, &revs
, NULL
);
217 save_commit_buffer
= 0;
218 setup_revisions(ac
, av
, &revs
, NULL
);
220 if (prepare_revision_walk(&revs
))
221 die("revision walk setup failed");
222 traverse_commit_list(&revs
, show_commit
, NULL
, ¬_shallow_list
);
224 if (!not_shallow_list
)
225 die("no commits selected for shallow requests");
227 /* Mark all reachable commits as NOT_SHALLOW */
228 for (p
= not_shallow_list
; p
; p
= p
->next
)
229 p
->item
->object
.flags
|= not_shallow_flag
;
232 * mark border commits SHALLOW + NOT_SHALLOW.
233 * We cannot clear NOT_SHALLOW right now. Imagine border
234 * commit A is processed first, then commit B, whose parent is
235 * A, later. If NOT_SHALLOW on A is cleared at step 1, B
236 * itself is considered border at step 2, which is incorrect.
238 for (p
= not_shallow_list
; p
; p
= p
->next
) {
239 struct commit
*c
= p
->item
;
240 struct commit_list
*parent
;
243 die("unable to parse commit %s",
244 oid_to_hex(&c
->object
.oid
));
246 for (parent
= c
->parents
; parent
; parent
= parent
->next
)
247 if (!(parent
->item
->object
.flags
& not_shallow_flag
)) {
248 c
->object
.flags
|= shallow_flag
;
249 commit_list_insert(c
, &result
);
253 free_commit_list(not_shallow_list
);
256 * Now we can clean up NOT_SHALLOW on border commits. Having
257 * both flags set can confuse the caller.
259 for (p
= result
; p
; p
= p
->next
) {
260 struct object
*o
= &p
->item
->object
;
261 if ((o
->flags
& both_flags
) == both_flags
)
262 o
->flags
&= ~not_shallow_flag
;
267 static void check_shallow_file_for_update(struct repository
*r
)
269 if (r
->parsed_objects
->is_shallow
== -1)
270 BUG("shallow must be initialized by now");
272 if (!stat_validity_check(r
->parsed_objects
->shallow_stat
,
273 git_path_shallow(r
)))
274 die("shallow file has changed since we read it");
281 struct write_shallow_data
{
283 int use_pack_protocol
;
288 static int write_one_shallow(const struct commit_graft
*graft
, void *cb_data
)
290 struct write_shallow_data
*data
= cb_data
;
291 const char *hex
= oid_to_hex(&graft
->oid
);
292 if (graft
->nr_parent
!= -1)
294 if (data
->flags
& QUICK
) {
295 if (!has_object_file(&graft
->oid
))
297 } else if (data
->flags
& SEEN_ONLY
) {
298 struct commit
*c
= lookup_commit(the_repository
, &graft
->oid
);
299 if (!c
|| !(c
->object
.flags
& SEEN
)) {
300 if (data
->flags
& VERBOSE
)
301 printf("Removing %s from .git/shallow\n",
302 oid_to_hex(&c
->object
.oid
));
307 if (data
->use_pack_protocol
)
308 packet_buf_write(data
->out
, "shallow %s", hex
);
310 strbuf_addstr(data
->out
, hex
);
311 strbuf_addch(data
->out
, '\n');
316 static int write_shallow_commits_1(struct strbuf
*out
, int use_pack_protocol
,
317 const struct oid_array
*extra
,
320 struct write_shallow_data data
;
323 data
.use_pack_protocol
= use_pack_protocol
;
326 for_each_commit_graft(write_one_shallow
, &data
);
329 for (i
= 0; i
< extra
->nr
; i
++) {
330 strbuf_addstr(out
, oid_to_hex(extra
->oid
+ i
));
331 strbuf_addch(out
, '\n');
337 int write_shallow_commits(struct strbuf
*out
, int use_pack_protocol
,
338 const struct oid_array
*extra
)
340 return write_shallow_commits_1(out
, use_pack_protocol
, extra
, 0);
343 const char *setup_temporary_shallow(const struct oid_array
*extra
)
345 struct tempfile
*temp
;
346 struct strbuf sb
= STRBUF_INIT
;
348 if (write_shallow_commits(&sb
, 0, extra
)) {
349 temp
= xmks_tempfile(git_path("shallow_XXXXXX"));
351 if (write_in_full(temp
->fd
, sb
.buf
, sb
.len
) < 0 ||
352 close_tempfile_gently(temp
) < 0)
353 die_errno("failed to write to %s",
354 get_tempfile_path(temp
));
356 return get_tempfile_path(temp
);
359 * is_repository_shallow() sees empty string as "no shallow
365 void setup_alternate_shallow(struct shallow_lock
*shallow_lock
,
366 const char **alternate_shallow_file
,
367 const struct oid_array
*extra
)
369 struct strbuf sb
= STRBUF_INIT
;
372 fd
= hold_lock_file_for_update(&shallow_lock
->lock
,
373 git_path_shallow(the_repository
),
375 check_shallow_file_for_update(the_repository
);
376 if (write_shallow_commits(&sb
, 0, extra
)) {
377 if (write_in_full(fd
, sb
.buf
, sb
.len
) < 0)
378 die_errno("failed to write to %s",
379 get_lock_file_path(&shallow_lock
->lock
));
380 *alternate_shallow_file
= get_lock_file_path(&shallow_lock
->lock
);
383 * is_repository_shallow() sees empty string as "no
386 *alternate_shallow_file
= "";
390 static int advertise_shallow_grafts_cb(const struct commit_graft
*graft
, void *cb
)
393 if (graft
->nr_parent
== -1)
394 packet_write_fmt(fd
, "shallow %s\n", oid_to_hex(&graft
->oid
));
398 void advertise_shallow_grafts(int fd
)
400 if (!is_repository_shallow(the_repository
))
402 for_each_commit_graft(advertise_shallow_grafts_cb
, &fd
);
406 * mark_reachable_objects() should have been run prior to this and all
407 * reachable commits marked as "SEEN", except when quick_prune is non-zero,
408 * in which case lines are excised from the shallow file if they refer to
409 * commits that do not exist (any longer).
411 void prune_shallow(unsigned options
)
413 struct shallow_lock shallow_lock
= SHALLOW_LOCK_INIT
;
414 struct strbuf sb
= STRBUF_INIT
;
415 unsigned flags
= SEEN_ONLY
;
418 if (options
& PRUNE_QUICK
)
421 if (options
& PRUNE_SHOW_ONLY
) {
423 write_shallow_commits_1(&sb
, 0, NULL
, flags
);
427 fd
= hold_lock_file_for_update(&shallow_lock
.lock
,
428 git_path_shallow(the_repository
),
430 check_shallow_file_for_update(the_repository
);
431 if (write_shallow_commits_1(&sb
, 0, NULL
, flags
)) {
432 if (write_in_full(fd
, sb
.buf
, sb
.len
) < 0)
433 die_errno("failed to write to %s",
434 get_lock_file_path(&shallow_lock
.lock
));
435 commit_shallow_file(the_repository
, &shallow_lock
);
437 unlink(git_path_shallow(the_repository
));
438 rollback_shallow_file(the_repository
, &shallow_lock
);
443 struct trace_key trace_shallow
= TRACE_KEY_INIT(SHALLOW
);
446 * Step 1, split sender shallow commits into "ours" and "theirs"
447 * Step 2, clean "ours" based on .git/shallow
449 void prepare_shallow_info(struct shallow_info
*info
, struct oid_array
*sa
)
452 trace_printf_key(&trace_shallow
, "shallow: prepare_shallow_info\n");
453 memset(info
, 0, sizeof(*info
));
457 ALLOC_ARRAY(info
->ours
, sa
->nr
);
458 ALLOC_ARRAY(info
->theirs
, sa
->nr
);
459 for (i
= 0; i
< sa
->nr
; i
++) {
460 if (has_object_file(sa
->oid
+ i
)) {
461 struct commit_graft
*graft
;
462 graft
= lookup_commit_graft(the_repository
,
464 if (graft
&& graft
->nr_parent
< 0)
466 info
->ours
[info
->nr_ours
++] = i
;
468 info
->theirs
[info
->nr_theirs
++] = i
;
472 void clear_shallow_info(struct shallow_info
*info
)
478 /* Step 4, remove non-existent ones in "theirs" after getting the pack */
480 void remove_nonexistent_theirs_shallow(struct shallow_info
*info
)
482 struct object_id
*oid
= info
->shallow
->oid
;
484 trace_printf_key(&trace_shallow
, "shallow: remove_nonexistent_theirs_shallow\n");
485 for (i
= dst
= 0; i
< info
->nr_theirs
; i
++) {
487 info
->theirs
[dst
] = info
->theirs
[i
];
488 if (has_object_file(oid
+ info
->theirs
[i
]))
491 info
->nr_theirs
= dst
;
494 define_commit_slab(ref_bitmap
, uint32_t *);
496 #define POOL_SIZE (512 * 1024)
499 struct ref_bitmap ref_bitmap
;
506 static uint32_t *paint_alloc(struct paint_info
*info
)
508 unsigned nr
= DIV_ROUND_UP(info
->nr_bits
, 32);
509 unsigned size
= nr
* sizeof(uint32_t);
511 if (!info
->pool_count
|| size
> info
->end
- info
->free
) {
512 if (size
> POOL_SIZE
)
513 BUG("pool size too small for %d in paint_alloc()",
516 REALLOC_ARRAY(info
->pools
, info
->pool_count
);
517 info
->free
= xmalloc(POOL_SIZE
);
518 info
->pools
[info
->pool_count
- 1] = info
->free
;
519 info
->end
= info
->free
+ POOL_SIZE
;
527 * Given a commit SHA-1, walk down to parents until either SEEN,
528 * UNINTERESTING or BOTTOM is hit. Set the id-th bit in ref_bitmap for
529 * all walked commits.
531 static void paint_down(struct paint_info
*info
, const struct object_id
*oid
,
535 struct commit_list
*head
= NULL
;
536 int bitmap_nr
= DIV_ROUND_UP(info
->nr_bits
, 32);
537 size_t bitmap_size
= st_mult(sizeof(uint32_t), bitmap_nr
);
538 struct commit
*c
= lookup_commit_reference_gently(the_repository
, oid
,
540 uint32_t *tmp
; /* to be freed before return */
546 tmp
= xmalloc(bitmap_size
);
547 bitmap
= paint_alloc(info
);
548 memset(bitmap
, 0, bitmap_size
);
549 bitmap
[id
/ 32] |= (1U << (id
% 32));
550 commit_list_insert(c
, &head
);
552 struct commit_list
*p
;
553 struct commit
*c
= pop_commit(&head
);
554 uint32_t **refs
= ref_bitmap_at(&info
->ref_bitmap
, c
);
556 /* XXX check "UNINTERESTING" from pack bitmaps if available */
557 if (c
->object
.flags
& (SEEN
| UNINTERESTING
))
560 c
->object
.flags
|= SEEN
;
565 memcpy(tmp
, *refs
, bitmap_size
);
566 for (i
= 0; i
< bitmap_nr
; i
++)
568 if (memcmp(tmp
, *refs
, bitmap_size
)) {
569 *refs
= paint_alloc(info
);
570 memcpy(*refs
, tmp
, bitmap_size
);
574 if (c
->object
.flags
& BOTTOM
)
578 die("unable to parse commit %s",
579 oid_to_hex(&c
->object
.oid
));
581 for (p
= c
->parents
; p
; p
= p
->next
) {
582 if (p
->item
->object
.flags
& SEEN
)
584 commit_list_insert(p
->item
, &head
);
588 nr
= get_max_object_index();
589 for (i
= 0; i
< nr
; i
++) {
590 struct object
*o
= get_indexed_object(i
);
591 if (o
&& o
->type
== OBJ_COMMIT
)
598 static int mark_uninteresting(const char *refname
, const struct object_id
*oid
,
599 int flags
, void *cb_data
)
601 struct commit
*commit
= lookup_commit_reference_gently(the_repository
,
605 commit
->object
.flags
|= UNINTERESTING
;
606 mark_parents_uninteresting(commit
);
610 static void post_assign_shallow(struct shallow_info
*info
,
611 struct ref_bitmap
*ref_bitmap
,
614 * Step 6(+7), associate shallow commits with new refs
616 * info->ref must be initialized before calling this function.
618 * If used is not NULL, it's an array of info->shallow->nr
619 * bitmaps. The n-th bit set in the m-th bitmap if ref[n] needs the
620 * m-th shallow commit from info->shallow.
622 * If used is NULL, "ours" and "theirs" are updated. And if ref_status
623 * is not NULL it's an array of ref->nr ints. ref_status[i] is true if
624 * the ref needs some shallow commits from either info->ours or
627 void assign_shallow_commits_to_refs(struct shallow_info
*info
,
628 uint32_t **used
, int *ref_status
)
630 struct object_id
*oid
= info
->shallow
->oid
;
631 struct oid_array
*ref
= info
->ref
;
633 int *shallow
, nr_shallow
= 0;
634 struct paint_info pi
;
636 trace_printf_key(&trace_shallow
, "shallow: assign_shallow_commits_to_refs\n");
637 ALLOC_ARRAY(shallow
, info
->nr_ours
+ info
->nr_theirs
);
638 for (i
= 0; i
< info
->nr_ours
; i
++)
639 shallow
[nr_shallow
++] = info
->ours
[i
];
640 for (i
= 0; i
< info
->nr_theirs
; i
++)
641 shallow
[nr_shallow
++] = info
->theirs
[i
];
644 * Prepare the commit graph to track what refs can reach what
645 * (new) shallow commits.
647 nr
= get_max_object_index();
648 for (i
= 0; i
< nr
; i
++) {
649 struct object
*o
= get_indexed_object(i
);
650 if (!o
|| o
->type
!= OBJ_COMMIT
)
653 o
->flags
&= ~(UNINTERESTING
| BOTTOM
| SEEN
);
656 memset(&pi
, 0, sizeof(pi
));
657 init_ref_bitmap(&pi
.ref_bitmap
);
658 pi
.nr_bits
= ref
->nr
;
661 * "--not --all" to cut short the traversal if new refs
662 * connect to old refs. If not (e.g. force ref updates) it'll
663 * have to go down to the current shallow commits.
665 head_ref(mark_uninteresting
, NULL
);
666 for_each_ref(mark_uninteresting
, NULL
);
668 /* Mark potential bottoms so we won't go out of bound */
669 for (i
= 0; i
< nr_shallow
; i
++) {
670 struct commit
*c
= lookup_commit(the_repository
,
672 c
->object
.flags
|= BOTTOM
;
675 for (i
= 0; i
< ref
->nr
; i
++)
676 paint_down(&pi
, ref
->oid
+ i
, i
);
679 int bitmap_size
= DIV_ROUND_UP(pi
.nr_bits
, 32) * sizeof(uint32_t);
680 memset(used
, 0, sizeof(*used
) * info
->shallow
->nr
);
681 for (i
= 0; i
< nr_shallow
; i
++) {
682 const struct commit
*c
= lookup_commit(the_repository
,
684 uint32_t **map
= ref_bitmap_at(&pi
.ref_bitmap
, c
);
686 used
[shallow
[i
]] = xmemdupz(*map
, bitmap_size
);
689 * unreachable shallow commits are not removed from
690 * "ours" and "theirs". The user is supposed to run
691 * step 7 on every ref separately and not trust "ours"
692 * and "theirs" any more.
695 post_assign_shallow(info
, &pi
.ref_bitmap
, ref_status
);
697 clear_ref_bitmap(&pi
.ref_bitmap
);
698 for (i
= 0; i
< pi
.pool_count
; i
++)
704 struct commit_array
{
705 struct commit
**commits
;
709 static int add_ref(const char *refname
, const struct object_id
*oid
,
710 int flags
, void *cb_data
)
712 struct commit_array
*ca
= cb_data
;
713 ALLOC_GROW(ca
->commits
, ca
->nr
+ 1, ca
->alloc
);
714 ca
->commits
[ca
->nr
] = lookup_commit_reference_gently(the_repository
,
716 if (ca
->commits
[ca
->nr
])
721 static void update_refstatus(int *ref_status
, int nr
, uint32_t *bitmap
)
726 for (i
= 0; i
< nr
; i
++)
727 if (bitmap
[i
/ 32] & (1U << (i
% 32)))
732 * Step 7, reachability test on "ours" at commit level
734 static void post_assign_shallow(struct shallow_info
*info
,
735 struct ref_bitmap
*ref_bitmap
,
738 struct object_id
*oid
= info
->shallow
->oid
;
742 int bitmap_nr
= DIV_ROUND_UP(info
->ref
->nr
, 32);
743 struct commit_array ca
;
745 trace_printf_key(&trace_shallow
, "shallow: post_assign_shallow\n");
747 memset(ref_status
, 0, sizeof(*ref_status
) * info
->ref
->nr
);
749 /* Remove unreachable shallow commits from "theirs" */
750 for (i
= dst
= 0; i
< info
->nr_theirs
; i
++) {
752 info
->theirs
[dst
] = info
->theirs
[i
];
753 c
= lookup_commit(the_repository
, &oid
[info
->theirs
[i
]]);
754 bitmap
= ref_bitmap_at(ref_bitmap
, c
);
757 for (j
= 0; j
< bitmap_nr
; j
++)
759 update_refstatus(ref_status
, info
->ref
->nr
, *bitmap
);
764 info
->nr_theirs
= dst
;
766 memset(&ca
, 0, sizeof(ca
));
767 head_ref(add_ref
, &ca
);
768 for_each_ref(add_ref
, &ca
);
770 /* Remove unreachable shallow commits from "ours" */
771 for (i
= dst
= 0; i
< info
->nr_ours
; i
++) {
773 info
->ours
[dst
] = info
->ours
[i
];
774 c
= lookup_commit(the_repository
, &oid
[info
->ours
[i
]]);
775 bitmap
= ref_bitmap_at(ref_bitmap
, c
);
778 for (j
= 0; j
< bitmap_nr
; j
++)
780 /* Step 7, reachability test at commit level */
781 !in_merge_bases_many(c
, ca
.nr
, ca
.commits
)) {
782 update_refstatus(ref_status
, info
->ref
->nr
, *bitmap
);
792 /* (Delayed) step 7, reachability test at commit level */
793 int delayed_reachability_test(struct shallow_info
*si
, int c
)
795 if (si
->need_reachability_test
[c
]) {
796 struct commit
*commit
= lookup_commit(the_repository
,
797 &si
->shallow
->oid
[c
]);
800 struct commit_array ca
;
802 memset(&ca
, 0, sizeof(ca
));
803 head_ref(add_ref
, &ca
);
804 for_each_ref(add_ref
, &ca
);
805 si
->commits
= ca
.commits
;
806 si
->nr_commits
= ca
.nr
;
809 si
->reachable
[c
] = in_merge_bases_many(commit
,
812 si
->need_reachability_test
[c
] = 0;
814 return si
->reachable
[c
];