How to get the list of about-to-be-commited files in JGIT?

I need to write a precommit hook for GIT where the about to be commited files are checked to see if they are formatted according to a specific eclipse formatter. For this I need to get the list of the files which are not yet commited and their contents. Can this be done using JGIT?

  • Visual Studio Tools for Git commit system
  • How do I remove all my mysterious “index on” and “WIP on” commits?
  • How to diff .odt files with difftool? kdiff3 diff outputs unreadable characters
  • How to change past commit to include a missed file?
  • Using git filter-branch to rewrite authors/committers and commit messages simultaneously
  • How to make existing git branch track a remote branch?
  • Accidentally pasted a file on my main git directory
  • Get range of commits in same branch using git rev-parse
  • Is there any tool for me to easy understand the git conflict file?
  • Why is git is rejecting my pull simply because I have a commit on my local branch?
  • Permission denied (publickey). heroku git:clone myapp - on Windows
  • Smart Git not showing local changes
  • One Solution collect form web for “How to get the list of about-to-be-commited files in JGIT?”

    AFAIK, commit hooks aren’t yet implemented in JGit. See

    However, for examining the index, you can use the DirCache class. returns the index for the given repository. You can then either use a TreeWalk to iterate over the entries or use getEntryCount() and getEntry().
    You may also want to look at the unit tests to get further pointers on how to use the API.

    Git Baby is a git and github fan, let's start git clone.