thblt / write-yourself-a-git

Learn Git by reimplementing it from scratch

Home Page:https://wyag.thb.lt

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

wyag init should use gitdir instead of worktree

celloward opened this issue · comments

Right now as the tutorial is written, repo_create creates a new worktree if one doesn't already exist and will throw an exception if the worktree has any files in it. Whereas git init will simply add a .git directory to . if one doesn't already exist and fill it out if it is empty.

In order for wyag init to work like git init it should be checking the existence of the GitRepository.gitdir instead of the GitRepository.worktree.

Indeed, thanks for pointing that out, I'll try and fix this soon. Don't hesitate to send a PR if you can !