204a205,224 > // InitPrivateAnnex initializes a private annex in the repository > func (t *TemporaryUploadRepository) InitPrivateAnnex() error { > if _, _, err := git.NewCommand(t.ctx, "config", "annex.private", "true").RunStdString(&git.RunOpts{Dir: t.basePath}); err != nil { > return err > } > if _, _, err := git.NewCommand(t.ctx, "annex", "init").RunStdString(&git.RunOpts{Dir: t.basePath}); err != nil { > return err > } > return nil > } > > // AddAnnex adds the file at path to the repository using git annex add > // This requires a non-bare repository > func (t *TemporaryUploadRepository) AddAnnex(path string) error { > if _, _, err := git.NewCommand(t.ctx, "annex", "add").AddDynamicArguments(path).RunStdString(&git.RunOpts{Dir: t.basePath}); err != nil { > return err > } > return nil > } > 346c366,367 < return nil, fmt.Errorf("unable to open stdout pipe: %w", err) --- > log.Error("Unable to open stdout pipe: %v", err) > return nil, fmt.Errorf("Unable to open stdout pipe: %w", err) 354c375,377 < err = git.NewCommand(t.ctx, "diff-index", "--src-prefix=\\a/", "--dst-prefix=\\b/", "--cached", "-p", "HEAD"). --- > var finalErr error > > if err := git.NewCommand(t.ctx, "diff-index", "--src-prefix=\\a/", "--dst-prefix=\\b/", "--cached", "-p", "HEAD"). 362,368c385,388 < defer cancel() < var diffErr error < diff, diffErr = gitdiff.ParsePatch(t.ctx, setting.Git.MaxGitDiffLines, setting.Git.MaxGitDiffLineCharacters, setting.Git.MaxGitDiffFiles, stdoutReader, "") < _ = stdoutReader.Close() < if diffErr != nil { < // if the diffErr is not nil, it will be returned as the error of "Run()" < return fmt.Errorf("ParsePatch: %w", diffErr) --- > diff, finalErr = gitdiff.ParsePatch(t.ctx, setting.Git.MaxGitDiffLines, setting.Git.MaxGitDiffLineCharacters, setting.Git.MaxGitDiffFiles, stdoutReader, "") > if finalErr != nil { > log.Error("ParsePatch: %v", finalErr) > cancel() 370c390,391 < return nil --- > _ = stdoutReader.Close() > return finalErr 372,375c393,401 < }) < if err != nil && !git.IsErrCanceledOrKilled(err) { < log.Error("Unable to diff-index in temporary repo %s (%s). Error: %v\nStderr: %s", t.repo.FullName(), t.basePath, err, stderr) < return nil, fmt.Errorf("unable to run diff-index pipeline in temporary repo: %w", err) --- > }); err != nil { > if finalErr != nil { > log.Error("Unable to ParsePatch in temporary repo %s (%s). Error: %v", t.repo.FullName(), t.basePath, finalErr) > return nil, finalErr > } > log.Error("Unable to run diff-index pipeline in temporary repo %s (%s). Error: %v\nStderr: %s", > t.repo.FullName(), t.basePath, err, stderr) > return nil, fmt.Errorf("Unable to run diff-index pipeline in temporary repo %s. Error: %w\nStderr: %s", > t.repo.FullName(), err, stderr)