summaryrefslogtreecommitdiff
path: root/builtin/rev-parse.c
diff options
context:
space:
mode:
authorRené Scharfe <l.s.r@web.de>2014-07-28 18:30:39 (GMT)
committerJunio C Hamano <gitster@pobox.com>2014-08-26 18:06:06 (GMT)
commit56b9f6e738af6f5238f57a29e96103cf61e3f8cd (patch)
treed6386cc8e082c60423ecd3a16b2e49969ced25fc /builtin/rev-parse.c
parentaa14e980fff55e090dd42174ab4f37fe4b3dfa1e (diff)
downloadgit-56b9f6e738af6f5238f57a29e96103cf61e3f8cd.zip
git-56b9f6e738af6f5238f57a29e96103cf61e3f8cd.tar.gz
git-56b9f6e738af6f5238f57a29e96103cf61e3f8cd.tar.bz2
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 'builtin/rev-parse.c')
-rw-r--r--builtin/rev-parse.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/builtin/rev-parse.c b/builtin/rev-parse.c
index 1a6122d..a88123a 100644
--- a/builtin/rev-parse.c
+++ b/builtin/rev-parse.c
@@ -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")) {