From: Johannes Sixt Date: Mon, 14 Jul 2008 07:13:13 GMT Subject: Re: [PATCH] Allow add_path() to add non-existent directories to the path Message-ID: <487AFC89.8020009@viscovery.net> In-Reply-To: <1215981083-10815-6-git-send-email-johannes.sixt@telecom.at> Johannes Sixt schrieb: > +static const char *get_pwd_cwd(void) > +{ > + static char cwd[PATH_MAX + 1]; > + char *pwd; > + struct stat cwd_stat, pwd_stat; > + if (getcwd(cwd, PATH_MAX) == NULL) > + return NULL; > + pwd = getenv("PWD"); > + if (pwd && strcmp(pwd, cwd)) { > + stat(cwd, &cwd_stat); > + if (!stat(pwd, &pwd_stat) && > + pwd_stat.st_dev == cwd_stat.st_dev && > + pwd_stat.st_ino == cwd_stat.st_ino) { > + strlcpy(cwd, pwd, PATH_MAX); git-bash users on Windows, please test this patch. The problem is that with our custom stat implementation st_dev and st_ino are not reliable. It works in my setup because $PWD is not set and this branch is never entered, but with bash it makes a difference. -- Hannes