diff options
author | Thomas Wolf <twolf@apache.org> | 2022-08-14 16:34:50 +0200 |
---|---|---|
committer | Matthias Sohn <matthias.sohn@sap.com> | 2022-08-14 21:33:19 +0200 |
commit | b255eb0fb6ab9c7487423083e8df9b1e373bc37e (patch) | |
tree | 085ffc3bb03717ad7c91b16296d485685789822e /org.eclipse.jgit/src/org/eclipse/jgit/api/StashApplyCommand.java | |
parent | 134ee334fb22410623972fa972f60bff38b38ca8 (diff) | |
download | jgit-b255eb0fb6ab9c7487423083e8df9b1e373bc37e.tar.gz jgit-b255eb0fb6ab9c7487423083e8df9b1e373bc37e.zip |
DirCacheCheckout: load WorkingTreeOptions only once
Previous code loaded the WorkingTreeOptions afresh for every single
file being checked out. This checked the git config (all three files,
repo, user and system config) for having been modified every time.
These checks can be costly, for instance on Windows, or if one of the
three config files is not on a local disk, or on an otherwise slow
storage.
Improve this by loading the options and thus checking the git config
only once before the checkout.
Bug: 579715
Change-Id: I21cd5a808f9d90b5ca2d022f91f0eeb8ca26091c
Signed-off-by: Thomas Wolf <twolf@apache.org>
Diffstat (limited to 'org.eclipse.jgit/src/org/eclipse/jgit/api/StashApplyCommand.java')
-rw-r--r-- | org.eclipse.jgit/src/org/eclipse/jgit/api/StashApplyCommand.java | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/api/StashApplyCommand.java b/org.eclipse.jgit/src/org/eclipse/jgit/api/StashApplyCommand.java index 1004d3e50f..17036a9cd3 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/api/StashApplyCommand.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/api/StashApplyCommand.java @@ -48,6 +48,7 @@ import org.eclipse.jgit.revwalk.RevWalk; import org.eclipse.jgit.treewalk.AbstractTreeIterator; import org.eclipse.jgit.treewalk.FileTreeIterator; import org.eclipse.jgit.treewalk.TreeWalk; +import org.eclipse.jgit.treewalk.WorkingTreeOptions; /** * Command class to apply a stashed commit. @@ -382,6 +383,8 @@ public class StashApplyCommand extends GitCommand<ObjectId> { private void resetUntracked(RevTree tree) throws CheckoutConflictException, IOException { Set<String> actuallyModifiedPaths = new HashSet<>(); + WorkingTreeOptions options = repo.getConfig() + .get(WorkingTreeOptions.KEY); // TODO maybe NameConflictTreeWalk ? try (TreeWalk walk = new TreeWalk(repo)) { walk.addTree(tree); @@ -413,7 +416,7 @@ public class StashApplyCommand extends GitCommand<ObjectId> { } } - checkoutPath(entry, reader, + checkoutPath(entry, reader, options, new CheckoutMetadata(eolStreamType, null)); actuallyModifiedPaths.add(entry.getPathString()); } @@ -426,10 +429,10 @@ public class StashApplyCommand extends GitCommand<ObjectId> { } private void checkoutPath(DirCacheEntry entry, ObjectReader reader, - CheckoutMetadata checkoutMetadata) { + WorkingTreeOptions options, CheckoutMetadata checkoutMetadata) { try { DirCacheCheckout.checkoutEntry(repo, entry, reader, true, - checkoutMetadata); + checkoutMetadata, options); } catch (IOException e) { throw new JGitInternalException(MessageFormat.format( JGitText.get().checkoutConflictWithFile, |