Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [jgit-dev] Git log --follow

On Fri, Feb 17, 2017 at 7:39 AM, AJ Otto <aj.o@xxxxxxxxxxx> wrote:

Hello, I’m trying to follow the history of a file when it’s path has changed.
I’ve tried more than 6 different implementations (I’m not going to say they were good as they didn’t work) and I’m at my wits end. 
Doing it by manually walking through all the commits and file trees seems to be the only way to do it but I’m hoping that one of you might have implemented something of the sorts.

I want to retrieve all versions of a file (in the paths before renames too for example) and have those in a single list.
If you’d like to see what I have so far (it doesn’t work) I can post that on a code-share site of sorts.

There’s one Stackoverflow question where someone got it working but I’ve not been successful with his code.
http://stackoverflow.com/questions/11471836/how-to-git-log-follow-path-in-jgit-to-retrieve-the-full-history-includi
it returns random other files with the desired file and returns duplicates too – how would I filter the duplicate files (by checking the commit type) from the final result?


Kind Regards

AJ Otto

Software Developer @ Adept ICT


use the org.eclipse.jgit.revwalk.FollowFilter to follow renames, it's used e.g. by jgit command line
command log to implement the --follow option:

$ jgit log --follow <path>

org.eclipse.jgit.pgm.Log 's base class org.eclipse.jgit.pgm.RevWalkTextBuiltin is using this filter to
implement the --follow option. Or see the test class RevWalkFollowFilterTest.

-Matthias


Back to the top