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:
authorJames Fargher <jfargher@gitlab.com>2021-11-08 03:10:00 +0300
committerJames Fargher <jfargher@gitlab.com>2021-11-08 03:10:00 +0300
commit5436b8c94256624716b5e61f0d263bfe3c823828 (patch)
tree3488ea118be60c464ebb4fd788fefdb461b0d45d
parentc78886eb5b6f5ca3d22a9715cc6f9a5a229f3c52 (diff)
git: Use spaces instead of the NUL-byteextract_refs_coding
There is a bug that prevents the NUL-byte being outputted for some variations of `--format`. So instead, since ref names cannot have spaces anyway, switch to using spaces.
-rw-r--r--internal/git/decoder.go6
-rw-r--r--internal/git/gitpipe/revision_test.go2
-rw-r--r--internal/gitaly/service/ref/find_all_tags.go2
3 files changed, 5 insertions, 5 deletions
diff --git a/internal/git/decoder.go b/internal/git/decoder.go
index f73889ed2..e788dede9 100644
--- a/internal/git/decoder.go
+++ b/internal/git/decoder.go
@@ -24,18 +24,18 @@ func NewShowRefDecoder(r io.Reader) *RefsDecoder {
// ForEachRefFormat can be passed to the `for-each-ref` `--format` flag
// to retrieve references that can be parsed by `NewForEachRefDecoder`.
-const ForEachRefFormat = "%(objectname)%00%(refname)"
+const ForEachRefFormat = "%(objectname) %(refname)"
// ForEachRefSymbolicFormat can be passed to the `for-each-ref` `--format` flag
// to retrieve references that can be parsed by `NewForEachRefDecoder` and that
// distinguishes symbolic references.
-const ForEachRefSymbolicFormat = "%(objectname)%00%(refname)%00%(symref)"
+const ForEachRefSymbolicFormat = "%(objectname) %(refname) %(symref)"
// NewForEachRefDecoder ...
func NewForEachRefDecoder(r io.Reader) *RefsDecoder {
return &RefsDecoder{
r: bufio.NewReader(r),
- sep: "\x00",
+ sep: " ",
}
}
diff --git a/internal/git/gitpipe/revision_test.go b/internal/git/gitpipe/revision_test.go
index b31d30ff7..8b0d7bd25 100644
--- a/internal/git/gitpipe/revision_test.go
+++ b/internal/git/gitpipe/revision_test.go
@@ -572,7 +572,7 @@ func TestForEachRef(t *testing.T) {
t.Run("tag with format", func(t *testing.T) {
refs := readRefs(t, repo, []string{"refs/tags/v1.0.0"},
- WithForEachRefFormat("%(objectname)%00tag\n%(*objectname)%00peeled"),
+ WithForEachRefFormat("%(objectname) tag\n%(*objectname) peeled"),
)
require.Equal(t, refs, []RevisionResult{
diff --git a/internal/gitaly/service/ref/find_all_tags.go b/internal/gitaly/service/ref/find_all_tags.go
index 23a925c04..849427c1b 100644
--- a/internal/gitaly/service/ref/find_all_tags.go
+++ b/internal/gitaly/service/ref/find_all_tags.go
@@ -50,7 +50,7 @@ func (s *server) findAllTags(ctx context.Context, repo *localrepo.Repo, sortFiel
repo,
[]string{"refs/tags/"},
gitpipe.WithSortField(sortField),
- gitpipe.WithForEachRefFormat("%(objectname)%00%(refname)%(if)%(*objectname)%(then)\n%(objectname)^{}%00peeled%(end)"),
+ gitpipe.WithForEachRefFormat("%(objectname) %(refname)%(if)%(*objectname)%(then)\n%(objectname)^{} peeled%(end)"),
)
catfileObjectsIter := gitpipe.CatfileObject(ctx, objectReader, forEachRefIter)