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:
authorJohn Cai <jcai@gitlab.com>2019-04-25 03:29:48 +0300
committerJohn Cai <jcai@gitlab.com>2019-04-25 04:38:11 +0300
commit19b9deebf3a4d9c3795d89400319966d17985412 (patch)
tree2cfe841691536a7f498165969b4790a07a59877c
parent80221e5cd697c1974b9bb13b5f6ca66a044c6173 (diff)
Use constant for escapedNewLine
-rw-r--r--internal/command/command.go14
1 files changed, 10 insertions, 4 deletions
diff --git a/internal/command/command.go b/internal/command/command.go
index 5aebc5732..c6f911ece 100644
--- a/internal/command/command.go
+++ b/internal/command/command.go
@@ -20,6 +20,10 @@ import (
"gitlab.com/gitlab-org/gitaly/internal/config"
)
+const (
+ escapedNewline = `\n`
+)
+
// GitEnv contains the ENV variables for git commands
var GitEnv = []string{
// Force english locale for consistency on the output messages
@@ -53,7 +57,9 @@ var exportedEnvVars = []string{
const (
// MaxStderrBytes is at most how many bytes will be written to stderr
- MaxStderrBytes = 10000 // 10kb
+ MaxStderrBytes = 10000 // 10kb
+ // StderrBufferSize is the buffer size we use for the reader that reads from
+ // the stderr stream of the command
StderrBufferSize = 4096
)
@@ -291,13 +297,13 @@ func writeLines(writer io.Writer, reader io.Reader, done chan struct{}, maxBytes
}
// only write up to the max
- if len(b)+bytesWritten+2 >= maxBytes {
- b = b[:maxBytes-bytesWritten-2]
+ if len(b)+bytesWritten+len(escapedNewline) >= maxBytes {
+ b = b[:maxBytes-bytesWritten-len(escapedNewline)]
}
// prepend an escaped newline
if bytesWritten > 0 {
- b = append([]byte{'\\', 'n'}, b...)
+ b = append([]byte(escapedNewline), b...)
}
n, _ := writer.Write(b)