CommitDiff returns the full diff for a commit. For the root commit (no parent), uses diff-tree against empty tree.
(hash string)
| 293 | // CommitDiff returns the full diff for a commit. |
| 294 | // For the root commit (no parent), uses diff-tree against empty tree. |
| 295 | func (r *Repo) CommitDiff(hash string) (string, error) { |
| 296 | out, err := r.run("diff", hash+"~1", hash, "--no-ext-diff", "--color=never") |
| 297 | if err != nil { |
| 298 | // Root commit — diff against empty tree |
| 299 | return r.run("diff-tree", "-p", "--root", "--no-ext-diff", "--color=never", hash) |
| 300 | } |
| 301 | return out, nil |
| 302 | } |
| 303 | |
| 304 | // CommitDiffFiles returns files changed in a commit. |
| 305 | func (r *Repo) CommitDiffFiles(hash string) ([]FileChange, error) { |