{"thread":{"id":"54767","subject":"'git worktree repair' can't repair when main and linked worktrees are moved","startedAt":"2020-12-04T23:15:43Z","lastAt":"2020-12-08T22:28:34Z","messageCount":5,"participants":["Philippe Blain","Eric Sunshine"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"411421","messageId":"63AC7AC2-5D32-479B-BF9E-0E5C31351A1B@gmail.com","threadId":"54767","inReplyTo":null,"subject":"'git worktree repair' can't repair when main and linked worktrees are moved","fromName":"Philippe Blain","fromEmail":"levraiphilippeblain@gmail.com","sentAt":"2020-12-04T23:14:37Z","receivedAt":"2020-12-04T23:15:43Z","isPatch":false,"sender":{"key":"levraiphilippeblain@gmail.com","avatar":"https://avatars.githubusercontent.com/u/44212482?v=4"},"body":"Hello,\n\nI've had to move all my Git clones to a new filesystem.\nSeveral of them use secondary worktrees, and all are \nat the same level ex:\n\n$ ls code\ngit git2 git3 other other2 other3 ...\n\nI had hoped to use the new 'git worktree repair' command\nbut it seems it does not work for this use case. \n\nI tried several things:\n\n( cd git && git repair )\n( cd git && git repair ../git2 )\n( cd git && git repair /old/path/to/old/filesystem/git2 )\n( cd git2 && git repair /old/path/to/old/filesystem/git2 )\n( cd git2 && git repair ../git )\n\nNone of them work. Note that /old/path/to/old/filesystem/\ndoes not exist anymore.\n\nIs this supposed to work ? Or it's not something that \n'git worktree repair' can currently cope with ?\n\nP.S. I know how to repair the worktrees manuallly, I just\nwanted to test if 'repair' could help me.\n\nCheers,\n\nPhilippe.\n"},{"id":"411425","messageId":"8F01BDC6-81AD-4052-B11E-FFAA6A4C641E@gmail.com","threadId":"54767","inReplyTo":"63AC7AC2-5D32-479B-BF9E-0E5C31351A1B@gmail.com","subject":"Re: 'git worktree repair' can't repair when main and linked worktrees are moved","fromName":"Philippe Blain","fromEmail":"levraiphilippeblain@gmail.com","sentAt":"2020-12-04T23:21:03Z","receivedAt":"2020-12-04T23:21:53Z","isPatch":false,"sender":{"key":"levraiphilippeblain@gmail.com","avatar":"https://avatars.githubusercontent.com/u/44212482?v=4"},"body":"\n> Le 4 déc. 2020 à 18:14, Philippe Blain <levraiphilippeblain@gmail.com> a écrit :\n> \n> I tried several things:\n> \n> ( cd git && git repair )\n\nOups, please read 'git worktree repair' here and below.\n\n> ( cd git && git repair ../git2 )\n> ( cd git && git repair /old/path/to/old/filesystem/git2 )\n> ( cd git2 && git repair /old/path/to/old/filesystem/git2 )\n> ( cd git2 && git repair ../git )\n\n"},{"id":"411498","messageId":"CAPig+cT=-nNcfrzjSmTXymhFkB22bPFE6QRKXqPtat2ipUdboQ@mail.gmail.com","threadId":"54767","inReplyTo":"63AC7AC2-5D32-479B-BF9E-0E5C31351A1B@gmail.com","subject":"Re: 'git worktree repair' can't repair when main and linked worktrees are moved","fromName":"Eric Sunshine","fromEmail":"sunshine@sunshineco.com","sentAt":"2020-12-05T09:22:06Z","receivedAt":"2020-12-05T09:25:59Z","isPatch":false,"sender":{"key":"sunshine@sunshineco.com","avatar":"https://avatars.githubusercontent.com/u/163641?v=4"},"body":"On Fri, Dec 4, 2020 at 6:14 PM Philippe Blain\n<levraiphilippeblain@gmail.com> wrote:\n> I've had to move all my Git clones to a new filesystem.\n> Several of them use secondary worktrees, and all are\n> at the same level ex:\n>\n> I had hoped to use the new 'git worktree repair' command\n> but it seems it does not work for this use case.\n>\n> Is this supposed to work ? Or it's not something that\n> 'git worktree repair' can currently cope with ?\n\nThis is a situation which `git worktree repair` can not yet handle.\nThe implementation of bare bones `git worktree repair` was\nsufficiently complex that I decided that additional cases like this\nand other bells and whistles should be built later atop the basic\nimplementation. At present, only the following cases are handled:\n\n* secondary worktree has moved so main worktree doesn't know where it\nis, but secondary worktree still knows where main worktree is, thus\n`git worktree repair` within the secondary can contact the main and\nfix up main's reference to the secondary\n\n* main worktree has moved so secondary worktrees don't know where it\nis, but main worktree still knows where secondary worktrees are, thus\n`git worktree repair` within main can contact each secondary and fix\nup their references back to main\n\nThere was a little discussion during review[1,2,3] about how the\nsituation might be handled in which both main and secondary worktrees\nhave been moved. Primarily, a new command-line option would be added\nallowing the user to tell `git worktree repair` where the main\nworktree is, in addition to also giving the paths to the secondary\nworktrees as arguments (the latter of which is already supported). Now\nthat I'm thinking about it, I realize also that if invoked in the main\nworktree, then `git worktree repair` can recognize that it is\noperating in the main worktree (and infer the value of the new\ncommand-line option for specifying location of the main worktree),\nthus the user would only have to supply paths to the secondary\nworktrees as arguments. My main concern with inferring too much\nautomatically is that the command could be used to hijack a worktree\nbelonging to another repository (but perhaps that's a case of \"don't\ndo it if it hurts\").\n\nOf course, we could also get more fancy and provide some way to\nspecify path transformations. For instance, `git worktree repair\n--map-path=/old/path:/new/path` might make it possible to repair links\nin both directions by applying the path transformation to the paths\ninvolved in the repair. However, this idea is barely germinated; it's\nfar less well thought out than the previous one.\n\n[1]: https://lore.kernel.org/git/CAPig+cT-w6LV490MGNyG_ihWkSzdgfnEBrjQCsafjndTRmMgFA@mail.gmail.com/\n[2]: https://lore.kernel.org/git/xmqqlfi0qaru.fsf@gitster.c.googlers.com/\n[3]: https://lore.kernel.org/git/CAPig+cT-ipENZQ39wpaGukRzx3d52OatKEXjWc3_mv56jMbDRg@mail.gmail.com/\n"},{"id":"411725","messageId":"CAPig+cSEHR+S+y66zm5HFQCybtino0Ne=Z7qwB7tsc50pi1kpg@mail.gmail.com","threadId":"54767","inReplyTo":"CAPig+cT=-nNcfrzjSmTXymhFkB22bPFE6QRKXqPtat2ipUdboQ@mail.gmail.com","subject":"Re: 'git worktree repair' can't repair when main and linked worktrees are moved","fromName":"Eric Sunshine","fromEmail":"sunshine@sunshineco.com","sentAt":"2020-12-08T17:42:23Z","receivedAt":"2020-12-08T17:43:39Z","isPatch":false,"sender":{"key":"sunshine@sunshineco.com","avatar":"https://avatars.githubusercontent.com/u/163641?v=4"},"body":"On Sat, Dec 5, 2020 at 4:22 AM Eric Sunshine <sunshine@sunshineco.com> wrote:\n> On Fri, Dec 4, 2020 at 6:14 PM Philippe Blain\n> <levraiphilippeblain@gmail.com> wrote:\n> > I've had to move all my Git clones to a new filesystem.\n> > Several of them use secondary worktrees [...]\n> > I had hoped to use the new 'git worktree repair' command\n> > but it seems it does not work for this use case.\n>\n> This is a situation which `git worktree repair` can not yet handle.\n\nA patch[1] addressing this shortcoming has been posted.\n\n[1]: https://lore.kernel.org/git/20201208173705.5770-1-sunshine@sunshineco.com/\n"},{"id":"411786","messageId":"CADtb9DwR4SQE7w9YmzpEgvvdt+wQYm5rQSC7nQ+mevzJOthj8A@mail.gmail.com","threadId":"54767","inReplyTo":"CAPig+cSEHR+S+y66zm5HFQCybtino0Ne=Z7qwB7tsc50pi1kpg@mail.gmail.com","subject":"Re: 'git worktree repair' can't repair when main and linked worktrees are moved","fromName":"Philippe Blain","fromEmail":"levraiphilippeblain@gmail.com","sentAt":"2020-12-08T22:27:27Z","receivedAt":"2020-12-08T22:28:34Z","isPatch":false,"sender":{"key":"levraiphilippeblain@gmail.com","avatar":"https://avatars.githubusercontent.com/u/44212482?v=4"},"body":"Hi Eric,\n\nLe mar. 8 déc. 2020, à 12 h 42, Eric Sunshine\n<sunshine@sunshineco.com> a écrit :\n>\n> On Sat, Dec 5, 2020 at 4:22 AM Eric Sunshine <sunshine@sunshineco.com> wrote:\n> > On Fri, Dec 4, 2020 at 6:14 PM Philippe Blain\n> > <levraiphilippeblain@gmail.com> wrote:\n> > > I've had to move all my Git clones to a new filesystem.\n> > > Several of them use secondary worktrees [...]\n> > > I had hoped to use the new 'git worktree repair' command\n> > > but it seems it does not work for this use case.\n> >\n> > This is a situation which `git worktree repair` can not yet handle.\n>\n> A patch[1] addressing this shortcoming has been posted.\n>\n> [1]: https://lore.kernel.org/git/20201208173705.5770-1-sunshine@sunshineco.com/\n\nGreat! I'll try to take a look.\n\nThanks,\nPhilippe.\n"}]}