[PATCH] Add .git/version (Take 2)
From: Martin Atukunda <hidden>
Date: 2016-06-15 22:42:12
Subsystem:
the rest · Maintainer:
Linus Torvalds
Currently the version number can be considered version 1, so this patch just sets it to that. This patch supercedes my earlier attempt that erroneously used the git version number as the repo format version. Signed-Off-By: Martin Atukunda <redacted> --- init-db.c | 17 +++++++++++++++++ 1 files changed, 17 insertions(+), 0 deletions(-) applies-to: d1bb16b919a119cca6ee001f755f83251a2c2964 31e78e387d708da5e09f40436d5fdc9e9ec5e16c
diff --git a/init-db.c b/init-db.c
index bd88291..e403dac 100644
--- a/init-db.c
+++ b/init-db.c@@ -9,6 +9,8 @@ #define DEFAULT_GIT_TEMPLATE_DIR "/usr/share/git-core/templates/" #endif +#define REPO_VERSION 1 + static void safe_create_dir(const char *dir) { if (mkdir(dir, 0777) < 0) {
@@ -19,6 +21,17 @@ static void safe_create_dir(const char * } } +static void record_repo_version(const char *path) +{ + FILE *verfile = fopen(path, "w"); + if (!verfile) + die ("Can not write to %s?", path); + + fprintf(verfile, "%d\n", REPO_VERSION); + + fclose(verfile); +} + static int copy_file(const char *dst, const char *src, int mode) { int fdi, fdo, status;
@@ -212,6 +225,10 @@ static void create_default_files(const c fprintf(stderr, "Ignoring file modes\n"); } } + + /* record the version of the git repo */ + strcpy(path + len, "version"); + record_repo_version(path); } static const char init_db_usage[] =
--- 0.99.9.GIT -- Due to a shortage of devoted followers, the production of great leaders has been discontinued.