0

I'm trying to use Doxygen to generate documentation for my Android project and I want to use the FILE_VERSION_FILTER tag to automatically fetch the numeric version of any file.

I know that Git uses hashes as id to the commits, but is there a way to get a numeric version of a separate file?

To get a better understanding of what I want to do, you can see this example from the Doxygen documentation

However, I want to use git instead of CVS or SVN. Is it even possible with Git?

[I'm on Ubuntu, and will be using bash as the shell]

jub0bs
  • 60,866
  • 25
  • 183
  • 186
Victor Axelsson
  • 1,420
  • 1
  • 15
  • 32

1 Answers1

3

Git does not store any numeric version of the objects from the repository. I think you want to know how many times the object was changed (stored in the repository) and this is easy to get: use git log, tell it to produce a single line of text for each commit and count the lines of its output:

To count the versions of file foo stored in the repository that are accessible from the current branch run this:

git log --oneline HEAD -- foo | wc -l

You can replace HEAD with a branch name to get the number of commits reachable from that branch that store changes on file foo or you can remove it altogether.

Keep in mind that the number you get is not unique for each version of the file and it depends on the path you use to get the log.

Check the next fragment of revision graph:

* commit #4 (merge test into master)
|\
* | commit #3 (on branch master)
| * commit #2 (on branch test)
|/
* commit #1 (on master)

Let's say the file foo was added on commit #1 and modified on all the other commits displayed.

Running the command above on different commits will produce the following values:

+--------+---------------+
| commit | # of versions |
+--------+---------------+
|   #1   |  1            |
|   #2   |  2            |
|   #3   |  2            |
|   #4   |  4            |
+--------+---------------+
axiac
  • 68,258
  • 9
  • 99
  • 134