]> git.ipfire.org Git - thirdparty/git.git/blob - shallow.h
Merge branch 'jk/committer-date-is-author-date-fix-simplify'
[thirdparty/git.git] / shallow.h
1 #ifndef SHALLOW_H
2 #define SHALLOW_H
3
4 #include "lockfile.h"
5 #include "object.h"
6 #include "repository.h"
7 #include "strbuf.h"
8
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);
13
14 /*
15 * Lock for updating the $GIT_DIR/shallow file.
16 *
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.
22 */
23 struct shallow_lock {
24 struct lock_file lock;
25 };
26 #define SHALLOW_LOCK_INIT { LOCK_INIT }
27
28 /* commit $GIT_DIR/shallow and reset stat-validity checks */
29 int commit_shallow_file(struct repository *r, struct shallow_lock *lk);
30 /* rollback $GIT_DIR/shallow and reset stat-validity checks */
31 void rollback_shallow_file(struct repository *r, struct shallow_lock *lk);
32
33 struct commit_list *get_shallow_commits(struct object_array *heads,
34 int depth, int shallow_flag, int not_shallow_flag);
35 struct commit_list *get_shallow_commits_by_rev_list(
36 int ac, const char **av, int shallow_flag, int not_shallow_flag);
37 int write_shallow_commits(struct strbuf *out, int use_pack_protocol,
38 const struct oid_array *extra);
39
40 void setup_alternate_shallow(struct shallow_lock *shallow_lock,
41 const char **alternate_shallow_file,
42 const struct oid_array *extra);
43
44 const char *setup_temporary_shallow(const struct oid_array *extra);
45
46 void advertise_shallow_grafts(int);
47
48 #define PRUNE_SHOW_ONLY 1
49 #define PRUNE_QUICK 2
50 void prune_shallow(unsigned options);
51
52 /*
53 * Initialize with prepare_shallow_info() or zero-initialize (equivalent to
54 * prepare_shallow_info with a NULL oid_array).
55 */
56 struct shallow_info {
57 struct oid_array *shallow;
58 int *ours, nr_ours;
59 int *theirs, nr_theirs;
60 struct oid_array *ref;
61
62 /* for receive-pack */
63 uint32_t **used_shallow;
64 int *need_reachability_test;
65 int *reachable;
66 int *shallow_ref;
67 struct commit **commits;
68 int nr_commits;
69 };
70
71 void prepare_shallow_info(struct shallow_info *, struct oid_array *);
72 void clear_shallow_info(struct shallow_info *);
73 void remove_nonexistent_theirs_shallow(struct shallow_info *);
74 void assign_shallow_commits_to_refs(struct shallow_info *info,
75 uint32_t **used,
76 int *ref_status);
77 int delayed_reachability_test(struct shallow_info *si, int c);
78
79 extern struct trace_key trace_shallow;
80
81 #endif /* SHALLOW_H */