Repository format version check.
This adds the repository format version code, first done by Martin Atukunda. Signed-off-by: Junio C Hamano <junkio@cox.net>
Junio C Hamano committed
Nov 25, 2005 at 15:59 UTC
ab9cb76f661c1794800361c27bc5a515245aaaef
3 files changed
+22
cache.h
+5
@@ -182,6 +182,10 @@ extern int trust_executable_bit;
182
extern int only_use_symrefs;
183
extern int diff_rename_limit_default;
184
185
+#define GIT_REPO_VERSION 0
186
+extern int repository_format_version;
187
+extern int check_repository_format(void);
188
+
189
#define MTIME_CHANGED 0x0001
190
#define CTIME_CHANGED 0x0002
191
#define OWNER_CHANGED 0x0004
@@ -388,6 +392,7 @@ extern int git_config_int(const char *, const char *);
392
extern int git_config_bool(const char *, const char *);
393
extern int git_config_set(const char *, const char *);
394
extern int git_config_set_multivar(const char *, const char *, const char *, int);
395
+extern int check_repository_format_version(const char *var, const char *value);
396
397
#define MAX_GITNAME (1000)
398
extern char git_default_email[MAX_GITNAME];
environment.c
+1
@@ -13,6 +13,7 @@ char git_default_email[MAX_GITNAME];
13
char git_default_name[MAX_GITNAME];
14
int trust_executable_bit = 1;
15
int only_use_symrefs = 0;
16
+int repository_format_version = 0;
17
18
static char *git_dir, *git_object_dir, *git_index_file, *git_refs_dir,
19
*git_graft_file;
setup.c
+16
@@ -154,6 +154,22 @@ static const char *setup_git_directory_1(void)
154
return cwd + offset;
155
}
156
157
+int check_repository_format_version(const char *var, const char *value)
158
+{
159
+ if (strcmp(var, "core.repositoryformatversion") == 0)
160
+ repository_format_version = git_config_int(var, value);
161
+ return 0;
162
+}
163
+
164
+int check_repository_format(void)
165
+{
166
+ git_config(check_repository_format_version);
167
+ if (GIT_REPO_VERSION < repository_format_version)
168
+ die ("Expected git repo version <= %d, found %d",
169
+ GIT_REPO_VERSION, repository_format_version);
170
+ return 0;
171
+}
172
+
173
const char *setup_git_directory(void)
174
{
175
const char *retval = setup_git_directory_1();