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()
This commit is contained in:
12
dir.c
12
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)
|
||||
|
Reference in New Issue
Block a user