in src/main/java/com/microsoft/jenkins/appservice/commands/GitDeployCommand.java [144:173]
public Void invoke(Repository repo, VirtualChannel channel) throws IOException, InterruptedException {
DirCache dc = null;
try (final TreeWalk tw = new TreeWalk(repo)) {
dc = repo.lockDirCache();
DirCacheBuilder builder = dc.builder();
tw.reset(); // drop the first empty tree, which we do not need here
tw.setRecursive(true);
tw.setFilter(TreeFilter.ALL);
tw.addTree(new DirCacheBuildIterator(builder));
while (tw.next()) {
final FileMode mode = tw.getFileMode(0);
if (mode.getObjectType() == Constants.OBJ_BLOB) {
final File path = new File(repo.getWorkTree(),
tw.getPathString());
// Deleting a blob is simply a matter of removing
// the file or symlink named by the tree entry.
delete(repo, path);
}
}
builder.commit();
} finally {
if (dc != null) {
dc.unlock();
}
}
return null;
}