Skip to content

Commit 9de6ec2

Browse files
committed
Merge branch 'ds/reachable' into pu
The code for computing history reachability has been shuffled, obtained a bunch of new tests to cover them, and then being improved. * ds/reachable: commit-reach: use can_all_from_reach commit-reach: make can_all_from_reach... linear commit-reach: replace ref_newer logic test-reach: test commit_contains test-reach: test can_all_from_reach_with_flags test-reach: test reduce_heads test-reach: test get_merge_bases_many test-reach: test is_descendant_of test-reach: test in_merge_bases test-reach: create new test tool for ref_newer commit-reach: move can_all_from_reach_with_flags upload-pack: generalize commit date cutoff upload-pack: refactor ok_to_give_up() upload-pack: make reachable() more generic commit-reach: move commit_contains from ref-filter commit-reach: move ref_newer from remote.c commit.h: remove method declarations commit-reach: move walk methods from commit.c
2 parents f4d91a4 + 6cc0174 commit 9de6ec2

38 files changed

+1177
-631
lines changed

Makefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -723,6 +723,7 @@ TEST_BUILTINS_OBJS += test-mktemp.o
723723
TEST_BUILTINS_OBJS += test-online-cpus.o
724724
TEST_BUILTINS_OBJS += test-path-utils.o
725725
TEST_BUILTINS_OBJS += test-prio-queue.o
726+
TEST_BUILTINS_OBJS += test-reach.o
726727
TEST_BUILTINS_OBJS += test-read-cache.o
727728
TEST_BUILTINS_OBJS += test-read-midx.o
728729
TEST_BUILTINS_OBJS += test-ref-store.o
@@ -837,6 +838,7 @@ LIB_OBJS += column.o
837838
LIB_OBJS += combine-diff.o
838839
LIB_OBJS += commit.o
839840
LIB_OBJS += commit-graph.o
841+
LIB_OBJS += commit-reach.o
840842
LIB_OBJS += compat/obstack.o
841843
LIB_OBJS += compat/terminal.o
842844
LIB_OBJS += config.o

bisect.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#include "sha1-array.h"
1414
#include "argv-array.h"
1515
#include "commit-slab.h"
16+
#include "commit-reach.h"
1617

1718
static struct oid_array good_revs;
1819
static struct oid_array skipped_revs;

builtin/branch.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
#include "ref-filter.h"
2424
#include "worktree.h"
2525
#include "help.h"
26+
#include "commit-reach.h"
2627

2728
static const char * const builtin_branch_usage[] = {
2829
N_("git branch [<options>] [-r | -a] [--merged | --no-merged]"),

builtin/commit.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
#include "sequencer.h"
3434
#include "mailmap.h"
3535
#include "help.h"
36+
#include "commit-reach.h"
3637

3738
static const char * const builtin_commit_usage[] = {
3839
N_("git commit [<options>] [--] <pathspec>..."),

builtin/fetch.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
#include "packfile.h"
2424
#include "list-objects-filter-options.h"
2525
#include "remote-odb.h"
26+
#include "commit-reach.h"
2627

2728
static const char * const builtin_fetch_usage[] = {
2829
N_("git fetch [<options>] [<repository> [<refspec>...]]"),

builtin/fmt-merge-msg.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#include "fmt-merge-msg.h"
1313
#include "gpg-interface.h"
1414
#include "repository.h"
15+
#include "commit-reach.h"
1516

1617
static const char * const fmt_merge_msg_usage[] = {
1718
N_("git fmt-merge-msg [-m <message>] [--log[=<n>] | --no-log] [--file <file>]"),

builtin/log.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
#include "progress.h"
3232
#include "commit-slab.h"
3333
#include "repository.h"
34+
#include "commit-reach.h"
3435

3536
#define MAIL_DEFAULT_WRAP 72
3637

builtin/merge-base.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
#include "revision.h"
88
#include "parse-options.h"
99
#include "repository.h"
10+
#include "commit-reach.h"
1011

1112
static int show_merge_base(struct commit **rev, int rev_nr, int show_all)
1213
{

builtin/merge.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
#include "packfile.h"
3737
#include "tag.h"
3838
#include "alias.h"
39+
#include "commit-reach.h"
3940

4041
#define DEFAULT_TWOHEAD (1<<0)
4142
#define DEFAULT_OCTOPUS (1<<1)

builtin/pull.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
#include "tempfile.h"
2323
#include "lockfile.h"
2424
#include "wt-status.h"
25+
#include "commit-reach.h"
2526

2627
enum rebase_type {
2728
REBASE_INVALID = -1,

builtin/receive-pack.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
#include "packfile.h"
2828
#include "object-store.h"
2929
#include "protocol.h"
30+
#include "commit-reach.h"
3031

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

builtin/remote.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#include "refspec.h"
1111
#include "object-store.h"
1212
#include "argv-array.h"
13+
#include "commit-reach.h"
1314

1415
static const char * const builtin_remote_usage[] = {
1516
N_("git remote [-v | --verbose]"),

builtin/rev-parse.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#include "revision.h"
1515
#include "split-index.h"
1616
#include "submodule.h"
17+
#include "commit-reach.h"
1718

1819
#define DO_REVS 1
1920
#define DO_NOREV 2

commit-graph.c

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,24 @@ static int prepare_commit_graph(struct repository *r)
256256
return !!r->objects->commit_graph;
257257
}
258258

259+
int generation_numbers_enabled(struct repository *r)
260+
{
261+
uint32_t first_generation;
262+
struct commit_graph *g;
263+
if (!prepare_commit_graph(r))
264+
return 0;
265+
266+
g = r->objects->commit_graph;
267+
268+
if (!g->num_commits)
269+
return 0;
270+
271+
first_generation = get_be32(g->chunk_commit_data +
272+
g->hash_len + 8) >> 2;
273+
274+
return !!first_generation;
275+
}
276+
259277
void close_commit_graph(struct repository *r)
260278
{
261279
free_commit_graph(r->objects->commit_graph);

commit-graph.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,12 @@ struct commit_graph {
5151

5252
struct commit_graph *load_commit_graph_one(const char *graph_file);
5353

54+
/*
55+
* Return 1 if and only if the repository has a commit-graph
56+
* file and generation numbers are computed in that file.
57+
*/
58+
int generation_numbers_enabled(struct repository *r);
59+
5460
void write_commit_graph_reachable(const char *obj_dir, int append);
5561
void write_commit_graph(const char *obj_dir,
5662
struct string_list *pack_indexes,

0 commit comments

Comments
 (0)