Search code examples
bashdiffclearcase

Which versions modified a particular function


I have a VOB file which has over 100 commits (or check-ins).

Of all those commits, is there way to find out which versions (commits) have modified a particular function that I'm interested in?

The versions of the file can be accessed as /path/to/file@@main/<version_number>


Solution

  • Another approach would be to make use of the virtual file system interface and just brute force extract information. Assuming that you have a script that extracts only the function you are interested in from the whole file named extract_function.sh (could be as simple as sed -n '/^void your_function_name/,/^}/p' for instance), and assuming that there are no labels shorter than 4 characters, then you can run the following commands

    $ cd /path/to/file@@main
    $ for i in ? ?? ???; do /some/where/extract_function.sh $i > /some/where/your_function.$i; done
    $ cd /some/where
    $ md5sum your_function.* | uniq --check-chars=32 \
    | awk '{print $2}'
    

    This gives you a baseline of which versions that have modified your function of interest. Then you are able to compare them by running diff -u your_function.1 your_function.15 for instance.

    The VFS interface was one thing I really, really loved about clearcase when using it; is fantastic to have all of the version control information accessible right on the command line. If you for instance wanted to correlate the checkin time of each version found above this is easily available using ls.

    $ cd /some/where
    $ md5sum your_function.* | uniq --check-chars=32 \
    | awk '{print $2}' | cut -d. -f2 > version-numbers
    $ cd /path/to/file@@main
    $ xargs ls -l < /some/where/version-numbers
    

    which then makes it easy to ignore versions older than x years for instance.