git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH 2/2] setup: don't fail if commondir is deleted.

From
Eric Sunshine <sunshine@sunshineco.com>
Date
Feb 17, 2019, 07:14 UTC
Message-ID
<CAPig+cTS0MNvwx67ZVbYUvi9bA63KWnNnSmWdFjLuqc_SNAy8A@mail.gmail.com>
In-Reply-To
<dd42ab7054077c7d29ad62e7481c00ab5c1bf864.1550254374.git.msuchanek@suse.de>
On Fri, Feb 15, 2019 at 1:16 PM Michal Suchanek <msuchanek@suse.de> wrote:
Show 12 quoted lines
> 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@suse.de>
> ---
> 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).

Previous: Michal SuchanekNext: Michal Suchánek
Message 3 of 7 in “worktree: fix worktree add race.”
  1. 1/2 worktree: fix worktree add race.Michal Suchanek, Feb 15, 2019
  2. 2/2 setup: don't fail if commondir is deleted.Michal Suchanek, Feb 15, 2019
  3. Eric SunshineFeb 17, 2019
  4. Michal SuchánekFeb 18, 2019
  5. Junio C HamanoFeb 15, 2019
  6. Michal SuchánekFeb 16, 2019
  7. Eric SunshineFeb 17, 2019

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.