Sync with 2.33.8
[git/debian.git] / shallow.h
blobaba6ff5829405647070c5b2a475318e2fd76282d
1 #ifndef SHALLOW_H
2 #define SHALLOW_H
4 #include "lockfile.h"
5 #include "object.h"
6 #include "repository.h"
7 #include "strbuf.h"
9 void set_alternate_shallow_file(struct repository *r, const char *path, int override);
10 int register_shallow(struct repository *r, const struct object_id *oid);
11 int unregister_shallow(const struct object_id *oid);
12 int is_repository_shallow(struct repository *r);
15 * Lock for updating the $GIT_DIR/shallow file.
17 * Use `commit_shallow_file()` to commit an update, or
18 * `rollback_shallow_file()` to roll it back. In either case, any
19 * in-memory cached information about which commits are shallow will be
20 * appropriately invalidated so that future operations reflect the new
21 * state.
23 struct shallow_lock {
24 struct lock_file lock;
26 #define SHALLOW_LOCK_INIT { \
27 .lock = LOCK_INIT, \
30 /* commit $GIT_DIR/shallow and reset stat-validity checks */
31 int commit_shallow_file(struct repository *r, struct shallow_lock *lk);
32 /* rollback $GIT_DIR/shallow and reset stat-validity checks */
33 void rollback_shallow_file(struct repository *r, struct shallow_lock *lk);
35 struct commit_list *get_shallow_commits(struct object_array *heads,
36 int depth, int shallow_flag, int not_shallow_flag);
37 struct commit_list *get_shallow_commits_by_rev_list(
38 int ac, const char **av, int shallow_flag, int not_shallow_flag);
39 int write_shallow_commits(struct strbuf *out, int use_pack_protocol,
40 const struct oid_array *extra);
42 void setup_alternate_shallow(struct shallow_lock *shallow_lock,
43 const char **alternate_shallow_file,
44 const struct oid_array *extra);
46 const char *setup_temporary_shallow(const struct oid_array *extra);
48 void advertise_shallow_grafts(int);
50 #define PRUNE_SHOW_ONLY 1
51 #define PRUNE_QUICK 2
52 void prune_shallow(unsigned options);
55 * Initialize with prepare_shallow_info() or zero-initialize (equivalent to
56 * prepare_shallow_info with a NULL oid_array).
58 struct shallow_info {
59 struct oid_array *shallow;
60 int *ours, nr_ours;
61 int *theirs, nr_theirs;
62 struct oid_array *ref;
64 /* for receive-pack */
65 uint32_t **used_shallow;
66 int *need_reachability_test;
67 int *reachable;
68 int *shallow_ref;
69 struct commit **commits;
70 int nr_commits;
73 void prepare_shallow_info(struct shallow_info *, struct oid_array *);
74 void clear_shallow_info(struct shallow_info *);
75 void remove_nonexistent_theirs_shallow(struct shallow_info *);
76 void assign_shallow_commits_to_refs(struct shallow_info *info,
77 uint32_t **used,
78 int *ref_status);
79 int delayed_reachability_test(struct shallow_info *si, int c);
81 extern struct trace_key trace_shallow;
83 #endif /* SHALLOW_H */