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

Re: [PATCH] worktree: allow to (re)move worktrees with uninitialized submodules

From
Eric Sunshine <sunshine@sunshineco.com>
Date
Dec 16, 2018, 13:18 UTC
Message-ID
<CAPig+cQLz+mx8pXMCsYW_0=1C8GzFvzBb=uatfwLK0Dpj944Jg@mail.gmail.com>
In-Reply-To
<20181216121239.10017-1-pclouds@gmail.com>
On Sun, Dec 16, 2018 at 7:12 AM Nguyễn Thái Ngọc Duy <pclouds@gmail.com> wrote:
Show 23 quoted lines
> Uninitialized submodules have nothing valueable for us to be worried
> about. They are just SHA-1. Let "worktree remove" and "worktree move"
> continue in this case so that people can still use multiple worktrees
> on repos with optional submodules that are never populated, like
> sha1collisiondetection in git.git when checked out by doc-diff script.
> [...]
> Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
> ---
> diff --git a/builtin/worktree.c b/builtin/worktree.c
> @@ -724,20 +725,32 @@ static int unlock_worktree(int ac, const char **av, const char *prefix)
>  static void validate_no_submodules(const struct worktree *wt)
>  {
> +       if (is_directory(worktree_git_path(wt, "modules")))
> +               die(_("working trees containing submodules cannot be moved or removed"));
> +
>         if (read_index_from(&istate, worktree_git_path(wt, "index"),
>                             get_worktree_git_dir(wt)) > 0) {
>                 [...]
> +                       found_submodules = 1;
> +                       break;
>         }
>         if (found_submodules)
>                 die(_("working trees containing submodules cannot be moved or removed"));

Not worth a re-roll, but an alternate way to structure this to avoid duplicating the die() message would be:

    if (is_directory(...))
        found_submodules = 1;
    else if (read_index_from(...)) {
        ...
        found_submodules = 1;
        break;
    }
    if (found_submodules)
        die(...);
Previous: Nguyễn Thái Ngọc DuyNext: Nguyễn Thái Ngọc Duy
Message 2 of 6 in “worktree: allow to (re)move worktrees with uninitialized submodules”
  1. worktree: allow to (re)move worktrees with uninitialized submodulesNguyễn Thái Ngọc Duy, Dec 16, 2018
  2. Eric SunshineDec 16, 2018
  3. worktree: allow to (re)move worktrees with uninitialized submodulesNguyễn Thái Ngọc Duy, Dec 16, 2018
  4. Junio C HamanoJan 4, 2019
  5. Eric SunshineJan 6, 2019
  6. worktree: allow to (re)move worktrees with uninitialized submodulesNguyễn Thái Ngọc Duy, Jan 5, 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.