4

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.

HSchmale
  • 1,838
  • 2
  • 21
  • 48

3 Answers3

2

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'.

Mark Asbach
  • 61
  • 1
  • 9
1

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?".

Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • Is there a way to make git output the number of times that a specific file has been changed? You didn't fully answer my question. – HSchmale Jun 16 '15 at 22:56
  • Git describe does include the number of times a file has changed (since a beach start, or since the last tag) – VonC Jun 16 '15 at 23:22
  • 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. – HSchmale Jun 17 '15 at 00:34
1

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.