Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dolt clone allows cloning a repo with a journal, but only if that repo is in a child directory. #8791

Open
nicktobey opened this issue Jan 25, 2025 · 1 comment
Labels
bug Something isn't working version control

Comments

@nicktobey
Copy link
Contributor

Ordinarily, you can't use git clone to make a copy of a local repo. This is because git clone expects a remote (even if it's a "local" remote with the file:// protocol), and remotes and repos have a different structure: for instance, repos contain a journal and remotes don't.

Thus, the following fails:

mkdir test1 test2
cd test1
dolt init
cd ../test2
dolt clone file://../test1/.dolt/noms

This will result in the error

error: failed to get remote db
cause: cannot create NBS store for directory containing chunk journal: /Users/nick/test1/.dolt/noms

However, this safeguard fails if the repo being cloned is a child of the current working directory. In this case, Dolt on startup loads the repo's oldgen as a datas.database and caches it. When the clone command executes, it sees that the databse has already been loaded and skips the chuck journal check.

As a result, the clone operation completes... but only the oldgen is copied into the new repo. Any changes not in the oldgen (such as changes in the journal) don't get copied to the new repo.

mkdir test1 test2
cd test1
dolt init
dolt sql -q "create table test(pk int primary key);"
cd ..
dolt clone file://test1/.dolt/noms test2
cd test2
dolt ls

Output: No tables in working set

This is likely incorrect. The output of dolt clone probably shouldn't depend on the current working directory.

My PR to defer DB loading (#8783) should fix this issue, but it breaks a test in replication.bats, "local clone", that appears to be depending on this behavior. Before I modify the test, I want to verify that the correct behavior here is to forbid cloning from another repo in this way.

@nicktobey
Copy link
Contributor Author

I confirmed that the correct behavior should be to always reject clone commands that clone another repo. There's no reason why we can't support it in theory, but until we can do it correctly, we shouldn't risk doing it incorrectly.

#8783 will fix this.

@timsehn timsehn added bug Something isn't working version control labels Jan 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working version control
Projects
None yet
Development

No branches or pull requests

2 participants