[!exec:git] stop

# test that chezmoi init creates a git repo
chezmoi init
exists ${CHEZMOISOURCEDIR}${/}.git

# create a commit
chezmoi add $HOME${/}.bashrc
cmp ${CHEZMOISOURCEDIR}${/}dot_bashrc $HOME${/}.bashrc
chezmoi git add dot_bashrc
chezmoi git commit -- --message 'Add dot_bashrc'

# test that chezmoi init fetches git repo but does not apply
chhome home2${/}user
chezmoi init file://$WORK/home/user/.local/share/chezmoi
exists ${CHEZMOISOURCEDIR}${/}.git
! exists $HOME${/}.bashrc

# test that chezmoi init --apply fetches a git repo and runs chezmoi apply
chhome home3${/}user
chezmoi init --apply file://$WORK/home/user/.local/share/chezmoi
exists ${CHEZMOISOURCEDIR}${/}.git
grep '# contents of .bashrc' $HOME${/}.bashrc

# test that chezmoi init --clone=false does not clone the repo but does create the config file
chhome home4${/}user
chezmoi init --clone=false --source=${HOME}/dotfiles --verbose
! exists ${CHEZMOISOURCEDIR}${/}.git
exists ${CHEZMOICONFIGDIR}/chezmoi.toml

-- home/user/.bashrc --
# contents of .bashrc
-- home4/user/dotfiles/.chezmoi.toml.tmpl --
[data]
  email = "user@home.org"
