]> git.ipfire.org Git - thirdparty/git.git/commitdiff
setup: allow check_repository_format to read repository format
authorbrian m. carlson <sandals@crustytoothpaste.net>
Sat, 22 Feb 2020 20:17:37 +0000 (20:17 +0000)
committerJunio C Hamano <gitster@pobox.com>
Mon, 24 Feb 2020 17:33:27 +0000 (09:33 -0800)
In some cases, we will want to not only check the repository format, but
extract the information that we've gained.  To do so, allow
check_repository_format to take a pointer to struct repository_format.
Allow passing NULL for this argument if we're not interested in the
information, and pass NULL for all existing callers.  A future patch
will make use of this information.

Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/init-db.c
cache.h
path.c
setup.c

index 944ec77fe1032775ff595f0b1eb99a1fb22d059f..b11f07064dff02519952b916955ca7c50e85328e 100644 (file)
@@ -378,7 +378,7 @@ int init_db(const char *git_dir, const char *real_git_dir,
         * config file, so this will not fail.  What we are catching
         * is an attempt to reinitialize new repository with an old tool.
         */
-       check_repository_format();
+       check_repository_format(NULL);
 
        reinit = create_default_files(template_dir, original_git_dir);
 
diff --git a/cache.h b/cache.h
index 158d7ccfd8854d1362ef925e4c0ecd1c88dcba32..29ee02a8d412c6875ab01f0cc97fbc9d0bc913a6 100644 (file)
--- a/cache.h
+++ b/cache.h
@@ -1086,8 +1086,10 @@ int verify_repository_format(const struct repository_format *format,
  * and die if it is a version we don't understand. Generally one would
  * set_git_dir() before calling this, and use it only for "are we in a valid
  * repo?".
+ *
+ * If successful and fmt is not NULL, fill fmt with data.
  */
-void check_repository_format(void);
+void check_repository_format(struct repository_format *fmt);
 
 #define MTIME_CHANGED  0x0001
 #define CTIME_CHANGED  0x0002
diff --git a/path.c b/path.c
index 88cf59300738a2f10750ff458fa35b1211f00ab8..a10b62c0c48a4cd5993aebd3eeed4222fd1e31b2 100644 (file)
--- a/path.c
+++ b/path.c
@@ -851,7 +851,7 @@ const char *enter_repo(const char *path, int strict)
 
        if (is_git_directory(".")) {
                set_git_dir(".");
-               check_repository_format();
+               check_repository_format(NULL);
                return path;
        }
 
diff --git a/setup.c b/setup.c
index 4ea7a0b081bfd20a87d413d887f6d6926dbde8ab..af20c3d7c0c647edca8e5b29e283226a93eb7750 100644 (file)
--- a/setup.c
+++ b/setup.c
@@ -1253,10 +1253,12 @@ int git_config_perm(const char *var, const char *value)
        return -(i & 0666);
 }
 
-void check_repository_format(void)
+void check_repository_format(struct repository_format *fmt)
 {
        struct repository_format repo_fmt = REPOSITORY_FORMAT_INIT;
-       check_repository_format_gently(get_git_dir(), &repo_fmt, NULL);
+       if (!fmt)
+               fmt = &repo_fmt;
+       check_repository_format_gently(get_git_dir(), fmt, NULL);
        startup_info->have_repository = 1;
        clear_repository_format(&repo_fmt);
 }