Source:
<code>public ArtifactId updateGitTrackingBranch(BranchId branch, ArtifactReadable repoArtifact, UserId account, String gitBranchName, boolean fetch, String passphrase, boolean initialImport) { Repository jgitRepo = getLocalRepoReference(repoArtifact.getSoleAttributeValue(FileSystemPath)); if (fetch) { fetch(jgitRepo, passphrase); } if (gitBranchName == null) { gitBranchName = repoArtifact.getSoleAttributeValue(DefaultTrackingBranch); } try { String fromString = "remotes/origin/" + gitBranchName; ObjectId from = jgitRepo.resolve(fromString); if (from == null) { throw new OseeStateException("Failed to resolve commit [%s]", fromString); } List<ArtifactToken> currentCommits = new ArrayList<>(); ObjectId to = null; ArtifactReadable latestCommit = repoArtifact.getRelated(Git_Repository_Commit).getAtMostOneOrDefault(ArtifactReadable.SENTINEL); if (latestCommit.isValid()) { String latestImportedSHA = latestCommit.getSoleAttributeValue(CoreAttributeTypes.GitCommitSHA); to = ObjectId.fromString(latestImportedSHA); if (to == null) { throw new OseeStateException("Failed to resolve commit [%s]", latestImportedSHA); } } <START> currentCommits = queryFactory.fromBranch(branch).andIsOfType(CoreArtifactTypes.CodeUnit).loadArtifactTokens(); <END> for (ArtifactToken singleCommit : currentCommits) { pathToCodeunitMap.put(singleCommit.getName(), singleCommit); } TransactionBuilder tx = orcsApi.getTransactionFactory().createTransaction(repoArtifact.getBranch(), account, "updateGitTrackingBranch repo [" + repoArtifact + "]"); HistoryImportStrategy importStrategy = new FastHistoryStrategy(repoArtifact, orcsApi, tx, initialImport, pathToCodeunitMap); walkTree(repoArtifact, jgitRepo, to, from, repoArtifact.getBranch(), account, importStrategy); } catch (RevisionSyntaxException | IOException ex) { throw OseeCoreException.wrap(ex); } return repoArtifact; }</code><technical_language>declare assign currentCommits creating arraylist is reassigned</technical_language>

Target:
public ArtifactId updateGitTrackingBranch(BranchId branch, ArtifactReadable repoArtifact, UserId account, String gitBranchName, boolean fetch, String passphrase, boolean initialImport) { Repository jgitRepo = getLocalRepoReference(repoArtifact.getSoleAttributeValue(FileSystemPath)); if (fetch) { fetch(jgitRepo, passphrase); } if (gitBranchName == null) { gitBranchName = repoArtifact.getSoleAttributeValue(DefaultTrackingBranch); } try { String fromString = "remotes/origin/" + gitBranchName; ObjectId from = jgitRepo.resolve(fromString); if (from == null) { throw new OseeStateException("Failed to resolve commit [%s]", fromString); } ObjectId to = null; ArtifactReadable latestCommit = repoArtifact.getRelated(Git_Repository_Commit).getAtMostOneOrDefault(ArtifactReadable.SENTINEL); if (latestCommit.isValid()) { String latestImportedSHA = latestCommit.getSoleAttributeValue(CoreAttributeTypes.GitCommitSHA); to = ObjectId.fromString(latestImportedSHA); if (to == null) { throw new OseeStateException("Failed to resolve commit [%s]", latestImportedSHA); } } List<ArtifactToken> currentCommits = queryFactory.fromBranch(branch).andIsOfType(CoreArtifactTypes.CodeUnit).loadArtifactTokens(); for (ArtifactToken singleCommit : currentCommits) { pathToCodeunitMap.put(singleCommit.getName(), singleCommit); } TransactionBuilder tx = orcsApi.getTransactionFactory().createTransaction(repoArtifact.getBranch(), account, "updateGitTrackingBranch repo [" + repoArtifact + "]"); HistoryImportStrategy importStrategy = new FastHistoryStrategy(repoArtifact, orcsApi, tx, initialImport, pathToCodeunitMap); walkTree(repoArtifact, jgitRepo, to, from, repoArtifact.getBranch(), account, importStrategy); } catch (RevisionSyntaxException | IOException ex) { throw OseeCoreException.wrap(ex); } return repoArtifact; }