Skip to content

Commit cfe3917

Browse files
bk2204gitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent bf154a8 commit cfe3917

File tree

4 files changed

+9
-5
lines changed

4 files changed

+9
-5
lines changed

builtin/init-db.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -378,7 +378,7 @@ int init_db(const char *git_dir, const char *real_git_dir,
378378
* config file, so this will not fail. What we are catching
379379
* is an attempt to reinitialize new repository with an old tool.
380380
*/
381-
check_repository_format();
381+
check_repository_format(NULL);
382382

383383
reinit = create_default_files(template_dir, original_git_dir);
384384

cache.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1086,8 +1086,10 @@ int verify_repository_format(const struct repository_format *format,
10861086
* and die if it is a version we don't understand. Generally one would
10871087
* set_git_dir() before calling this, and use it only for "are we in a valid
10881088
* repo?".
1089+
*
1090+
* If successful and fmt is not NULL, fill fmt with data.
10891091
*/
1090-
void check_repository_format(void);
1092+
void check_repository_format(struct repository_format *fmt);
10911093

10921094
#define MTIME_CHANGED 0x0001
10931095
#define CTIME_CHANGED 0x0002

path.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -851,7 +851,7 @@ const char *enter_repo(const char *path, int strict)
851851

852852
if (is_git_directory(".")) {
853853
set_git_dir(".");
854-
check_repository_format();
854+
check_repository_format(NULL);
855855
return path;
856856
}
857857

setup.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1253,10 +1253,12 @@ int git_config_perm(const char *var, const char *value)
12531253
return -(i & 0666);
12541254
}
12551255

1256-
void check_repository_format(void)
1256+
void check_repository_format(struct repository_format *fmt)
12571257
{
12581258
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);
12601262
startup_info->have_repository = 1;
12611263
clear_repository_format(&repo_fmt);
12621264
}

0 commit comments

Comments
 (0)