# test that chezmoi apply uses .chezmoiroot
chezmoi apply
cmp $HOME/.file golden/.file

# test that chezmoi add uses .chezmoiroot
symlink $HOME/.symlink -> .file
chezmoi add $HOME${/}.symlink
cmp $CHEZMOISOURCEDIR/home/symlink_dot_symlink golden/symlink_dot_symlink

[!exec:git] skip 'git not found in $PATH'
[windows] skip 'go-git does not support file:// URLs on windows'

chhome home2/user
mkgitconfig

# create a git repo in home2/user/repo
exec git -C $HOME/repo init
exec git -C $HOME/repo add .
exec git -C $HOME/repo commit -m 'Initial commit'

# test that chezmoi init uses .chezmoiroot
chezmoi init --apply file://$HOME/repo
exists $CHEZMOICONFIGDIR/chezmoi.toml
cmp $HOME/.file golden/.file

-- golden/.file --
# contents of .file
-- golden/symlink_dot_symlink --
.file
-- home/user/.local/share/chezmoi/.chezmoiroot --
home
-- home/user/.local/share/chezmoi/home/dot_file --
# contents of .file
-- home2/user/repo/.chezmoiroot --
home
-- home2/user/repo/home/.chezmoi.toml.tmpl --
-- home2/user/repo/home/dot_file --
# contents of .file
