All of lore.kernel.org
 help / color / mirror / Atom feed
* git branch -D doesn't work with deleted worktree
@ 2017-01-05 10:06 Roland Illig
  2017-01-05 14:02 ` Stefan Beller
  0 siblings, 1 reply; 7+ messages in thread
From: Roland Illig @ 2017-01-05 10:06 UTC (permalink / raw)
  To: git

Git 2.11.0 gives a wrong error message after the following commands:
 
$ git init
$ echo hello >file
$ git add file
$ git commit -m "message"
$ git worktree add ../worktree
$ rm -rf ../worktree
$ git br -D worktree
error: Cannot delete branch 'worktree' checked out at '../worktree'

Since ../worktree has been deleted, there cannot be anything checked out at that location.

In my opinion, deleting the branch should just work. Especially since I used the -D option and the "git worktree" documentation says "When you are done with a linked working tree you can simply delete it."

Regards,
Roland


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

* Re: git branch -D doesn't work with deleted worktree
  2017-01-05 10:06 git branch -D doesn't work with deleted worktree Roland Illig
@ 2017-01-05 14:02 ` Stefan Beller
  2017-01-06 10:05   ` Duy Nguyen
  0 siblings, 1 reply; 7+ messages in thread
From: Stefan Beller @ 2017-01-05 14:02 UTC (permalink / raw)
  To: Roland Illig, Duy Nguyen; +Cc: git

On Thu, Jan 5, 2017 at 2:06 AM, Roland Illig <rillig@novomind.com> wrote:
> Git 2.11.0 gives a wrong error message after the following commands:
>
> $ git init
> $ echo hello >file
> $ git add file
> $ git commit -m "message"
> $ git worktree add ../worktree
> $ rm -rf ../worktree
> $ git br -D worktree
> error: Cannot delete branch 'worktree' checked out at '../worktree'
>
> Since ../worktree has been deleted, there cannot be anything checked out at that location.
>
> In my opinion, deleting the branch should just work. Especially since I used the -D option and the "git worktree" documentation says "When you are done with a linked working tree you can simply delete it."
>
> Regards,
> Roland
>

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

* Re: git branch -D doesn't work with deleted worktree
  2017-01-05 14:02 ` Stefan Beller
@ 2017-01-06 10:05   ` Duy Nguyen
  2017-01-09  3:44     ` Jacob Keller
  0 siblings, 1 reply; 7+ messages in thread
From: Duy Nguyen @ 2017-01-06 10:05 UTC (permalink / raw)
  To: Stefan Beller; +Cc: Roland Illig, git

On Thu, Jan 5, 2017 at 9:02 PM, Stefan Beller <sbeller@google.com> wrote:
> On Thu, Jan 5, 2017 at 2:06 AM, Roland Illig <rillig@novomind.com> wrote:
>> Git 2.11.0 gives a wrong error message after the following commands:
>>
>> $ git init
>> $ echo hello >file
>> $ git add file
>> $ git commit -m "message"
>> $ git worktree add ../worktree
>> $ rm -rf ../worktree
>> $ git br -D worktree
>> error: Cannot delete branch 'worktree' checked out at '../worktree'
>>
>> Since ../worktree has been deleted, there cannot be anything checked out at that location.
>>
>> In my opinion, deleting the branch should just work. Especially since I used the -D option and the "git worktree" documentation says "When you are done with a linked working tree you can simply delete it."

Since -D means "I know what I'm doing, get out of my way", maybe we
should continue if any worktree has the branch checked out by
detaching it?

(Yes I'm carefully tip toeing around the deleted worktree issue since
"git worktree remove" is coming. After that point, running "worktree
prune" before "branch -D" does not sound so bad)
-- 
Duy

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

* Re: git branch -D doesn't work with deleted worktree
  2017-01-06 10:05   ` Duy Nguyen
@ 2017-01-09  3:44     ` Jacob Keller
  2017-01-09 10:07       ` Duy Nguyen
  0 siblings, 1 reply; 7+ messages in thread
From: Jacob Keller @ 2017-01-09  3:44 UTC (permalink / raw)
  To: Duy Nguyen; +Cc: Stefan Beller, Roland Illig, git

On Fri, Jan 6, 2017 at 2:05 AM, Duy Nguyen <pclouds@gmail.com> wrote:
> On Thu, Jan 5, 2017 at 9:02 PM, Stefan Beller <sbeller@google.com> wrote:
>> On Thu, Jan 5, 2017 at 2:06 AM, Roland Illig <rillig@novomind.com> wrote:
>>> Git 2.11.0 gives a wrong error message after the following commands:
>>>
>>> $ git init
>>> $ echo hello >file
>>> $ git add file
>>> $ git commit -m "message"
>>> $ git worktree add ../worktree
>>> $ rm -rf ../worktree
>>> $ git br -D worktree
>>> error: Cannot delete branch 'worktree' checked out at '../worktree'
>>>
>>> Since ../worktree has been deleted, there cannot be anything checked out at that location.
>>>
>>> In my opinion, deleting the branch should just work. Especially since I used the -D option and the "git worktree" documentation says "When you are done with a linked working tree you can simply delete it."
>
> Since -D means "I know what I'm doing, get out of my way", maybe we
> should continue if any worktree has the branch checked out by
> detaching it?
>
> (Yes I'm carefully tip toeing around the deleted worktree issue since
> "git worktree remove" is coming. After that point, running "worktree
> prune" before "branch -D" does not sound so bad)
> --
> Duy

Why not just update the documentation to be "when you are done with a
work tree you can delete it and then run git worktree prune"?

Thanks,
Jake

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

* Re: git branch -D doesn't work with deleted worktree
  2017-01-09  3:44     ` Jacob Keller
@ 2017-01-09 10:07       ` Duy Nguyen
  2017-01-10  5:08         ` Jacob Keller
  0 siblings, 1 reply; 7+ messages in thread
From: Duy Nguyen @ 2017-01-09 10:07 UTC (permalink / raw)
  To: Jacob Keller; +Cc: Stefan Beller, Roland Illig, git

On Mon, Jan 9, 2017 at 10:44 AM, Jacob Keller <jacob.keller@gmail.com> wrote:
> Why not just update the documentation to be "when you are done with a
> work tree you can delete it and then run git worktree prune"?

The document does say that (a bit verbose though):

When you are done with a linked working tree you can simply delete it.
The working tree's administrative files in the repository (see
"DETAILS" below) will eventually be removed automatically (see
`gc.worktreePruneExpire` in linkgit:git-config[1]), or you can run
`git worktree prune` in the main or any linked working tree to
clean up any stale administrative files.
-- 
Duy

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

* Re: git branch -D doesn't work with deleted worktree
  2017-01-09 10:07       ` Duy Nguyen
@ 2017-01-10  5:08         ` Jacob Keller
  2017-01-10 10:47           ` Duy Nguyen
  0 siblings, 1 reply; 7+ messages in thread
From: Jacob Keller @ 2017-01-10  5:08 UTC (permalink / raw)
  To: Duy Nguyen; +Cc: Stefan Beller, Roland Illig, git

On Mon, Jan 9, 2017 at 2:07 AM, Duy Nguyen <pclouds@gmail.com> wrote:
> On Mon, Jan 9, 2017 at 10:44 AM, Jacob Keller <jacob.keller@gmail.com> wrote:
>> Why not just update the documentation to be "when you are done with a
>> work tree you can delete it and then run git worktree prune"?
>
> The document does say that (a bit verbose though):
>
> When you are done with a linked working tree you can simply delete it.
> The working tree's administrative files in the repository (see
> "DETAILS" below) will eventually be removed automatically (see
> `gc.worktreePruneExpire` in linkgit:git-config[1]), or you can run
> `git worktree prune` in the main or any linked working tree to
> clean up any stale administrative files.
> --
> Duy

Right, so maybe we can make it more clear since it's not quite as
simple as "deleting the work tree" because of stuff like stale
branches.. or would it be worth re-scanning worktrees when we do
branch deletion? (obviously ignoring the ones that are marked as on
removable media)

Thanks,
Jake

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

* Re: git branch -D doesn't work with deleted worktree
  2017-01-10  5:08         ` Jacob Keller
@ 2017-01-10 10:47           ` Duy Nguyen
  0 siblings, 0 replies; 7+ messages in thread
From: Duy Nguyen @ 2017-01-10 10:47 UTC (permalink / raw)
  To: Jacob Keller; +Cc: Stefan Beller, Roland Illig, git

On Tue, Jan 10, 2017 at 12:08 PM, Jacob Keller <jacob.keller@gmail.com> wrote:
> On Mon, Jan 9, 2017 at 2:07 AM, Duy Nguyen <pclouds@gmail.com> wrote:
>> On Mon, Jan 9, 2017 at 10:44 AM, Jacob Keller <jacob.keller@gmail.com> wrote:
>>> Why not just update the documentation to be "when you are done with a
>>> work tree you can delete it and then run git worktree prune"?
>>
>> The document does say that (a bit verbose though):
>>
>> When you are done with a linked working tree you can simply delete it.
>> The working tree's administrative files in the repository (see
>> "DETAILS" below) will eventually be removed automatically (see
>> `gc.worktreePruneExpire` in linkgit:git-config[1]), or you can run
>> `git worktree prune` in the main or any linked working tree to
>> clean up any stale administrative files.
>> --
>> Duy
>
> Right, so maybe we can make it more clear since it's not quite as
> simple as "deleting the work tree" because of stuff like stale
> branches..

Patches are welcome. I wrote that paragraph and you could clearly see
its "quality" (from user perspective).

> or would it be worth re-scanning worktrees when we do
> branch deletion? (obviously ignoring the ones that are marked as on
> removable media)

Probably. We run "git worktree prune" as part of "git gc" and that
command is automatically called in a couple places. Adding another
"git gc" here probably does not hurt. However it could trigger a full
repack and make "git branch" hang for a few seconds...

And no I don't want to single out "git worktree prune" to be called in
git-branch. We should either go through git-gc or none. We could check
if a worktree is deleted and suggest the user to run "git gc" though,
but it's getting too complicated when "git worktree remove" will soon
be the recommended way of deleting a worktree. So.. I don't know..
-- 
Duy

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

end of thread, other threads:[~2017-01-10 10:48 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-01-05 10:06 git branch -D doesn't work with deleted worktree Roland Illig
2017-01-05 14:02 ` Stefan Beller
2017-01-06 10:05   ` Duy Nguyen
2017-01-09  3:44     ` Jacob Keller
2017-01-09 10:07       ` Duy Nguyen
2017-01-10  5:08         ` Jacob Keller
2017-01-10 10:47           ` Duy Nguyen

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.