In the example the history starts at HEAD. Adjust the markStart() call the start from somewhere else or call markStart() multiple times to include several start points.
The PathFilter excludes commits that do not contain the given repository-relative path name. And finally the two sort() calls take care that commits are ordered by their time stamp (newest first) in reverse order. Hence the oldest commit that contains the given file is returned by next().
Be aware that the commit passed to markStart() must be from the same revision walker, i.e. it must be obtained with a call to parseCommit() from the same revWalk instance. See also this thread for more details.
A
RevWalk
can be used as follows to obtain the first commit that contains 'file.txt'In the example the history starts at
HEAD
. Adjust themarkStart()
call the start from somewhere else or callmarkStart()
multiple times to include several start points.The
PathFilter
excludes commits that do not contain the given repository-relative path name. And finally the twosort()
calls take care that commits are ordered by their time stamp (newest first) in reverse order. Hence the oldest commit that contains the given file is returned bynext()
.Be aware that the commit passed to
markStart()
must be from the same revision walker, i.e. it must be obtained with a call toparseCommit()
from the same revWalk instance. See also this thread for more details.