Skip to content

Commit

Permalink
setup.c: convert check_repository_format_gently to use strbuf
Browse files Browse the repository at this point in the history
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
Nguyễn Thái Ngọc Duy authored and Junio C Hamano committed Dec 1, 2014
1 parent 4dc4e14 commit 7d0fb0d
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions setup.c
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,9 @@ void setup_work_tree(void)

static int check_repository_format_gently(const char *gitdir, int *nongit_ok)
{
char repo_config[PATH_MAX+1];
struct strbuf sb = STRBUF_INIT;
const char *repo_config;
int ret = 0;

/*
* git_config() can't be used here because it calls git_pathdup()
Expand All @@ -353,7 +355,8 @@ static int check_repository_format_gently(const char *gitdir, int *nongit_ok)
* Use a gentler version of git_config() to check if this repo
* is a good one.
*/
snprintf(repo_config, PATH_MAX, "%s/config", gitdir);
strbuf_addf(&sb, "%s/config", gitdir);
repo_config = sb.buf;
git_config_early(check_repository_format_version, NULL, repo_config);
if (GIT_REPO_VERSION < repository_format_version) {
if (!nongit_ok)
Expand All @@ -363,9 +366,10 @@ static int check_repository_format_gently(const char *gitdir, int *nongit_ok)
GIT_REPO_VERSION, repository_format_version);
warning("Please upgrade Git");
*nongit_ok = -1;
return -1;
ret = -1;
}
return 0;
strbuf_release(&sb);
return ret;
}

/*
Expand Down

0 comments on commit 7d0fb0d

Please sign in to comment.