{"thread":{"id":"46180","subject":"Minor missing features in worktree compare to new-workdir","startedAt":"2017-06-14T12:31:46Z","lastAt":"2017-06-15T00:40:48Z","messageCount":3,"participants":["Yichao Yu","Paul Smith"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"322244","messageId":"CAMvDr+Qxjdgnm0aW3WenDpFs2NBhyrNXZA2M7sjsCjJs+RzM3Q@mail.gmail.com","threadId":"46180","inReplyTo":null,"subject":"Minor missing features in worktree compare to new-workdir","fromName":"Yichao Yu","fromEmail":"yyc1992@gmail.com","sentAt":"2017-06-14T12:31:11Z","receivedAt":"2017-06-14T12:31:46Z","isPatch":false,"sender":{"key":"yyc1992@gmail.com","avatar":"https://avatars.githubusercontent.com/u/712232?v=4"},"body":"Hi,\n\nI've just learnt recently that the new-workdir script has finally got\na builtin version, i.e. worktree. I've given it a short try and for\nthe most part it works as good or better than new-workdir.\n\nHowever, there's few minor features that I use in new-workdir that\ndoesn't seem to be supported by worktree.\n\n1. the branch name in new-workdir has the same behavior as checkout,\ni.e. when it matches a remote branch name a local branch tracking that\nremote branch will be created and checked out. worktree gives an error\nin this case. This is very useful for fetching someone else' feature\nbranch into a different work dir for testing.\n\n2. worktree doesn't seem to support multiple worktree on the same\nbranch. I do this for testing different options and also to checkout a\nbase branch on a worktree before deleting the dev branch checked out\nin the workdir. This will indeed cause one of the checkout to be dirty\nwhen the branch is updated somewhere else but it doesn't seem to cause\nmuch issue otherwise. (this mainly happen when I forgot to remove a\nworkdir so the solution is usually just remove that out-of-date\ncheckout).\n\n3. There's an error when the branch name is omitted but the default\nbrach name already exist. Can it default to checking out the branch if\nit already exist instead? (The behavior of creating new branch is of\ncourse also useful when the branch doesn't exist)\n\n4. worktree doesn't seem to be runable outside a git repo. new-workdir\ncan. This is pretty minor and mainly useful when checking out a branch\nthat matches the nested structure in the branch name (i.e. I'd like to\ncheckout branch A/B/C into A/B/C/ while master branch is in master/. I\nusually first cd to A/B before running git new-workdir ../../master C)\nThis only saves a little typing in certain cases so it's a very minor\nissue.....\n\nAll tests are done 2.13.1 from ArchLinux official repo.\n\nThanks.\n\nYichao Yu\n"},{"id":"322245","messageId":"1497444089.13409.108.camel@mad-scientist.net","threadId":"46180","inReplyTo":"CAMvDr+Qxjdgnm0aW3WenDpFs2NBhyrNXZA2M7sjsCjJs+RzM3Q@mail.gmail.com","subject":"Re: Minor missing features in worktree compare to new-workdir","fromName":"Paul Smith","fromEmail":"paul@mad-scientist.net","sentAt":"2017-06-14T12:41:29Z","receivedAt":"2017-06-14T12:41:50Z","isPatch":false,"sender":{"key":"paul@mad-scientist.net","avatar":"https://avatars.githubusercontent.com/u/109636?v=4"},"body":"On Wed, 2017-06-14 at 08:31 -0400, Yichao Yu wrote:\n> 1. the branch name in new-workdir has the same behavior as checkout,\n> i.e. when it matches a remote branch name a local branch tracking that\n> remote branch will be created and checked out. worktree gives an error\n> in this case. This is very useful for fetching someone else' feature\n> branch into a different work dir for testing.\n\nI agree; this behavior of worktree is frustrating.  It's a very common\nuse-case to aid in code reviews etc. and it's not easy to explain to\npeople what they need to do to make this work.\n\n> 2. worktree doesn't seem to support multiple worktree on the same\n> branch.\n\nI think this is a very good thing about worktrees as opposed to\nworkdirs.\n\nIn a situation where I may want multiple worktrees pointing to the same\ncommit I just check out the SHA rather than the branch: you can have as\nmany branches set to the same SHA (detached HEAD) as you like, and\nthere's no concern about dirty workspaces.  This latter can actually be\na really big problem (suppose the workdir contained some modified files\nthen you update another workdir with the same branch... it's not easy to\nfigure out what happened here!)\n"},{"id":"322290","messageId":"CAMvDr+TsdO5V694R5gpaWwyjkSHXW=QYG8n74ULVYZ5pbuY-zA@mail.gmail.com","threadId":"46180","inReplyTo":"1497444089.13409.108.camel@mad-scientist.net","subject":"Re: Minor missing features in worktree compare to new-workdir","fromName":"Yichao Yu","fromEmail":"yyc1992@gmail.com","sentAt":"2017-06-15T00:40:21Z","receivedAt":"2017-06-15T00:40:48Z","isPatch":false,"sender":{"key":"yyc1992@gmail.com","avatar":"https://avatars.githubusercontent.com/u/712232?v=4"},"body":">> 2. worktree doesn't seem to support multiple worktree on the same\n>> branch.\n>\n> I think this is a very good thing about worktrees as opposed to\n> workdirs.\n>\n> In a situation where I may want multiple worktrees pointing to the same\n> commit I just check out the SHA rather than the branch: you can have as\n\nHmm, this could be workable. Though in that case it'll be nice to have\na easier way to checkout the SHA corresponding to a branch.\n\n> many branches set to the same SHA (detached HEAD) as you like, and\n> there's no concern about dirty workspaces.  This latter can actually be\n> a really big problem (suppose the workdir contained some modified files\n> then you update another workdir with the same branch... it's not easy to\n> figure out what happened here!)\n\nUnless it can cause internal corruption I'd still prefer to allow this\nwith warning/option. I have indeed cause dirty state myself though 95%\nof the time it's because I forgot to remove the checkout that I'm done\nusing and the rest 5% being temperary state that I intentionally cause\n(e.g. update in one checkout before hard resetting the second one).\n"}]}