]> source.dussan.org Git - jgit.git/commit
Delay locating .gitattributes until requested 22/61522/5
authorShawn Pearce <spearce@spearce.org>
Sun, 29 Nov 2015 20:04:03 +0000 (12:04 -0800)
committerShawn Pearce <spearce@spearce.org>
Mon, 30 Nov 2015 02:56:49 +0000 (18:56 -0800)
commitb0eb744604391c94ec505f846604df1a07a166b1
tree899c28c01837932929ad73b0ca3cf7980751c5a3
parent45cc76524bc29d856340736a9de8d0889b17bc13
Delay locating .gitattributes until requested

Instead of checking every entry for .gitattributes only look for the
entry on request by TreeWalk.  This avoids impacting uses like RevWalk
filtering history.

When the attrs is requested skip to the start of the tree and look for
.gitattributes until either it is found, or it is impossible to be
present.  Due to the sorting rules of tree entries .gitattributes
should be among the first or second entries in the tree so very few
entries will need to be considered.

Waiting to find the .gitattributes file by native ordering may miss
attrs for files like .config, which sorts before .gitattributes.
Starting from the front of the tree on demand ensures the attributes
are parsed as early as necessary to process any entry in the tree.

Due to TreeWalk recursively processing up the tree of iterators we
cannot just reset the current CanonicalTreeParser to the start as
parent parsers share the same path buffer as their children.
Resetting a parent to look for .gitattributes may overwrite path
buffer data used by a child iterator.  Work around this by building a
new temporary CanonicalTreeParser instance.

Change-Id: Ife950253b687be325340d27e9915c9a40df2641c
org.eclipse.jgit.test/tst/org/eclipse/jgit/treewalk/CanonicalTreeParserTest.java
org.eclipse.jgit/src/org/eclipse/jgit/treewalk/AbstractTreeIterator.java
org.eclipse.jgit/src/org/eclipse/jgit/treewalk/CanonicalTreeParser.java