writeGarbageExternalDiff writes a shell script that emits non-diff output and returns its path. When git invokes it via GIT_EXTERNAL_DIFF / diff.external it replaces the normal unified-diff machinery, so the output can no longer be parsed into model.Diff structs unless the git command opts out with
(t *testing.T)
| 28 | // parsed into model.Diff structs unless the git command opts out with |
| 29 | // --no-ext-diff. |
| 30 | func writeGarbageExternalDiff(t *testing.T) string { |
| 31 | t.Helper() |
| 32 | dir := t.TempDir() |
| 33 | script := filepath.Join(dir, "garbage-diff.sh") |
| 34 | // GIT_EXTERNAL_DIFF programs receive 7 args; we ignore them and print junk. |
| 35 | body := "#!/bin/sh\necho \"not a diff\"\n" |
| 36 | if err := os.WriteFile(script, []byte(body), 0o755); err != nil { |
| 37 | t.Fatalf("write garbage diff script: %v", err) |
| 38 | } |
| 39 | return script |
| 40 | } |
| 41 | |
| 42 | // initRepoWithChange creates a real git repository with one committed file and |
| 43 | // an uncommitted working-tree modification, returning the repo dir. There is a |
no outgoing calls
no test coverage detected