@matheusbsbs / matheus-bagliano / commits / cfe3917c85
Fork 0

setup: allow check_repository_format to read repository format

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>

brian m. carlson committed Feb 22, 2020 at 20:17 UTC cfe3917c85f38c3367de7b6f5838ecaf6d1e148d
4 files changed +9 -5
builtin/init-db.c
+1 -1
@@ -378,7 +378,7 @@ int init_db(const char *git_dir, const char *real_git_dir,
378 * config file, so this will not fail. What we are catching
379 * is an attempt to reinitialize new repository with an old tool.
380 */
381 - check_repository_format();
381 + check_repository_format(NULL);
382
383 reinit = create_default_files(template_dir, original_git_dir);
384
cache.h
+3 -1
@@ -1086,8 +1086,10 @@ int verify_repository_format(const struct repository_format *format,
1086 * and die if it is a version we don't understand. Generally one would
1087 * set_git_dir() before calling this, and use it only for "are we in a valid
1088 * repo?".
1089 + *
1090 + * If successful and fmt is not NULL, fill fmt with data.
1091 */
1090 -void check_repository_format(void);
1092 +void check_repository_format(struct repository_format *fmt);
1093
1094 #define MTIME_CHANGED 0x0001
1095 #define CTIME_CHANGED 0x0002
path.c
+1 -1
@@ -851,7 +851,7 @@ const char *enter_repo(const char *path, int strict)
851
852 if (is_git_directory(".")) {
853 set_git_dir(".");
854 - check_repository_format();
854 + check_repository_format(NULL);
855 return path;
856 }
857
setup.c
+4 -2
@@ -1253,10 +1253,12 @@ int git_config_perm(const char *var, const char *value)
1253 return -(i & 0666);
1254 }
1255
1256 -void check_repository_format(void)
1256 +void check_repository_format(struct repository_format *fmt)
1257 {
1258 struct repository_format repo_fmt = REPOSITORY_FORMAT_INIT;
1259 - check_repository_format_gently(get_git_dir(), &repo_fmt, NULL);
1259 + if (!fmt)
1260 + fmt = &repo_fmt;
1261 + check_repository_format_gently(get_git_dir(), fmt, NULL);
1262 startup_info->have_repository = 1;
1263 clear_repository_format(&repo_fmt);
1264 }