use xgetcwd() to get the current directory or die
Convert several calls of getcwd() and die() to use xgetcwd() instead. This way we get rid of fixed-size buffers (which can be too small depending on the used file system) and gain consistent error messages. Signed-off-by: Rene Scharfe <l.s.r@web.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
committed by
Junio C Hamano
parent
aa14e980ff
commit
56b9f6e738
@ -734,7 +734,7 @@ int cmd_rev_parse(int argc, const char **argv, const char *prefix)
|
||||
}
|
||||
if (!strcmp(arg, "--git-dir")) {
|
||||
const char *gitdir = getenv(GIT_DIR_ENVIRONMENT);
|
||||
static char cwd[PATH_MAX];
|
||||
char *cwd;
|
||||
int len;
|
||||
if (gitdir) {
|
||||
puts(gitdir);
|
||||
@ -744,10 +744,10 @@ int cmd_rev_parse(int argc, const char **argv, const char *prefix)
|
||||
puts(".git");
|
||||
continue;
|
||||
}
|
||||
if (!getcwd(cwd, PATH_MAX))
|
||||
die_errno("unable to get current working directory");
|
||||
cwd = xgetcwd();
|
||||
len = strlen(cwd);
|
||||
printf("%s%s.git\n", cwd, len && cwd[len-1] != '/' ? "/" : "");
|
||||
free(cwd);
|
||||
continue;
|
||||
}
|
||||
if (!strcmp(arg, "--resolve-git-dir")) {
|
||||
|
||||
Reference in New Issue
Block a user