Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RFC: Consolidate reachability logic #8

Closed
wants to merge 18 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -716,6 +716,7 @@ TEST_BUILTINS_OBJS += test-mktemp.o
TEST_BUILTINS_OBJS += test-online-cpus.o
TEST_BUILTINS_OBJS += test-path-utils.o
TEST_BUILTINS_OBJS += test-prio-queue.o
TEST_BUILTINS_OBJS += test-reach.o
TEST_BUILTINS_OBJS += test-read-cache.o
TEST_BUILTINS_OBJS += test-ref-store.o
TEST_BUILTINS_OBJS += test-regex.o
Expand Down Expand Up @@ -829,6 +830,7 @@ LIB_OBJS += column.o
LIB_OBJS += combine-diff.o
LIB_OBJS += commit.o
LIB_OBJS += commit-graph.o
LIB_OBJS += commit-reach.o
LIB_OBJS += compat/obstack.o
LIB_OBJS += compat/terminal.o
LIB_OBJS += config.o
Expand Down
1 change: 1 addition & 0 deletions bisect.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#include "sha1-array.h"
#include "argv-array.h"
#include "commit-slab.h"
#include "commit-reach.h"

static struct oid_array good_revs;
static struct oid_array skipped_revs;
Expand Down
1 change: 1 addition & 0 deletions builtin/branch.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#include "ref-filter.h"
#include "worktree.h"
#include "help.h"
#include "commit-reach.h"

static const char * const builtin_branch_usage[] = {
N_("git branch [<options>] [-r | -a] [--merged | --no-merged]"),
Expand Down
1 change: 1 addition & 0 deletions builtin/commit.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
#include "sequencer.h"
#include "mailmap.h"
#include "help.h"
#include "commit-reach.h"

static const char * const builtin_commit_usage[] = {
N_("git commit [<options>] [--] <pathspec>..."),
Expand Down
1 change: 1 addition & 0 deletions builtin/fetch.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include "utf8.h"
#include "packfile.h"
#include "list-objects-filter-options.h"
#include "commit-reach.h"

static const char * const builtin_fetch_usage[] = {
N_("git fetch [<options>] [<repository> [<refspec>...]]"),
Expand Down
1 change: 1 addition & 0 deletions builtin/fmt-merge-msg.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#include "fmt-merge-msg.h"
#include "gpg-interface.h"
#include "repository.h"
#include "commit-reach.h"

static const char * const fmt_merge_msg_usage[] = {
N_("git fmt-merge-msg [-m <message>] [--log[=<n>] | --no-log] [--file <file>]"),
Expand Down
1 change: 1 addition & 0 deletions builtin/log.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
#include "progress.h"
#include "commit-slab.h"
#include "repository.h"
#include "commit-reach.h"

#define MAIL_DEFAULT_WRAP 72

Expand Down
1 change: 1 addition & 0 deletions builtin/merge-base.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include "revision.h"
#include "parse-options.h"
#include "repository.h"
#include "commit-reach.h"

static int show_merge_base(struct commit **rev, int rev_nr, int show_all)
{
Expand Down
1 change: 1 addition & 0 deletions builtin/merge.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
#include "packfile.h"
#include "tag.h"
#include "alias.h"
#include "commit-reach.h"

#define DEFAULT_TWOHEAD (1<<0)
#define DEFAULT_OCTOPUS (1<<1)
Expand Down
1 change: 1 addition & 0 deletions builtin/pull.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include "tempfile.h"
#include "lockfile.h"
#include "wt-status.h"
#include "commit-reach.h"

enum rebase_type {
REBASE_INVALID = -1,
Expand Down
1 change: 1 addition & 0 deletions builtin/receive-pack.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
#include "packfile.h"
#include "object-store.h"
#include "protocol.h"
#include "commit-reach.h"

static const char * const receive_pack_usage[] = {
N_("git receive-pack <git-dir>"),
Expand Down
1 change: 1 addition & 0 deletions builtin/remote.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include "refspec.h"
#include "object-store.h"
#include "argv-array.h"
#include "commit-reach.h"

static const char * const builtin_remote_usage[] = {
N_("git remote [-v | --verbose]"),
Expand Down
1 change: 1 addition & 0 deletions builtin/rev-parse.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#include "revision.h"
#include "split-index.h"
#include "submodule.h"
#include "commit-reach.h"

#define DO_REVS 1
#define DO_NOREV 2
Expand Down
18 changes: 18 additions & 0 deletions commit-graph.c
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,24 @@ static int prepare_commit_graph(struct repository *r)
return !!r->objects->commit_graph;
}

int generation_numbers_enabled(struct repository *r)
{
uint32_t first_generation;
struct commit_graph *g;
if (!prepare_commit_graph(r))
return 0;

g = r->objects->commit_graph;

if (!g->num_commits)
return 0;

first_generation = get_be32(g->chunk_commit_data +
g->hash_len + 8) >> 2;

return !!first_generation;
}

static void close_commit_graph(void)
{
free_commit_graph(the_repository->objects->commit_graph);
Expand Down
6 changes: 6 additions & 0 deletions commit-graph.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,12 @@ struct commit_graph {

struct commit_graph *load_commit_graph_one(const char *graph_file);

/*
* Return 1 if and only if the repository has a commit-graph
* file and generation numbers are computed in that file.
*/
int generation_numbers_enabled(struct repository *r);

void write_commit_graph_reachable(const char *obj_dir, int append);
void write_commit_graph(const char *obj_dir,
struct string_list *pack_indexes,
Expand Down
Loading