git@vger.kernel.org list mirror (unofficial, one of many)
 help / color / Atom feed
* [PATCH] worktree remove: clarify error message on dirty worktree
@ 2019-08-13 18:02 SZEDER Gábor
  2019-08-13 18:52 ` Eric Sunshine
  0 siblings, 1 reply; 3+ messages in thread
From: SZEDER Gábor @ 2019-08-13 18:02 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git, SZEDER Gábor

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:

  $ git worktree add test-worktree
  Preparing worktree (new branch 'test-worktree')
  HEAD is now at aa53e60 Initial
  $ >test-worktree/untracked-file
  $ git worktree remove test-worktree/
  fatal: 'test-worktree/' is dirty, use --force to delete it
  $ git -C test-worktree/ diff
  $ git -C test-worktree/ diff --cached
  $ # Huh?  Where are those dirty 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>
---

I spent more time searching for those dirty files that I would like to
admit...

 builtin/worktree.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/builtin/worktree.c b/builtin/worktree.c
index a5bb02b207..7f094f8170 100644
--- a/builtin/worktree.c
+++ b/builtin/worktree.c
@@ -880,7 +880,7 @@ static void check_clean_worktree(struct worktree *wt,
 			  original_path);
 	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);
 	close(cp.out);
 	ret = finish_command(&cp);
-- 
2.23.0.rc2.350.gf4fdc32db7


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] worktree remove: clarify error message on dirty worktree
  2019-08-13 18:02 [PATCH] worktree remove: clarify error message on dirty worktree SZEDER Gábor
@ 2019-08-13 18:52 ` Eric Sunshine
  2019-08-13 20:10   ` Junio C Hamano
  0 siblings, 1 reply; 3+ messages in thread
From: Eric Sunshine @ 2019-08-13 18:52 UTC (permalink / raw)
  To: SZEDER Gábor; +Cc: Junio C Hamano, Git List

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>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] worktree remove: clarify error message on dirty worktree
  2019-08-13 18:52 ` Eric Sunshine
@ 2019-08-13 20:10   ` Junio C Hamano
  0 siblings, 0 replies; 3+ messages in thread
From: Junio C Hamano @ 2019-08-13 20:10 UTC (permalink / raw)
  To: Eric Sunshine; +Cc: SZEDER Gábor, Git List

Eric Sunshine <sunshine@sunshineco.com> writes:

> 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.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, back to index

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-08-13 18:02 [PATCH] worktree remove: clarify error message on dirty worktree SZEDER Gábor
2019-08-13 18:52 ` Eric Sunshine
2019-08-13 20:10   ` Junio C Hamano

git@vger.kernel.org list mirror (unofficial, one of many)

Archives are clonable:
	git clone --mirror https://public-inbox.org/git
	git clone --mirror http://ou63pmih66umazou.onion/git
	git clone --mirror http://czquwvybam4bgbro.onion/git
	git clone --mirror http://hjrcffqmbrq6wope.onion/git

Newsgroups are available over NNTP:
	nntp://news.public-inbox.org/inbox.comp.version-control.git
	nntp://ou63pmih66umazou.onion/inbox.comp.version-control.git
	nntp://czquwvybam4bgbro.onion/inbox.comp.version-control.git
	nntp://hjrcffqmbrq6wope.onion/inbox.comp.version-control.git
	nntp://news.gmane.org/gmane.comp.version-control.git

 note: .onion URLs require Tor: https://www.torproject.org/

AGPL code for this site: git clone https://public-inbox.org/ public-inbox