Skip to content

Commit 120ad2b

Browse files
ttaylorrgitster
authored andcommitted
shallow: extract a header file for shallow-related functions
There are many functions in commit.h that are more related to shallow repositories than they are to any sort of generic commit machinery. Likely this began when there were only a few shallow-related functions, and commit.h seemed a reasonable enough place to put them. But, now there are a good number of shallow-related functions, and placing them all in 'commit.h' doesn't make sense. This patch extracts a 'shallow.h', which takes all of the declarations from 'commit.h' for functions which already exist in 'shallow.c'. We will bring the remaining shallow-related functions defined in 'commit.c' in a subsequent patch. For now, move only the ones that already are implemented in 'shallow.c', and update the necessary includes. Signed-off-by: Taylor Blau <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 183df64 commit 120ad2b

16 files changed

+91
-61
lines changed

builtin/fetch.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
#include "branch.h"
2828
#include "promisor-remote.h"
2929
#include "commit-graph.h"
30+
#include "shallow.h"
3031

3132
#define FORCED_UPDATES_DELAY_WARNING_IN_MS (10 * 1000)
3233

builtin/pack-objects.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
#include "dir.h"
3535
#include "midx.h"
3636
#include "trace2.h"
37+
#include "shallow.h"
3738

3839
#define IN_PACK(obj) oe_in_pack(&to_pack, obj)
3940
#define SIZE(obj) oe_size(&to_pack, obj)

builtin/prune.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
#include "parse-options.h"
88
#include "progress.h"
99
#include "object-store.h"
10+
#include "shallow.h"
1011

1112
static const char * const prune_usage[] = {
1213
N_("git prune [-n] [-v] [--progress] [--expire <time>] [--] [<head>...]"),

builtin/receive-pack.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
#include "protocol.h"
2929
#include "commit-reach.h"
3030
#include "worktree.h"
31+
#include "shallow.h"
3132

3233
static const char * const receive_pack_usage[] = {
3334
N_("git receive-pack <git-dir>"),

builtin/repack.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#include "packfile.h"
1313
#include "object-store.h"
1414
#include "promisor-remote.h"
15+
#include "shallow.h"
1516

1617
static int delta_base_offset = 1;
1718
static int pack_kept_objects = -1;

builtin/rev-parse.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#include "split-index.h"
1717
#include "submodule.h"
1818
#include "commit-reach.h"
19+
#include "shallow.h"
1920

2021
#define DO_REVS 1
2122
#define DO_NOREV 2

commit-graph.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#include "hashmap.h"
1717
#include "replace-object.h"
1818
#include "progress.h"
19+
#include "shallow.h"
1920

2021
#define GRAPH_SIGNATURE 0x43475048 /* "CGPH" */
2122
#define GRAPH_CHUNKID_OIDFANOUT 0x4f494446 /* "OIDF" */

commit.c

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#include "refs.h"
2121
#include "commit-reach.h"
2222
#include "run-command.h"
23+
#include "shallow.h"
2324

2425
static struct commit_extra_header *read_commit_extra_header_lines(const char *buf, size_t len, const char **);
2526

@@ -245,19 +246,6 @@ int for_each_commit_graft(each_commit_graft_fn fn, void *cb_data)
245246
return ret;
246247
}
247248

248-
int unregister_shallow(const struct object_id *oid)
249-
{
250-
int pos = commit_graft_pos(the_repository, oid->hash);
251-
if (pos < 0)
252-
return -1;
253-
if (pos + 1 < the_repository->parsed_objects->grafts_nr)
254-
MOVE_ARRAY(the_repository->parsed_objects->grafts + pos,
255-
the_repository->parsed_objects->grafts + pos + 1,
256-
the_repository->parsed_objects->grafts_nr - pos - 1);
257-
the_repository->parsed_objects->grafts_nr--;
258-
return 0;
259-
}
260-
261249
struct commit_buffer {
262250
void *buffer;
263251
unsigned long size;

commit.h

Lines changed: 0 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -249,55 +249,7 @@ struct commit *get_fork_point(const char *refname, struct commit *commit);
249249

250250
struct oid_array;
251251
struct ref;
252-
int register_shallow(struct repository *r, const struct object_id *oid);
253-
int unregister_shallow(const struct object_id *oid);
254-
int commit_shallow_file(struct repository *r, struct lock_file *lk);
255-
void rollback_shallow_file(struct repository *r, struct lock_file *lk);
256252
int for_each_commit_graft(each_commit_graft_fn, void *);
257-
int is_repository_shallow(struct repository *r);
258-
struct commit_list *get_shallow_commits(struct object_array *heads,
259-
int depth, int shallow_flag, int not_shallow_flag);
260-
struct commit_list *get_shallow_commits_by_rev_list(
261-
int ac, const char **av, int shallow_flag, int not_shallow_flag);
262-
void set_alternate_shallow_file(struct repository *r, const char *path, int override);
263-
int write_shallow_commits(struct strbuf *out, int use_pack_protocol,
264-
const struct oid_array *extra);
265-
void setup_alternate_shallow(struct lock_file *shallow_lock,
266-
const char **alternate_shallow_file,
267-
const struct oid_array *extra);
268-
const char *setup_temporary_shallow(const struct oid_array *extra);
269-
void advertise_shallow_grafts(int);
270-
271-
/*
272-
* Initialize with prepare_shallow_info() or zero-initialize (equivalent to
273-
* prepare_shallow_info with a NULL oid_array).
274-
*/
275-
struct shallow_info {
276-
struct oid_array *shallow;
277-
int *ours, nr_ours;
278-
int *theirs, nr_theirs;
279-
struct oid_array *ref;
280-
281-
/* for receive-pack */
282-
uint32_t **used_shallow;
283-
int *need_reachability_test;
284-
int *reachable;
285-
int *shallow_ref;
286-
struct commit **commits;
287-
int nr_commits;
288-
};
289-
290-
void prepare_shallow_info(struct shallow_info *, struct oid_array *);
291-
void clear_shallow_info(struct shallow_info *);
292-
void remove_nonexistent_theirs_shallow(struct shallow_info *);
293-
void assign_shallow_commits_to_refs(struct shallow_info *info,
294-
uint32_t **used,
295-
int *ref_status);
296-
int delayed_reachability_test(struct shallow_info *si, int c);
297-
#define PRUNE_SHOW_ONLY 1
298-
#define PRUNE_QUICK 2
299-
void prune_shallow(unsigned options);
300-
extern struct trace_key trace_shallow;
301253

302254
int interactive_add(int argc, const char **argv, const char *prefix, int patch);
303255
int run_add_interactive(const char *revision, const char *patch_mode,

environment.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#include "argv-array.h"
1818
#include "object-store.h"
1919
#include "chdir-notify.h"
20+
#include "shallow.h"
2021

2122
int trust_executable_bit = 1;
2223
int trust_ctime = 1;

0 commit comments

Comments
 (0)