Skip to content

Commit 99ffbd8

Browse files
authored
Merge pull request #523 from twpayne/better-diff-logging
Better diff logging
2 parents e349fef + d58df90 commit 99ffbd8

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

internal/chezmoi/debugmutator.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@ func (m *DebugMutator) Chmod(name string, mode os.FileMode) error {
2929
// IdempotentCmdOutput implements Mutator.IdempotentCmdOutput.
3030
func (m *DebugMutator) IdempotentCmdOutput(cmd *exec.Cmd) ([]byte, error) {
3131
var output []byte
32-
err := Debugf("IdempotentCmdOutput(%q)", []interface{}{cmd}, func() error {
32+
cmdStr := ShellQuoteArgs(append([]string{cmd.Path}, cmd.Args[1:]...))
33+
err := Debugf("IdempotentCmdOutput(%q)", []interface{}{cmdStr}, func() error {
3334
var err error
3435
output, err = m.m.IdempotentCmdOutput(cmd)
3536
return err
@@ -60,7 +61,8 @@ func (m *DebugMutator) Rename(oldpath, newpath string) error {
6061

6162
// RunCmd implements Mutator.RunCmd.
6263
func (m *DebugMutator) RunCmd(cmd *exec.Cmd) error {
63-
return Debugf("Run(%q)", []interface{}{cmd}, func() error {
64+
cmdStr := ShellQuoteArgs(append([]string{cmd.Path}, cmd.Args[1:]...))
65+
return Debugf("Run(%q)", []interface{}{cmdStr}, func() error {
6466
return m.m.RunCmd(cmd)
6567
})
6668
}

internal/chezmoi/verbosemutator.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,7 @@ func (m *VerboseMutator) Chmod(name string, mode os.FileMode) error {
4848
func (m *VerboseMutator) IdempotentCmdOutput(cmd *exec.Cmd) ([]byte, error) {
4949
action := cmdString(cmd)
5050
output, err := m.m.IdempotentCmdOutput(cmd)
51-
if err == nil {
52-
_, _ = fmt.Fprintln(m.w, action)
53-
} else {
51+
if err != nil {
5452
_, _ = fmt.Fprintf(m.w, "%s: %v\n", action, err)
5553
}
5654
return output, err

0 commit comments

Comments
 (0)