-
Notifications
You must be signed in to change notification settings - Fork 145
Reftable support git-core #539
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
Changes from all commits
e1d1d9f
502a66b
1bd136f
5bbbafb
e41fa78
d94ee26
13e422e
4870668
1da5494
d097b42
17c4401
3e1c064
2f1c37f
d85614c
2634784
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -728,6 +728,7 @@ TEST_BUILTINS_OBJS += test-read-cache.o | |
TEST_BUILTINS_OBJS += test-read-graph.o | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. On the Git mailing list, Junio C Hamano wrote (reply to this):
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. On the Git mailing list, hanwen@google.com wrote (reply to this):
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. On the Git mailing list, Junio C Hamano wrote (reply to this):
|
||
TEST_BUILTINS_OBJS += test-read-midx.o | ||
TEST_BUILTINS_OBJS += test-ref-store.o | ||
TEST_BUILTINS_OBJS += test-reftable.o | ||
TEST_BUILTINS_OBJS += test-regex.o | ||
TEST_BUILTINS_OBJS += test-repository.o | ||
TEST_BUILTINS_OBJS += test-revision-walking.o | ||
|
@@ -804,6 +805,8 @@ TEST_SHELL_PATH = $(SHELL_PATH) | |
|
||
LIB_FILE = libgit.a | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. On the Git mailing list, Jeff King wrote (reply to this):
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. On the Git mailing list, Martin Fick wrote (reply to this):
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. On the Git mailing list, Han-Wen Nienhuys wrote (reply to this):
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. On the Git mailing list, Jeff King wrote (reply to this):
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. On the Git mailing list, Jeff King wrote (reply to this):
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. On the Git mailing list, Jeff King wrote (reply to this):
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. On the Git mailing list, Jeff King wrote (reply to this):
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. On the Git mailing list, Han-Wen Nienhuys wrote (reply to this):
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. On the Git mailing list, Han-Wen Nienhuys wrote (reply to this):
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. On the Git mailing list, Jeff King wrote (reply to this):
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. On the Git mailing list, "brian m. carlson" wrote (reply to this):
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. On the Git mailing list, Han-Wen Nienhuys wrote (reply to this):
|
||
XDIFF_LIB = xdiff/lib.a | ||
REFTABLE_LIB = reftable/libreftable.a | ||
REFTABLE_TEST_LIB = reftable/libreftable_test.a | ||
|
||
GENERATED_H += command-list.h | ||
GENERATED_H += config-list.h | ||
|
@@ -964,6 +967,7 @@ LIB_OBJS += reflog-walk.o | |
LIB_OBJS += refs.o | ||
LIB_OBJS += refs/debug.o | ||
LIB_OBJS += refs/files-backend.o | ||
LIB_OBJS += refs/reftable-backend.o | ||
LIB_OBJS += refs/iterator.o | ||
LIB_OBJS += refs/packed-backend.o | ||
LIB_OBJS += refs/ref-cache.o | ||
|
@@ -1172,7 +1176,7 @@ THIRD_PARTY_SOURCES += compat/regex/% | |
THIRD_PARTY_SOURCES += sha1collisiondetection/% | ||
THIRD_PARTY_SOURCES += sha1dc/% | ||
|
||
GITLIBS = common-main.o $(LIB_FILE) $(XDIFF_LIB) | ||
GITLIBS = common-main.o $(LIB_FILE) $(XDIFF_LIB) $(REFTABLE_LIB) | ||
EXTLIBS = | ||
|
||
GIT_USER_AGENT = git/$(GIT_VERSION) | ||
|
@@ -2379,10 +2383,40 @@ XDIFF_OBJS += xdiff/xpatience.o | |
XDIFF_OBJS += xdiff/xprepare.o | ||
XDIFF_OBJS += xdiff/xutils.o | ||
|
||
REFTABLE_OBJS += reftable/basics.o | ||
REFTABLE_OBJS += reftable/error.o | ||
REFTABLE_OBJS += reftable/block.o | ||
REFTABLE_OBJS += reftable/blocksource.o | ||
REFTABLE_OBJS += reftable/iter.o | ||
REFTABLE_OBJS += reftable/merged.o | ||
REFTABLE_OBJS += reftable/pq.o | ||
REFTABLE_OBJS += reftable/publicbasics.o | ||
REFTABLE_OBJS += reftable/reader.o | ||
REFTABLE_OBJS += reftable/record.o | ||
REFTABLE_OBJS += reftable/refname.o | ||
REFTABLE_OBJS += reftable/reftable.o | ||
REFTABLE_OBJS += reftable/stack.o | ||
REFTABLE_OBJS += reftable/tree.o | ||
REFTABLE_OBJS += reftable/writer.o | ||
REFTABLE_OBJS += reftable/zlib-compat.o | ||
|
||
REFTABLE_TEST_OBJS += reftable/basics_test.o | ||
REFTABLE_TEST_OBJS += reftable/block_test.o | ||
REFTABLE_TEST_OBJS += reftable/dump.o | ||
REFTABLE_TEST_OBJS += reftable/merged_test.o | ||
REFTABLE_TEST_OBJS += reftable/record_test.o | ||
REFTABLE_TEST_OBJS += reftable/refname_test.o | ||
REFTABLE_TEST_OBJS += reftable/reftable_test.o | ||
REFTABLE_TEST_OBJS += reftable/stack_test.o | ||
REFTABLE_TEST_OBJS += reftable/test_framework.o | ||
REFTABLE_TEST_OBJS += reftable/tree_test.o | ||
|
||
TEST_OBJS := $(patsubst %$X,%.o,$(TEST_PROGRAMS)) $(patsubst %,t/helper/%,$(TEST_BUILTINS_OBJS)) | ||
OBJECTS := $(LIB_OBJS) $(BUILTIN_OBJS) $(PROGRAM_OBJS) $(TEST_OBJS) \ | ||
$(XDIFF_OBJS) \ | ||
$(FUZZ_OBJS) \ | ||
$(REFTABLE_OBJS) \ | ||
$(REFTABLE_TEST_OBJS) \ | ||
common-main.o \ | ||
git.o | ||
ifndef NO_CURL | ||
|
@@ -2534,6 +2568,12 @@ $(LIB_FILE): $(LIB_OBJS) | |
$(XDIFF_LIB): $(XDIFF_OBJS) | ||
$(QUIET_AR)$(RM) $@ && $(AR) $(ARFLAGS) $@ $^ | ||
|
||
$(REFTABLE_LIB): $(REFTABLE_OBJS) | ||
$(QUIET_AR)$(RM) $@ && $(AR) $(ARFLAGS) $@ $^ | ||
|
||
$(REFTABLE_TEST_LIB): $(REFTABLE_TEST_OBJS) | ||
$(QUIET_AR)$(RM) $@ && $(AR) $(ARFLAGS) $@ $^ | ||
|
||
export DEFAULT_EDITOR DEFAULT_PAGER | ||
|
||
Documentation/GIT-EXCLUDED-PROGRAMS: FORCE | ||
|
@@ -2812,7 +2852,7 @@ perf: all | |
|
||
t/helper/test-tool$X: $(patsubst %,t/helper/%,$(TEST_BUILTINS_OBJS)) | ||
|
||
t/helper/test-%$X: t/helper/test-%.o GIT-LDFLAGS $(GITLIBS) | ||
t/helper/test-%$X: t/helper/test-%.o GIT-LDFLAGS $(GITLIBS) $(REFTABLE_TEST_LIB) | ||
$(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) $(filter %.a,$^) $(LIBS) | ||
|
||
check-sha1:: t/helper/test-tool$X | ||
|
@@ -3142,7 +3182,7 @@ cocciclean: | |
clean: profile-clean coverage-clean cocciclean | ||
$(RM) *.res | ||
$(RM) $(OBJECTS) | ||
$(RM) $(LIB_FILE) $(XDIFF_LIB) | ||
$(RM) $(LIB_FILE) $(XDIFF_LIB) $(REFTABLE_LIB) $(REFTABLE_TEST_LIB) | ||
$(RM) $(ALL_PROGRAMS) $(SCRIPT_LIB) $(BUILT_INS) git$X | ||
$(RM) $(TEST_PROGRAMS) | ||
$(RM) $(FUZZ_PROGRAMS) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -179,12 +179,14 @@ static int needs_work_tree_config(const char *git_dir, const char *work_tree) | |
return 1; | ||
} | ||
|
||
void initialize_repository_version(int hash_algo, int reinit) | ||
void initialize_repository_version(int hash_algo, int reinit, | ||
const char *ref_storage_format) | ||
{ | ||
char repo_version_string[10]; | ||
int repo_version = GIT_REPO_VERSION; | ||
|
||
if (hash_algo != GIT_HASH_SHA1) | ||
if (hash_algo != GIT_HASH_SHA1 || | ||
!strcmp(ref_storage_format, "reftable")) | ||
repo_version = GIT_REPO_VERSION_READ; | ||
|
||
/* This forces creation of new config file */ | ||
|
@@ -238,6 +240,7 @@ static int create_default_files(const char *template_path, | |
is_bare_repository_cfg = init_is_bare_repository; | ||
if (init_shared_repository != -1) | ||
set_shared_repository(init_shared_repository); | ||
the_repository->ref_storage_format = xstrdup(fmt->ref_storage); | ||
|
||
/* | ||
* We would have created the above under user's umask -- under | ||
|
@@ -247,6 +250,24 @@ static int create_default_files(const char *template_path, | |
adjust_shared_perm(get_git_dir()); | ||
} | ||
|
||
/* | ||
* Check to see if .git/HEAD exists; this must happen before | ||
* initializing the ref db, because we want to see if there is an | ||
* existing HEAD. | ||
*/ | ||
path = git_path_buf(&buf, "HEAD"); | ||
reinit = (!access(path, R_OK) || | ||
readlink(path, junk, sizeof(junk) - 1) != -1); | ||
|
||
/* | ||
* refs/heads is a file when using reftable. We can't reinitialize with | ||
* a reftable because it will overwrite HEAD | ||
*/ | ||
if (reinit && (!strcmp(fmt->ref_storage, "reftable")) == | ||
is_directory(git_path_buf(&buf, "refs/heads"))) { | ||
die("cannot switch ref storage format."); | ||
} | ||
|
||
/* | ||
* We need to create a "refs" dir in any case so that older | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. On the Git mailing list, Junio C Hamano wrote (reply to this):
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. On the Git mailing list, Han-Wen Nienhuys wrote (reply to this):
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. On the Git mailing list, Junio C Hamano wrote (reply to this):
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. On the Git mailing list, Junio C Hamano wrote (reply to this):
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. On the Git mailing list, Han-Wen Nienhuys wrote (reply to this):
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. On the Git mailing list, SZEDER Gábor wrote (reply to this):
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. On the Git mailing list, Jeff King wrote (reply to this):
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. On the Git mailing list, Emily Shaffer wrote (reply to this):
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. On the Git mailing list, Junio C Hamano wrote (reply to this):
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. On the Git mailing list, Han-Wen Nienhuys wrote (reply to this):
|
||
* versions of git can tell that this is a repository. | ||
|
@@ -261,9 +282,6 @@ static int create_default_files(const char *template_path, | |
* Point the HEAD symref to the initial branch with if HEAD does | ||
* not yet exist. | ||
*/ | ||
path = git_path_buf(&buf, "HEAD"); | ||
reinit = (!access(path, R_OK) | ||
|| readlink(path, junk, sizeof(junk)-1) != -1); | ||
if (!reinit) { | ||
char *ref; | ||
|
||
|
@@ -280,7 +298,7 @@ static int create_default_files(const char *template_path, | |
free(ref); | ||
} | ||
|
||
initialize_repository_version(fmt->hash_algo, 0); | ||
initialize_repository_version(fmt->hash_algo, 0, fmt->ref_storage); | ||
|
||
/* Check filemode trustability */ | ||
path = git_path_buf(&buf, "config"); | ||
|
@@ -396,7 +414,7 @@ static void validate_hash_algorithm(struct repository_format *repo_fmt, int hash | |
|
||
int init_db(const char *git_dir, const char *real_git_dir, | ||
const char *template_dir, int hash, const char *initial_branch, | ||
unsigned int flags) | ||
const char *ref_storage_format, unsigned int flags) | ||
{ | ||
int reinit; | ||
int exist_ok = flags & INIT_DB_EXIST_OK; | ||
|
@@ -435,9 +453,31 @@ int init_db(const char *git_dir, const char *real_git_dir, | |
* is an attempt to reinitialize new repository with an old tool. | ||
*/ | ||
check_repository_format(&repo_fmt); | ||
repo_fmt.ref_storage = xstrdup(ref_storage_format); | ||
|
||
validate_hash_algorithm(&repo_fmt, hash); | ||
|
||
/* | ||
* At this point, the_repository we have in-core does not look | ||
* anything like one that we would see initialized in an already | ||
* working repository after calling setup_git_directory(). | ||
* | ||
* Calling repository.c::initialize_the_repository() may have | ||
* prepared the .index .objects and .parsed_objects members, but | ||
* other members like .gitdir, .commondir, etc. have not been | ||
* initialized. | ||
* | ||
* Many API functions assume they are working with the_repository | ||
* that has sensibly been initialized, but because we haven't | ||
* really read from an existing repository, we need to hand-craft | ||
* the necessary members of the structure to get out of this | ||
* chicken-and-egg situation. | ||
* | ||
* For now, we update the hash algorithm member to what the | ||
* validate_hash_algorithm() call decided for us. | ||
*/ | ||
repo_set_hash_algo(the_repository, repo_fmt.hash_algo); | ||
|
||
reinit = create_default_files(template_dir, original_git_dir, | ||
initial_branch, &repo_fmt, | ||
flags & INIT_DB_QUIET); | ||
|
@@ -468,6 +508,9 @@ int init_db(const char *git_dir, const char *real_git_dir, | |
git_config_set("receive.denyNonFastforwards", "true"); | ||
} | ||
|
||
if (!strcmp(ref_storage_format, "reftable")) | ||
git_config_set("extensions.refStorage", ref_storage_format); | ||
|
||
if (!(flags & INIT_DB_QUIET)) { | ||
int len = strlen(git_dir); | ||
|
||
|
@@ -541,6 +584,7 @@ static const char *const init_db_usage[] = { | |
int cmd_init_db(int argc, const char **argv, const char *prefix) | ||
{ | ||
const char *git_dir; | ||
const char *ref_storage_format = default_ref_storage(); | ||
const char *real_git_dir = NULL; | ||
const char *work_tree; | ||
const char *template_dir = NULL; | ||
|
@@ -549,15 +593,18 @@ int cmd_init_db(int argc, const char **argv, const char *prefix) | |
const char *initial_branch = NULL; | ||
int hash_algo = GIT_HASH_UNKNOWN; | ||
const struct option init_db_options[] = { | ||
OPT_STRING(0, "template", &template_dir, N_("template-directory"), | ||
N_("directory from which templates will be used")), | ||
OPT_STRING(0, "template", &template_dir, | ||
N_("template-directory"), | ||
N_("directory from which templates will be used")), | ||
OPT_SET_INT(0, "bare", &is_bare_repository_cfg, | ||
N_("create a bare repository"), 1), | ||
N_("create a bare repository"), 1), | ||
{ OPTION_CALLBACK, 0, "shared", &init_shared_repository, | ||
N_("permissions"), | ||
N_("specify that the git repository is to be shared amongst several users"), | ||
PARSE_OPT_OPTARG | PARSE_OPT_NONEG, shared_callback, 0}, | ||
N_("permissions"), | ||
N_("specify that the git repository is to be shared amongst several users"), | ||
PARSE_OPT_OPTARG | PARSE_OPT_NONEG, shared_callback, 0 }, | ||
OPT_BIT('q', "quiet", &flags, N_("be quiet"), INIT_DB_QUIET), | ||
OPT_STRING(0, "ref-storage", &ref_storage_format, N_("backend"), | ||
N_("the ref storage format to use")), | ||
OPT_STRING(0, "separate-git-dir", &real_git_dir, N_("gitdir"), | ||
N_("separate git dir from working tree")), | ||
OPT_STRING('b', "initial-branch", &initial_branch, N_("name"), | ||
|
@@ -698,10 +745,11 @@ int cmd_init_db(int argc, const char **argv, const char *prefix) | |
} | ||
|
||
UNLEAK(real_git_dir); | ||
UNLEAK(ref_storage_format); | ||
UNLEAK(git_dir); | ||
UNLEAK(work_tree); | ||
|
||
flags |= INIT_DB_EXIST_OK; | ||
return init_db(git_dir, real_git_dir, template_dir, hash_algo, | ||
initial_branch, flags); | ||
initial_branch, ref_storage_format, flags); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On the Git mailing list, Junio C Hamano wrote (reply to this):
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On the Git mailing list, Han-Wen Nienhuys wrote (reply to this):
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On the Git mailing list, Junio C Hamano wrote (reply to this):
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On the Git mailing list, Han-Wen Nienhuys wrote (reply to this):
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On the Git mailing list, Junio C Hamano wrote (reply to this):
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On the Git mailing list, Han-Wen Nienhuys wrote (reply to this):