Using git with Doxygen FILE_VERSION_FILTER

1.3k views Asked by At

What command would be used with git for the doxygen FILE_VERSION_FILTER? The output would preferably be the number of times that file as been revised in the repo.

3

There are 3 answers

3
VonC On BEST ANSWER

I was looking more for a git command that accepts a file name and outputs how many times that file has been included in a commit.

For a file, you can use one of the git log commands in "List all commits for a specific file":

git log --follow --name-only --format='%H' -- afile | wc

Another option, in "How to get the git commit count?" (git rev-list HEAD --count) would apply to the all repo, not one single file.
It was introduced in commit f69c501, Git 1.7.2-rc1, Jun 2010. Combined with a -- afile, it can work too. Note the option was only offically documented in commit 75d2e5a, Git 2.4.7.


Original answer, for a all repo:

In Git, the usual command is git-describe.

Either:

git describe --long --all --abbrev=7

Or (if you have put at least one tag)

git describe --long --tags --abbrev=7

See "Deriving application build version from git describe - how to get a relatively straightforward string?".

0
Daniele E. Domenichelli On

git revlist --count accepts a list of paths after -- (I don't know if this is a recent feature or if it has always been there).

Since doxygen wants a single command to call using popen(), I'm using a small script like this:

#!/bin/sh

echo -n "File version: "
git -C <path_to_git_directory> rev-list HEAD --count -- $1

-C is necessary if doxygen is not executed in the git directory and requires a recent git version.

0
Mark Asbach On

This is an old question, but since I found it looking for the same problem, here's my solution:

FILE_VERSION_FILTER    = "git log --format='%H' -1"

It will actually just get the git revision for each file and that seems to be the intended use of FILE_VERSION_FILTER. If you like, you could use abbreviated revisions by changing format from '%H' to '%h'.