Skip to content

Commit c1e648d

Browse files
committed
2 parents cf93b89 + 0e0d313 commit c1e648d

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

lib/utils/GitUtil.java

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,7 @@
33
import java.nio.file.Path;
44
import java.nio.file.Paths;
55
import java.util.Arrays;
6-
import java.util.Date;
7-
import java.util.HashSet;
86
import java.util.List;
9-
import java.util.Set;
107

118
public class GitUtil {
129

@@ -183,6 +180,17 @@ public static Boolean checkout(Path repoDir, String com, Boolean ifForce) {
183180
}
184181
pr = ProcessUtil.executeCMD(checkoutCMD, null, repoDir, 0);
185182

183+
if (pr.err.contains("fatal: index file smaller than expected")) {
184+
Path lockFilePath = Paths.get(repoDir.toString() + "/.git/index.lock");
185+
if (lockFilePath.toFile().exists()) {
186+
lockFilePath.toFile().delete();
187+
}
188+
Path indexFilePath = Paths.get(repoDir.toString() + "/.git/index");
189+
if (indexFilePath.toFile().exists()) {
190+
indexFilePath.toFile().delete();
191+
}
192+
}
193+
186194
if (pr.exitCode == 0) {
187195
return true;
188196
} else {

0 commit comments

Comments
 (0)