extension.partialclone: introduce partial clone extension

Introduce new repository extension option: `extensions.partialclone` See the update to Documentation/technical/repository-version.txt in this patch for more information. Signed-off-by: Jonathan Tan <jonathantanmy@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Jonathan Tan committed Dec 5, 2017 at 16:58 UTC 75b97fec171dbbf7ec73960cefb50c265cfb7af7
4 files changed +21 -1
Documentation/technical/repository-version.txt
+12
@@ -86,3 +86,15 @@ for testing format-1 compatibility.
86 When the config key `extensions.preciousObjects` is set to `true`,
87 objects in the repository MUST NOT be deleted (e.g., by `git-prune` or
88 `git repack -d`).
89 +
90 +`partialclone`
91 +~~~~~~~~~~~~~~
92 +
93 +When the config key `extensions.partialclone` is set, it indicates
94 +that the repo was created with a partial clone (or later performed
95 +a partial fetch) and that the remote may have omitted sending
96 +certain unwanted objects. Such a remote is called a "promisor remote"
97 +and it promises that all such omitted objects can be fetched from it
98 +in the future.
99 +
100 +The value of this key is the name of the promisor remote.
cache.h
+2
@@ -860,10 +860,12 @@ extern int grafts_replace_parents;
860 #define GIT_REPO_VERSION 0
861 #define GIT_REPO_VERSION_READ 1
862 extern int repository_format_precious_objects;
863 +extern char *repository_format_partial_clone;
864
865 struct repository_format {
866 int version;
867 int precious_objects;
868 + char *partial_clone; /* value of extensions.partialclone */
869 int is_bare;
870 char *work_tree;
871 struct string_list unknown_extensions;
environment.c
+1
@@ -27,6 +27,7 @@ int warn_ambiguous_refs = 1;
27 int warn_on_object_refname_ambiguity = 1;
28 int ref_paranoia = -1;
29 int repository_format_precious_objects;
30 +char *repository_format_partial_clone;
31 const char *git_commit_encoding;
32 const char *git_log_output_encoding;
33 const char *apply_default_whitespace;
setup.c
+6 -1
@@ -420,7 +420,11 @@ static int check_repo_format(const char *var, const char *value, void *vdata)
420 ;
421 else if (!strcmp(ext, "preciousobjects"))
422 data->precious_objects = git_config_bool(var, value);
423 - else
423 + else if (!strcmp(ext, "partialclone")) {
424 + if (!value)
425 + return config_error_nonbool(var);
426 + data->partial_clone = xstrdup(value);
427 + } else
428 string_list_append(&data->unknown_extensions, ext);
429 } else if (strcmp(var, "core.bare") == 0) {
430 data->is_bare = git_config_bool(var, value);
@@ -463,6 +467,7 @@ static int check_repository_format_gently(const char *gitdir, int *nongit_ok)
467 }
468
469 repository_format_precious_objects = candidate.precious_objects;
470 + repository_format_partial_clone = candidate.partial_clone;
471 string_list_clear(&candidate.unknown_extensions, 0);
472 if (!has_common) {
473 if (candidate.is_bare != -1) {