On Fri, Feb 15, 2019 at 1:16 PM Michal Suchanek <msuchanek@xxxxxxx> wrote: > When adding wotktrees git can die in get_common_dir_noenv while > examining existing worktrees because the commondir file does not exist. > Handle ENOENT so adding a worktree does not fail because of incompletely > set-up other worktree. > > Signed-off-by: Michal Suchanek <msuchanek@xxxxxxx> > --- > diff --git a/setup.c b/setup.c > @@ -274,22 +274,25 @@ int get_common_dir_noenv(struct strbuf *sb, const char *gitdir) > + if (strbuf_read_file(&data, path.buf, 0) <= 0) { > + if (errno != ENOENT) > + die_errno(_("failed to read %s"), path.buf); Documentation for strbuf_read_file() in strbuf.h does not state that 'errno' has any meaningful value when this function fails, however, the actual implementation in strbuf.c is careful to preserve 'errno' when something goes wrong. Therefore, it is safe to consult 'errno' here. Fine. It might be a good idea to fix the documentation of strbuf_read_file() to mention 'errno' explicitly, as a preparatory patch of this series (though not at all a requirement when re-rolling; just a suggestion to assist reviewers).