@@ -7,8 +7,6 @@ package git
7
7
8
8
import (
9
9
"context"
10
- "fmt"
11
- "io"
12
10
"path"
13
11
"sort"
14
12
@@ -124,48 +122,25 @@ func GetLastCommitForPaths(ctx context.Context, commit *Commit, treePath string,
124
122
return nil , err
125
123
}
126
124
127
- batchStdinWriter , batchReader , cancel , err := commit .repo .CatFileBatch (ctx )
128
- if err != nil {
129
- return nil , err
130
- }
131
- defer cancel ()
132
-
133
125
commitsMap := map [string ]* Commit {}
134
126
commitsMap [commit .ID .String ()] = commit
135
127
136
128
commitCommits := map [string ]* Commit {}
137
129
for path , commitID := range revs {
138
- c , ok := commitsMap [commitID ]
139
- if ok {
140
- commitCommits [path ] = c
130
+ if len (commitID ) == 0 {
141
131
continue
142
132
}
143
133
144
- if len (commitID ) == 0 {
134
+ c , ok := commitsMap [commitID ]
135
+ if ok {
136
+ commitCommits [path ] = c
145
137
continue
146
138
}
147
139
148
- _ , err := batchStdinWriter .Write ([]byte (commitID + "\n " ))
149
- if err != nil {
150
- return nil , err
151
- }
152
- _ , typ , size , err := ReadBatchLine (batchReader )
140
+ c , err := commit .repo .GetCommit (commitID ) // Ensure the commit exists in the repository
153
141
if err != nil {
154
142
return nil , err
155
143
}
156
- if typ != "commit" {
157
- if err := DiscardFull (batchReader , size + 1 ); err != nil {
158
- return nil , err
159
- }
160
- return nil , fmt .Errorf ("unexpected type: %s for commit id: %s" , typ , commitID )
161
- }
162
- c , err = CommitFromReader (commit .repo , MustIDFromString (commitID ), io .LimitReader (batchReader , size ))
163
- if err != nil {
164
- return nil , err
165
- }
166
- if _ , err := batchReader .Discard (1 ); err != nil {
167
- return nil , err
168
- }
169
144
commitCommits [path ] = c
170
145
}
171
146
0 commit comments