@@ -12,8 +12,8 @@ import (
1212 "strconv"
1313 "strings"
1414
15- "code.gitea.io/gitea/modules/git/internal"
1615 "code.gitea.io/gitea/modules/log"
16+ "code.gitea.io/gitea/modules/util"
1717
1818 "github.com/djherbis/buffer"
1919 "github.com/djherbis/nio/v3"
@@ -89,7 +89,8 @@ func catFileBatchCheck(ctx context.Context, repoPath string) (WriteCloserError,
8989
9090// catFileBatch opens git cat-file --batch in the provided repo and returns a stdin pipe, a stdout reader and cancel function
9191// 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 ()) {
9394 // We often want to feed the commits in order into cat-file --batch, followed by their trees and sub trees as necessary.
9495 // so let's create a batch stdin and stdout
9596 batchStdinReader , batchStdinWriter := io .Pipe ()
@@ -109,10 +110,15 @@ func catFileBatch(ctx context.Context, repoPath, batchArg string) (WriteCloserEr
109110 cancel ()
110111 }()
111112
113+ const (
114+ batchCmdArg = "--batch"
115+ batchCommandArg = "--batch-command"
116+ )
117+
112118 go func () {
113119 stderr := strings.Builder {}
114120 err := NewCommand ("cat-file" ).
115- AddArguments (internal . CmdArg ( batchArg )).
121+ AddArguments (toTrustCmdArg ( util . Iif ( batchOrBatchCommnd , batchCmdArg , batchCommandArg ) )).
116122 Run (ctx , & RunOpts {
117123 Dir : repoPath ,
118124 Stdin : batchStdinReader ,
0 commit comments