nolint:gocognit
( ctx context.Context, w io.Writer, repoPath string, baseRef string, headRef string, mergeBase bool, ignoreWhitespace bool, alternates []string, files ...FileDiffRequest, )
| 158 | |
| 159 | //nolint:gocognit |
| 160 | func (g *Git) RawDiff( |
| 161 | ctx context.Context, |
| 162 | w io.Writer, |
| 163 | repoPath string, |
| 164 | baseRef string, |
| 165 | headRef string, |
| 166 | mergeBase bool, |
| 167 | ignoreWhitespace bool, |
| 168 | alternates []string, |
| 169 | files ...FileDiffRequest, |
| 170 | ) error { |
| 171 | if repoPath == "" { |
| 172 | return ErrRepositoryPathEmpty |
| 173 | } |
| 174 | |
| 175 | baseTag, err := g.GetAnnotatedTag(ctx, repoPath, baseRef) |
| 176 | if err == nil { |
| 177 | baseRef = baseTag.TargetSHA.String() |
| 178 | } |
| 179 | |
| 180 | headTag, err := g.GetAnnotatedTag(ctx, repoPath, headRef) |
| 181 | if err == nil { |
| 182 | headRef = headTag.TargetSHA.String() |
| 183 | } |
| 184 | |
| 185 | cmd := command.New("diff", |
| 186 | command.WithFlag("-M"), |
| 187 | command.WithFlag("--full-index"), |
| 188 | command.WithAlternateObjectDirs(alternates...), |
| 189 | ) |
| 190 | if mergeBase { |
| 191 | cmd.Add(command.WithFlag("--merge-base")) |
| 192 | } |
| 193 | |
| 194 | if ignoreWhitespace { |
| 195 | // Ignore whitespace when comparing lines. |
| 196 | cmd.Add(command.WithFlag("-w")) |
| 197 | } |
| 198 | |
| 199 | perFileDiffRequired := false |
| 200 | paths := make([]string, 0, len(files)) |
| 201 | if len(files) > 0 { |
| 202 | for _, file := range files { |
| 203 | paths = append(paths, file.Path) |
| 204 | if file.StartLine > 0 || file.EndLine > 0 { |
| 205 | perFileDiffRequired = true |
| 206 | } |
| 207 | } |
| 208 | } |
| 209 | |
| 210 | processed := 0 |
| 211 | |
| 212 | again: |
| 213 | startLine := 0 |
| 214 | endLine := 0 |
| 215 | |
| 216 | newCmd := cmd.Clone() |
| 217 |
nothing calls this directly
no test coverage detected