@@ -12,8 +12,8 @@ import (
12
12
"strconv"
13
13
"strings"
14
14
15
- "code.gitea.io/gitea/modules/git/internal"
16
15
"code.gitea.io/gitea/modules/log"
16
+ "code.gitea.io/gitea/modules/util"
17
17
18
18
"github.com/djherbis/buffer"
19
19
"github.com/djherbis/nio/v3"
@@ -89,7 +89,8 @@ func catFileBatchCheck(ctx context.Context, repoPath string) (WriteCloserError,
89
89
90
90
// catFileBatch opens git cat-file --batch in the provided repo and returns a stdin pipe, a stdout reader and cancel function
91
91
// batchArg is the argument to pass to cat-file --batch, e.g. "--batch" or "--batch-command"
92
- func catFileBatch (ctx context.Context , repoPath , batchArg string ) (WriteCloserError , * bufio.Reader , func ()) {
92
+ // If batchOrBatchCommnd is false, it will use "--batch-command" instead of "--batch".
93
+ func catFileBatch (ctx context.Context , repoPath string , batchOrBatchCommnd bool ) (WriteCloserError , * bufio.Reader , func ()) {
93
94
// We often want to feed the commits in order into cat-file --batch, followed by their trees and sub trees as necessary.
94
95
// so let's create a batch stdin and stdout
95
96
batchStdinReader , batchStdinWriter := io .Pipe ()
@@ -109,10 +110,15 @@ func catFileBatch(ctx context.Context, repoPath, batchArg string) (WriteCloserEr
109
110
cancel ()
110
111
}()
111
112
113
+ const (
114
+ batchCmdArg = "--batch"
115
+ batchCommandArg = "--batch-command"
116
+ )
117
+
112
118
go func () {
113
119
stderr := strings.Builder {}
114
120
err := NewCommand ("cat-file" ).
115
- AddArguments (internal . CmdArg ( batchArg )).
121
+ AddArguments (toTrustCmdArg ( util . Iif ( batchOrBatchCommnd , batchCmdArg , batchCommandArg ) )).
116
122
Run (ctx , & RunOpts {
117
123
Dir : repoPath ,
118
124
Stdin : batchStdinReader ,
0 commit comments