Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitaly.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKyle Edwards <kyle.edwards@kitware.com>2022-06-07 16:18:11 +0300
committerKyle Edwards <kyle.edwards@kitware.com>2022-06-14 20:22:26 +0300
commit6d22584f179a6e7690c58a69d260aa7d39750463 (patch)
tree9b61368d5c76c3b117fcf7a621f791b8080a89ac
parentd94a0e3e84580684204c5d71d1e528ec07dc0d65 (diff)
FindChangedPaths: Remove --name-status and change parsing accordingly
Now that git diff-tree can potentially receive tree objects, in those cases it will print the IDs of the trees as an extra first line of output before the regular output. While this extra first line of output could be suppressed for commits with --no-commit-id, there is no way to suppress it for trees. So instead of trying to suppress this extra output, we allow git diff-tree to print entire lines in its regular output by not passing it --name-status anymore, and then we search for the beginning colon char to find these entire lines of regular output, ignoring everything else (the line with tree or commit IDs) before it. We then have to further parse the entire lines of regular output using a regex though.
-rw-r--r--internal/gitaly/service/diff/find_changed_paths.go17
1 files changed, 14 insertions, 3 deletions
diff --git a/internal/gitaly/service/diff/find_changed_paths.go b/internal/gitaly/service/diff/find_changed_paths.go
index 56a90a6ca..97019834c 100644
--- a/internal/gitaly/service/diff/find_changed_paths.go
+++ b/internal/gitaly/service/diff/find_changed_paths.go
@@ -2,6 +2,7 @@ package diff
import (
"bufio"
+ "bytes"
"context"
"fmt"
"io"
@@ -33,7 +34,6 @@ func (s *server) FindChangedPaths(in *gitalypb.FindChangedPathsRequest, stream g
git.Flag{Name: "--stdin"},
git.Flag{Name: "-m"},
git.Flag{Name: "-r"},
- git.Flag{Name: "--name-status"},
git.Flag{Name: "--no-renames"},
git.Flag{Name: "--no-commit-id"},
git.Flag{Name: "--diff-filter=AMDTC"},
@@ -77,11 +77,22 @@ func parsePaths(reader *bufio.Reader, chunker *chunk.Chunker) error {
}
func nextPath(reader *bufio.Reader) (*gitalypb.ChangedPaths, error) {
- pathStatus, err := reader.ReadBytes(numStatDelimiter)
+ _, err := reader.ReadBytes(':')
if err != nil {
return nil, err
}
+ line, err := reader.ReadBytes(numStatDelimiter)
+ if err != nil {
+ return nil, err
+ }
+ split := bytes.Split(line[:len(line)-1], []byte(" "))
+ if len(split) != 5 || len(split[4]) != 1 {
+ return nil, fmt.Errorf("git diff-tree parsing failed on: %v", line)
+ }
+
+ pathStatus := split[4]
+
path, err := reader.ReadBytes(numStatDelimiter)
if err != nil {
return nil, err
@@ -95,7 +106,7 @@ func nextPath(reader *bufio.Reader) (*gitalypb.ChangedPaths, error) {
"A": gitalypb.ChangedPaths_ADDED,
}
- parsedPath, ok := statusTypeMap[string(pathStatus[:len(pathStatus)-1])]
+ parsedPath, ok := statusTypeMap[string(pathStatus)]
if !ok {
return nil, helper.ErrInternalf("unknown changed paths returned: %v", string(pathStatus))
}