[windows] skip 'UNIX only' chmod 755 bin/diff-exists chmod 755 bin/diff-pager # test that chezmoi diff invokes diff.command when configured exec chezmoi diff stdout ^${HOME@R}/\.file\s+${WORK@R}/.*/\.file$ # test that chezmoi diff --use-builtin-diff uses the builtin diff even if diff.command is configured exec chezmoi diff --use-builtin-diff [umask:002] cmp stdout golden/diff-umask-002.diff [umask:022] cmp stdout golden/diff-umask-022.diff # test that chezmoi diff --reverse reverses the order of arguments exec chezmoi diff --reverse stdout ^${WORK@R}/.*/\.file\s+${HOME@R}/\.file$ # test that chezmoi apply --verbose uses diff.command exec chezmoi apply --verbose stdout ^${HOME@R}/\.file\s+${WORK@R}/.*/\.file$ chhome home2/user # test that chezmoi diff appends the destination and target paths if diff.args does not contain any templates exec chezmoi diff stdout ^arg\s+${HOME@R}/\.file\s+${WORK@R}/.*/\.file$ # test that chezmoi apply --verbose uses diff.command exec chezmoi apply --verbose stdout ^arg\s+${HOME@R}/\.file\s+${WORK@R}/.*/\.file$ exists $HOME/.file chhome home3/user # test that chezmoi diff ignores exit code 1 from diff.command if the files differ exec chezmoi diff chhome home4/user # test that chezmoi diff does not ignore exit code 2 from diff.command ! exec chezmoi diff stderr 'exit status 2' chhome home5/user # test that chezmoi diff does not invoke diff.command for directories if directories are excluded exec chezmoi diff stdout \.file ! stdout \.dir chhome home6/user # test that chezmoi diff does not invoke the diff pager when there is no diff exec chezmoi diff ! stdout . # test that chezmoi diff does invoke the diff pager when there is a diff cp golden/dot_file $CHEZMOISOURCEDIR exec chezmoi diff stdout diff-pager chhome home7/user stdin golden/diff-no exec chezmoi apply --interactive --no-tty stdout \s/dev/null\s+${WORK@R}/.*/\.file$ ! exists $HOME/.file -- bin/diff-exists -- #!/bin/sh for arg in "$@"; do if [ ! -e "$arg" ]; then echo "$arg: no such file" >&2 exit 2 fi done echo "$@" -- bin/diff-pager -- #!/bin/sh echo diff-pager -- golden/diff-no -- diff no -- golden/diff-umask-002.diff -- diff --git a/.file b/.file index bd729e8ee3cc005444c67dc77eed60016886b5e0..b508963510528ab709627ec448026a10a64c72ef 100664 --- a/.file +++ b/.file @@ -1 +1 @@ -# destination contents of .file +# target contents of .file -- golden/diff-umask-022.diff -- diff --git a/.file b/.file index bd729e8ee3cc005444c67dc77eed60016886b5e0..b508963510528ab709627ec448026a10a64c72ef 100644 --- a/.file +++ b/.file @@ -1 +1 @@ -# destination contents of .file +# target contents of .file -- golden/dot_file -- # contents of .file -- home/user/.config/chezmoi/chezmoi.toml -- [diff] command = "echo" -- home/user/.file -- # destination contents of .file -- home/user/.local/share/chezmoi/dot_file -- # target contents of .file -- home2/user/.config/chezmoi/chezmoi.toml -- [diff] command = "echo" args = ["arg"] -- home2/user/.file -- # destination contents of .file -- home2/user/.local/share/chezmoi/dot_file -- # target contents of .file -- home3/user/.config/chezmoi/chezmoi.toml -- [diff] command = "false" -- home3/user/.local/share/chezmoi/dot_file -- # target contents of .file -- home4/user/.config/chezmoi/chezmoi.toml -- [diff] command = "sh" args = ["-c", "exit 2"] -- home4/user/.local/share/chezmoi/dot_file -- # target contents of .file -- home5/user/.config/chezmoi/chezmoi.toml -- [diff] command = "echo" exclude = ["dirs"] -- home5/user/.local/share/chezmoi/dot_dir/.keep -- -- home5/user/.local/share/chezmoi/dot_file -- # contents of .file -- home6/user/.config/chezmoi/chezmoi.toml -- [diff] pager = "diff-pager" -- home6/user/.local/share/chezmoi/.keep -- -- home7/user/.config/chezmoi/chezmoi.toml -- [diff] command = "diff-exists" -- home7/user/.local/share/chezmoi/dot_file -- # contents of .file