summaryrefslogtreecommitdiff
path: root/dir.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2014-09-02 20:27:45 (GMT)
committerJunio C Hamano <gitster@pobox.com>2014-09-02 20:28:44 (GMT)
commitf655651e09b9fa7bf8ff13f1b4a5b16c7956e4cf (patch)
tree4027a4324f45863de3811cf89df768d584f08e3e /dir.c
parent51eeaea2108a4105542fe03935b411dfdbf5fe2b (diff)
parent9610decf4dc6b9352b81c67e3b03e5bb47fc8427 (diff)
downloadgit-f655651e09b9fa7bf8ff13f1b4a5b16c7956e4cf.zip
git-f655651e09b9fa7bf8ff13f1b4a5b16c7956e4cf.tar.gz
git-f655651e09b9fa7bf8ff13f1b4a5b16c7956e4cf.tar.bz2
Merge branch 'rs/strbuf-getcwd'
Reduce the use of fixed sized buffer passed to getcwd() calls by introducing xgetcwd() helper. * rs/strbuf-getcwd: use strbuf_add_absolute_path() to add absolute paths abspath: convert absolute_path() to strbuf use xgetcwd() to set $GIT_DIR use xgetcwd() to get the current directory or die wrapper: add xgetcwd() abspath: convert real_path_internal() to strbuf abspath: use strbuf_getcwd() to remember original working directory setup: convert setup_git_directory_gently_1 et al. to strbuf unix-sockets: use strbuf_getcwd() strbuf: add strbuf_getcwd()
Diffstat (limited to 'dir.c')
-rw-r--r--dir.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/dir.c b/dir.c
index fcb6872..bd274a7 100644
--- a/dir.c
+++ b/dir.c
@@ -1507,12 +1507,16 @@ int dir_inside_of(const char *subdir, const char *dir)
int is_inside_dir(const char *dir)
{
- char cwd[PATH_MAX];
+ char *cwd;
+ int rc;
+
if (!dir)
return 0;
- if (!getcwd(cwd, sizeof(cwd)))
- die_errno("can't find the current directory");
- return dir_inside_of(cwd, dir) >= 0;
+
+ cwd = xgetcwd();
+ rc = (dir_inside_of(cwd, dir) >= 0);
+ free(cwd);
+ return rc;
}
int is_empty_dir(const char *path)