Thread: There is the equivalent $Header$, $Date$, $log$ of CVS in Git for C source code ?

  1. #1
    Registered User
    Join Date
    Apr 2021
    Posts
    19

    There is the equivalent $Header$, $Date$, $log$ of CVS in Git for C source code ?

    Hello everyone. Can you tell me if the CVS equivalent $Header$, $Date$, $log$ and $Id$, exists in Git for the C source code ?

    Here is this piece of code as an example:
    Code:
    /* $Header$
     * My Name       $Date$
     *
     * <Description>
     *
     * $log$
    */
    static const char rcsid[] = "$Id$";

  2. #2
    Registered User
    Join Date
    Apr 2021
    Posts
    136
    Yes, but no.

    The problem is that git wants to compare the files, and if you change the files (by modifying the $Date$ or whatever) then it thinks there is a pending change.

    In general, this information is available from the commit log, and the expectation is that should get it from there. If you want a mapping of file to checksum, create a separate file and write a script to update it as part of your release process:

    1. Modify your source files. Test, debug, repeat.
    2. Commit all your source files. Integration test, debug, repeat.
    3. Just prior to release, use a script to dump git log, and create the filespec-to-checksum mapping file.
    4. Commit that file.
    5. Release.

  3. #3
    Registered User Sir Galahad's Avatar
    Join Date
    Nov 2016
    Location
    The Round Table
    Posts
    277
    Quote Originally Posted by aghast View Post
    Yes, but no.

    The problem is that git wants to compare the files, and if you change the files (by modifying the $Date$ or whatever) then it thinks there is a pending change.

    In general, this information is available from the commit log, and the expectation is that should get it from there. If you want a mapping of file to checksum, create a separate file and write a script to update it as part of your release process:

    1. Modify your source files. Test, debug, repeat.
    2. Commit all your source files. Integration test, debug, repeat.
    3. Just prior to release, use a script to dump git log, and create the filespec-to-checksum mapping file.
    4. Commit that file.
    5. Release.
    Good advice!

  4. #4
    Registered User
    Join Date
    Apr 2021
    Posts
    19
    Thanks for the advice, but my request arises from the need to have a history of its evolution and correction for each source .c / .h file. Git gives me the information on the evolution of the whole project and not of each component file (as Subversion does).

  5. #5
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,656
    If you want to know what happened on a per file basis, just type
    git log path/to/file
    It will tell you just those commits which affected that file.

    Similarly for some sub-directory, like the one containing all the source.

    Storing $log inside the file is so 1980's.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  6. #6
    Registered User
    Join Date
    May 2009
    Posts
    4,183
    Quote Originally Posted by Salem View Post
    If you want to know what happened on a per file basis, just type
    git log path/to/file
    It will tell you just those commits which affected that file.

    Similarly for some sub-directory, like the one containing all the source.

    Storing $log inside the file is so 1980's.
    This is the way I tend to do it; both work I have no idea if a corner case where one does not work exists

    Code:
    git log -- path/to/file
    Tim S.
    "...a computer is a stupid machine with the ability to do incredibly smart things, while computer programmers are smart people with the ability to do incredibly stupid things. They are,in short, a perfect match.." Bill Bryson

  7. #7
    Registered User
    Join Date
    Apr 2021
    Posts
    19
    thanks stahta01

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. equivalent of old C code
    By ekoc in forum C Programming
    Replies: 5
    Last Post: 06-11-2015, 08:13 AM
  2. Organizing and optimizing code into source and header files
    By edishuman in forum C++ Programming
    Replies: 3
    Last Post: 01-24-2012, 08:53 AM
  3. Looking for C source code or component for VonJacobson TCP/IP header compression
    By technokid in forum Networking/Device Communication
    Replies: 1
    Last Post: 10-17-2011, 04:41 PM
  4. header and source files
    By gtriarhos in forum C Programming
    Replies: 3
    Last Post: 10-02-2005, 03:16 AM
  5. what's the c equivalent to this asm code
    By *ClownPimp* in forum C++ Programming
    Replies: 4
    Last Post: 01-18-2002, 12:03 AM

Tags for this Thread