GNU Astronomy Utilities

12.3.31 Git wrappers (git.h)

Git is one of the most common tools for version control and it can often be useful during development, for example, see COMMIT keyword in Output FITS files. At installation time, Gnuastro will also check for the existence of libgit2, and store the value in the GAL_CONFIG_HAVE_LIBGIT2, see Configuration information (config.h) and Optional dependencies. gnuastro/git.h includes gnuastro/config.h internally, so you will not have to include both for this macro.

char *
gal_git_describe ( )

When libgit2 is present and the program is called within a directory that is version controlled, this function will return a string containing the commit description (similar to Gnuastro’s unofficial version number, see Version numbering). If there are uncommitted changes in the running directory, it will add a ‘-dirty’ prefix to the description. When there is no tagged point in the previous commit, this function will return a uniquely abbreviated commit object as fallback. This function is used for generating the value of the COMMIT keyword in Output FITS files. The output string is similar to the output of the following command:

$ git describe --dirty --always

Space for the output string is allocated within this function, so after using the value you have to free the output string. If libgit2 is not installed or the program calling this function is not within a version controlled directory, then the output will be the NULL pointer.