From: Derrick Stolee Date: Tue, 24 May 2022 17:41:12 GMT Subject: Re: [PATCH v3] setup: don't die if realpath(3) fails on getcwd(3) Message-ID: In-Reply-To: <68c66aef7ca4dba53faec9e6d2f3b70fe58ac33e.1653403877.git.kevin@kevinlocke.name> On 5/24/2022 10:51 AM, Kevin Locke wrote:> - /* Normalize the directory */ > - strbuf_realpath(&tmp, tmp_original_cwd, 1); > - free((char*)tmp_original_cwd); > - tmp_original_cwd = NULL; > - startup_info->original_cwd = strbuf_detach(&tmp, NULL); > + /* Try to normalize the directory. */ > + if (strbuf_realpath(&tmp, tmp_original_cwd, 0)) { > + free((char*)tmp_original_cwd); > + tmp_original_cwd = NULL; > + startup_info->original_cwd = strbuf_detach(&tmp, NULL); > + } else { > + trace2_data_string("setup", the_repository, > + "realpath-path", tmp_original_cwd); > + trace2_data_string("setup", the_repository, > + "realpath-failure", strerror(errno)); > + tmp_original_cwd = NULL; I didn't catch this in v2, but should this line instead be startup_info->original_cwd = NULL; ? Especially based on this comment: > Changes since v1: > * Set startup_info->original_cwd = NULL when strbuf_realpath() fails, > rather than setting it to the un-normalized path. Thanks, -Stolee