@@ -7,8 +7,6 @@ package git
77
88import  (
99	"context" 
10- 	"fmt" 
11- 	"io" 
1210	"path" 
1311	"sort" 
1412
@@ -124,48 +122,25 @@ func GetLastCommitForPaths(ctx context.Context, commit *Commit, treePath string,
124122		return  nil , err 
125123	}
126124
127- 	batchStdinWriter , batchReader , cancel , err  :=  commit .repo .CatFileBatch (ctx )
128- 	if  err  !=  nil  {
129- 		return  nil , err 
130- 	}
131- 	defer  cancel ()
132- 
133125	commitsMap  :=  map [string ]* Commit {}
134126	commitsMap [commit .ID .String ()] =  commit 
135127
136128	commitCommits  :=  map [string ]* Commit {}
137129	for  path , commitID  :=  range  revs  {
138- 		c , ok  :=  commitsMap [commitID ]
139- 		if  ok  {
140- 			commitCommits [path ] =  c 
130+ 		if  len (commitID ) ==  0  {
141131			continue 
142132		}
143133
144- 		if  len (commitID ) ==  0  {
134+ 		c , ok  :=  commitsMap [commitID ]
135+ 		if  ok  {
136+ 			commitCommits [path ] =  c 
145137			continue 
146138		}
147139
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 
153141		if  err  !=  nil  {
154142			return  nil , err 
155143		}
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- 		}
169144		commitCommits [path ] =  c 
170145	}
171146
0 commit comments