From: hi-angel@yandex.ru Date: Wed, 20 Feb 2019 14:34:34 GMT Subject: Re: git gc fails with "unable to resolve reference" for worktree Message-ID: <1550673274.30738.0@yandex.ru> In-Reply-To: I see, thanks! On Пн, Feb 18, 2019 at 6:18 PM, Duy Nguyen wrote: > On Mon, Feb 18, 2019 at 10:09 PM wrote: >> >> >> >> On Пн, Feb 18, 2019 at 6:02 PM, Duy Nguyen >> wrote: >> > On Mon, Feb 18, 2019 at 9:44 PM wrote: >> >> >> >> # Steps to reproduce (in terms of terminal commands) >> >> >> >> $ mkdir foo >> >> $ cd foo >> >> $ git init >> >> Initialized empty Git repository in /tmp/foo/.git/ >> >> $ echo hello > testfile >> >> $ git add testfile && git commit -m "my commit1" >> >> [master (root-commit) d5f0b47] my commit1 >> >> 1 file changed, 1 insertion(+) >> >> create mode 100644 testfile >> >> $ git checkout -b bar >> >> Switched to a new branch 'bar' >> >> $ git worktree add ../bar\ \(worktree\) master >> >> Preparing worktree (checking out 'master') >> >> HEAD is now at d5f0b47 my commit1 >> >> $ git gc >> >> error: cannot lock ref 'worktrees/bar (worktree)/HEAD': >> unable >> >> to >> >> resolve reference 'worktrees/bar (worktree)/HEAD': Invalid >> argument >> > >> > Thanks for reporting. This is not a valid reference and causes the >> > problem. The worktree's name has to sanitized. I'll fix it >> tomorrow. >> >> >> >> You mean, you want to prohibit such directory names as a worktree? >> But >> it's a proper directory naming, can perhaps git do the sanitizing >> transparently for end-user? > > No, not inhibiting. When you do "git add ../(abc)" then the internal > name could be simply "abc" or something like that instead of "(abc)" > which is invalid to reflog and other commands. The worktree's location > is still '(abc)'. There's also a work-in-progress option to let the > user control this worktree name directly. > -- > Duy