]> git.ipfire.org Git - thirdparty/git.git/blame - shallow.h
Merge branch 'jt/t5500-unflake'
[thirdparty/git.git] / shallow.h
CommitLineData
120ad2b0
TB
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
9void set_alternate_shallow_file(struct repository *r, const char *path, int override);
10int register_shallow(struct repository *r, const struct object_id *oid);
11int unregister_shallow(const struct object_id *oid);
12int is_repository_shallow(struct repository *r);
cac4b8e2
TB
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 */
23struct shallow_lock {
24 struct lock_file lock;
25};
26#define SHALLOW_LOCK_INIT { LOCK_INIT }
27
a4101617 28/* commit $GIT_DIR/shallow and reset stat-validity checks */
cac4b8e2 29int commit_shallow_file(struct repository *r, struct shallow_lock *lk);
a4101617 30/* rollback $GIT_DIR/shallow and reset stat-validity checks */
cac4b8e2 31void rollback_shallow_file(struct repository *r, struct shallow_lock *lk);
120ad2b0
TB
32
33struct commit_list *get_shallow_commits(struct object_array *heads,
34 int depth, int shallow_flag, int not_shallow_flag);
35struct commit_list *get_shallow_commits_by_rev_list(
36 int ac, const char **av, int shallow_flag, int not_shallow_flag);
37int write_shallow_commits(struct strbuf *out, int use_pack_protocol,
38 const struct oid_array *extra);
39
cac4b8e2 40void setup_alternate_shallow(struct shallow_lock *shallow_lock,
120ad2b0
TB
41 const char **alternate_shallow_file,
42 const struct oid_array *extra);
43
44const char *setup_temporary_shallow(const struct oid_array *extra);
45
46void advertise_shallow_grafts(int);
47
48#define PRUNE_SHOW_ONLY 1
49#define PRUNE_QUICK 2
50void 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 */
56struct 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
71void prepare_shallow_info(struct shallow_info *, struct oid_array *);
72void clear_shallow_info(struct shallow_info *);
73void remove_nonexistent_theirs_shallow(struct shallow_info *);
74void assign_shallow_commits_to_refs(struct shallow_info *info,
75 uint32_t **used,
76 int *ref_status);
77int delayed_reachability_test(struct shallow_info *si, int c);
78
79extern struct trace_key trace_shallow;
80
81#endif /* SHALLOW_H */