Is there a git equivalent for CVS's $Log$ in Comment History?

263 views Asked by At

I am migrating from CVS to git. In CVS, I can use $Log$ in my comments section, and CVS will write comments at the point of $Log$. Is there an equivalent for this in git?

I have looked and seen the powerful command line and add-on tools available to me, and I'll wind up using those if there is no equivalent, but I am just wondering if an equivalent exists.

1

There are 1 answers

2
Roland Smith On BEST ANSWER

Git doesn't support this be design, because you cannot update a file with commit info after committing, since git checksums the file first.

A workaround is to use attributes, using the "smudge" and "clean" filters and a post-commit hook. What these basically do is update the file with information once it is checked out, and remove the info before it is checked in.

My solution (written in Python) for the $Date$ an $Revision$ keywords (the latter are implemented as to make use of tags) is available on github. You should be able to expand that for $Log$.

However:

You should think really carefully if you want this, because this approach has potential problems;

  • It needs external programs.
  • You have to set a post-commit hook if you want to use it.
  • It might not be portable (I haven't tried it on ms-windows).
  • It might cause loops if you have both source code and compiled programs checked into the repo.

And last but not least, git commands like e.g. git log and git diff can give you much more information than a static log message.