←back to thread

128 points nvader | 9 comments | | HN request time: 0s | source | bottom
1. amluto ◴[] No.46191145[source]
I want a variant of this where I make a worktree that has no ability to push anywhere including its parent. Instead the parent worktree pulls from it automatically. That way I can run some sandboxed workflow that might arbitrarily corrupt the work tree, possibly overwriting everything in it and symlinked from it, without losing data.
replies(2): >>46191388 #>>46191787 #
2. Normal_gaussian ◴[] No.46191388[source]
The easy way to do this is to create a worktree and then just run it in some form of sandbox - e.g. a Docker container.

In the worktree there is no .git directory, just a .git file which has a single line: "gitdir: <path to gitdir>".

If your sandbox doesn't have access to the gitdir, you're golden.

replies(1): >>46191800 #
3. gcr ◴[] No.46191787[source]
Don’t you just want a clone in that case?
replies(1): >>46198439 #
4. gcr ◴[] No.46191800[source]
What if the sandbox needs access to the history? Imagine asking for help bisecting something, for example
replies(4): >>46192694 #>>46192764 #>>46198421 #>>46199117 #
5. ◴[] No.46192694{3}[source]
6. Normal_gaussian ◴[] No.46192764{3}[source]
Then you'll probably want a clone; which will cost in more space. Just remember to remove the remotes.

You could always use an overlayFS with the main (non-worktree) repo as the lowerdir (and then remove the remotes in the overlayFS), but that relies on you not trying to keep working on the git repo at the same time.

7. amluto ◴[] No.46198421{3}[source]
Or if I want the sandbox to be able to create commits, which is extremely useful.
8. amluto ◴[] No.46198439[source]
By itself, that doesn’t help if the thing in the sandbox does useful work for two hours and then does rm -rf /
9. adastra22 ◴[] No.46199117{3}[source]
Mount the parent read-only.