aboutsummaryrefslogtreecommitdiff
path: root/trace.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 /trace.c
parentaa14e980fff55e090dd42174ab4f37fe4b3dfa1e (diff)
downloadgit-56b9f6e738af6f5238f57a29e96103cf61e3f8cd.tar.gz
git-56b9f6e738af6f5238f57a29e96103cf61e3f8cd.tar.xz
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 'trace.c')
-rw-r--r--trace.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/trace.c b/trace.c
index 08180a90b..3523667f6 100644
--- a/trace.c
+++ b/trace.c
@@ -158,13 +158,12 @@ void trace_repo_setup(const char *prefix)
{
static const char *key = "GIT_TRACE_SETUP";
const char *git_work_tree;
- char cwd[PATH_MAX];
+ char *cwd;
if (!trace_want(key))
return;
- if (!getcwd(cwd, PATH_MAX))
- die("Unable to get current working directory");
+ cwd = xgetcwd();
if (!(git_work_tree = get_git_work_tree()))
git_work_tree = "(null)";
@@ -176,6 +175,8 @@ void trace_repo_setup(const char *prefix)
trace_printf_key(key, "setup: worktree: %s\n", quote_crnl(git_work_tree));
trace_printf_key(key, "setup: cwd: %s\n", quote_crnl(cwd));
trace_printf_key(key, "setup: prefix: %s\n", quote_crnl(prefix));
+
+ free(cwd);
}
int trace_want(const char *key)