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

Re: [PATCH] worktree remove: clarify error message on dirty worktree

From
Junio C Hamano <gitster@pobox.com>
Date
Aug 13, 2019, 20:10 UTC
Message-ID
<xmqqv9v07rn1.fsf@gitster-ct.c.googlers.com>
In-Reply-To
<CAPig+cSDxBFhnJSmH+WzNZBjY4O0OczazZ7EOqn1P=zgL+ec4g@mail.gmail.com>
Eric Sunshine <sunshine@sunshineco.com> writes:
Show 31 quoted lines
> On Tue, Aug 13, 2019 at 2:04 PM SZEDER Gábor <szeder.dev@gmail.com> wrote:
>> To avoid data loss, 'git worktree remove' refuses to delete a worktree
>> if it's dirty or contains untracked files.  However, the error message
>> only mentions that the worktree "is dirty", even if the worktree in
>> question is in fact clean, but contains untracked files:
>> [...]
>> Clarify this error message to say that the worktree "contains modified
>> or untracked files".
>>
>> Signed-off-by: SZEDER Gábor <szeder.dev@gmail.com>
>> ---
>> diff --git a/builtin/worktree.c b/builtin/worktree.c
>> @@ -880,7 +880,7 @@ static void check_clean_worktree(struct worktree *wt,
>>         ret = xread(cp.out, buf, sizeof(buf));
>>         if (ret)
>> -               die(_("'%s' is dirty, use --force to delete it"),
>> +               die(_("'%s' contains modified or untracked files, use --force to delete it"),
>>                     original_path);
>
> Makes sense. This is a different type of "dirtiness" than, say, "git
> rebase --interactive" which cares about unstaged changes but generally
> doesn't mind untracked files. So, it deserves an error message which
> mentions untracked files explicitly.
>
> We could actually parse the output of "git status --porcelain" (which
> is invoked just above this spot) and provide a more specific error
> message ("...contains modified files" or "...contains untracked
> files") but that's probably not worth the effort.
>
> Anyhow, for what it's worth:
> Reviewed-by: Eric Sunshine <sunshine@sunshineco.com>
Thanks, both.
Previous: Eric Sunshine
Message 3 of 3 in “worktree remove: clarify error message on dirty worktree”
  1. worktree remove: clarify error message on dirty worktreeSZEDER Gábor, Aug 13, 2019
  2. Eric SunshineAug 13, 2019
  3. Junio C HamanoAug 13, 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.