mkhomedir
symlink archive/.dir/.symlink -> .file
exec tar czf archive.tar.gz archive

# test that chezmoi import imports an archive
chezmoi import --strip-components=1 archive.tar.gz
cmp $CHEZMOISOURCEDIR/dot_dir/dot_file golden/dot_dir/dot_file
[!windows] cmp $CHEZMOISOURCEDIR/dot_dir/symlink_dot_symlink golden/dot_dir/symlink_dot_symlink # FIXME this should pass on Windows

# test that chezmoi import run a second time overwrites
chezmoi import --strip-components=1 archive.tar.gz

chhome home2/user

# test chezmoi import --destination
chezmoi import --strip-components=1 --destination=$HOME${/}.subdir archive.tar.gz
cmp $CHEZMOISOURCEDIR/dot_subdir/dot_dir/dot_file golden/dot_dir/dot_file
[!windows] cmp $CHEZMOISOURCEDIR/dot_subdir/dot_dir/symlink_dot_symlink golden/dot_dir/symlink_dot_symlink # FIXME this should pass on Windows

chhome home3/user

# test chezmoi --import --exclude
chezmoi import --strip-components=1 --destination=$HOME${/}.subdir --exclude=symlinks archive.tar.gz
cmp $CHEZMOISOURCEDIR/dot_subdir/dot_dir/dot_file golden/dot_dir/dot_file
! exists $CHEZMOISOURCEDIR/dot_subdir/dot_dir/symlink_dot_symlink

-- archive/.dir/.file --
# contents of .dir/.file
-- golden/dot_dir/dot_file --
# contents of .dir/.file
-- golden/dot_dir/symlink_dot_symlink --
.file
-- home2/user/.local/share/chezmoi/dot_subdir/.keep --
-- home3/user/.local/share/chezmoi/dot_subdir/.keep --
