summaryrefslogtreecommitdiff
path: root/setup.c
diff options
context:
space:
mode:
authorRené Scharfe <l.s.r@web.de>2014-07-28 20:30:39 +0200
committerJunio C Hamano <gitster@pobox.com>2014-08-26 11:06:06 -0700
commit56b9f6e738af6f5238f57a29e96103cf61e3f8cd (patch)
treed6386cc8e082c60423ecd3a16b2e49969ced25fc /setup.c
parentaa14e980fff55e090dd42174ab4f37fe4b3dfa1e (diff)
downloadgit-56b9f6e738af6f5238f57a29e96103cf61e3f8cd.tar.gz
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>
Diffstat (limited to 'setup.c')
-rw-r--r--setup.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/setup.c b/setup.c
index 937dad503c..72a4978ba5 100644
--- a/setup.c
+++ b/setup.c
@@ -434,16 +434,16 @@ static const char *setup_explicit_git_dir(const char *gitdirenv,
if (is_absolute_path(git_work_tree_cfg))
set_git_work_tree(git_work_tree_cfg);
else {
- char core_worktree[PATH_MAX];
+ char *core_worktree;
if (chdir(gitdirenv))
die_errno("Could not chdir to '%s'", gitdirenv);
if (chdir(git_work_tree_cfg))
die_errno("Could not chdir to '%s'", git_work_tree_cfg);
- if (!getcwd(core_worktree, PATH_MAX))
- die_errno("Could not get directory '%s'", git_work_tree_cfg);
+ core_worktree = xgetcwd();
if (chdir(cwd->buf))
die_errno("Could not come back to cwd");
set_git_work_tree(core_worktree);
+ free(core_worktree);
}
}
else if (!git_env_bool(GIT_IMPLICIT_WORK_TREE_ENVIRONMENT, 1)) {