]> git.ipfire.org Git - thirdparty/git.git/blame - shallow.h
t1405: explictly delete reflogs for reftable
[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};
f69a6e4f
ÆAB
26#define SHALLOW_LOCK_INIT { \
27 .lock = LOCK_INIT, \
28}
cac4b8e2 29
a4101617 30/* commit $GIT_DIR/shallow and reset stat-validity checks */
cac4b8e2 31int commit_shallow_file(struct repository *r, struct shallow_lock *lk);
a4101617 32/* rollback $GIT_DIR/shallow and reset stat-validity checks */
cac4b8e2 33void rollback_shallow_file(struct repository *r, struct shallow_lock *lk);
120ad2b0
TB
34
35struct commit_list *get_shallow_commits(struct object_array *heads,
36 int depth, int shallow_flag, int not_shallow_flag);
37struct commit_list *get_shallow_commits_by_rev_list(
38 int ac, const char **av, int shallow_flag, int not_shallow_flag);
39int write_shallow_commits(struct strbuf *out, int use_pack_protocol,
40 const struct oid_array *extra);
41
cac4b8e2 42void setup_alternate_shallow(struct shallow_lock *shallow_lock,
120ad2b0
TB
43 const char **alternate_shallow_file,
44 const struct oid_array *extra);
45
46const char *setup_temporary_shallow(const struct oid_array *extra);
47
48void advertise_shallow_grafts(int);
49
50#define PRUNE_SHOW_ONLY 1
51#define PRUNE_QUICK 2
52void prune_shallow(unsigned options);
53
54/*
55 * Initialize with prepare_shallow_info() or zero-initialize (equivalent to
56 * prepare_shallow_info with a NULL oid_array).
57 */
58struct shallow_info {
59 struct oid_array *shallow;
60 int *ours, nr_ours;
61 int *theirs, nr_theirs;
62 struct oid_array *ref;
63
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;
71};
72
73void prepare_shallow_info(struct shallow_info *, struct oid_array *);
74void clear_shallow_info(struct shallow_info *);
75void remove_nonexistent_theirs_shallow(struct shallow_info *);
76void assign_shallow_commits_to_refs(struct shallow_info *info,
77 uint32_t **used,
78 int *ref_status);
79int delayed_reachability_test(struct shallow_info *si, int c);
80
81extern struct trace_key trace_shallow;
82
83#endif /* SHALLOW_H */