Andrew's git
/
gitweb.git
/ diff
summary
|
log
|
commit
| diff |
tree
commit
grep
author
committer
pickaxe
?
re
setup.c: convert check_repository_format_gently to use strbuf
author
Nguyễn Thái Ngọc Duy
<pclouds@gmail.com>
Sun, 30 Nov 2014 08:24:42 +0000
(15:24 +0700)
committer
Junio C Hamano
<gitster@pobox.com>
Mon, 1 Dec 2014 19:00:15 +0000
(11:00 -0800)
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
setup.c
patch
|
blob
|
history
raw
|
patch
|
inline
| side by side (parent:
4dc4e14
)
diff --git
a/setup.c
b/setup.c
index 6c52f7585399edca9088f2b6f269b49bba8f6d6a..00a23e6edf454bce0a30783e57195f251c1e1e11 100644
(file)
--- a/
setup.c
+++ b/
setup.c
@@
-342,7
+342,9
@@
void setup_work_tree(void)
static int check_repository_format_gently(const char *gitdir, int *nongit_ok)
{
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()
/*
* git_config() can't be used here because it calls git_pathdup()
@@
-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.
*/
* 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)
git_config_early(check_repository_format_version, NULL, repo_config);
if (GIT_REPO_VERSION < repository_format_version) {
if (!nongit_ok)
@@
-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;
GIT_REPO_VERSION, repository_format_version);
warning("Please upgrade Git");
*nongit_ok = -1;
- ret
urn
-1;
+ ret
=
-1;
}
}
- return 0;
+ strbuf_release(&sb);
+ return ret;
}
/*
}
/*