From d1202096e66a30029213ca71230b70eb038b658f Mon Sep 17 00:00:00 2001 From: Martin Nordholts Date: Sat, 30 Jan 2010 08:10:41 +0100 Subject: [PATCH] app: Include git commit hash in verbose version output Note: * Passes make distcheck * The git commit hash is shipped with tarballs * Build handles if git-version.h is removed from a tarball --- app/.gitignore | 9 +++++---- app/Makefile.am | 26 +++++++++++++++++++++++++- app/version.c | 4 ++++ 3 files changed, 34 insertions(+), 5 deletions(-) diff --git a/app/.gitignore b/app/.gitignore index 41eacc56f2..e5731368bd 100644 --- a/app/.gitignore +++ b/app/.gitignore @@ -1,9 +1,10 @@ -/Makefile -/Makefile.in -/makefile.mingw /.deps /.libs +/Makefile +/Makefile.in /gimp-2.* /gimp-console-2.* -/libapp.a /gimp.rc +/git-version.h +/libapp.a +/makefile.mingw diff --git a/app/Makefile.am b/app/Makefile.am index dd5ef21817..1431c0060a 100644 --- a/app/Makefile.am +++ b/app/Makefile.am @@ -70,7 +70,12 @@ libapp_sources = \ gimp-log.h \ gimp-intl.h -libapp_a_SOURCES = $(libapp_sources) +libapp_generated_sources = \ + git-version.h + +$(srcdir)/version.c: git-version.h + +libapp_a_SOURCES = $(libapp_sources) $(libapp_generated_sources) gimp_2_7_SOURCES = $(libapp_sources) main.c @@ -264,3 +269,22 @@ gimp-console.rc.o: gimp.rc $(WINDRES) --define ORIGINALFILENAME_STR="gimp-console-2.7$(EXEEXT)" \ --define INTERNALNAME_STR="gimp-console-2.7" \ gimp.rc gimp-console.rc.o + +# If git is available, always check if git-version.h should be +# updated. If git is not avaialbe, don't do anything if git-version.h +# already exists because then we are probably working with a tarball +# in which case the git-version.h we ship is correct. +git-version.h: update-git-version-header + @if test -d "$(top_srcdir)/.git"; then \ + echo "#define GIMP_GIT_VERSION \"`git log HEAD^..HEAD --pretty=format:%H`\"" > "$@.tmp"; \ + elif test ! -f "$@"; then \ + echo "#define GIMP_GIT_VERSION \"Unknown, shouldn't happen\"" > "$@.tmp"; \ + fi + @if ( test -f "$@" && cmp "$@.tmp" "$@" > /dev/null); then \ + rm -f "$@.tmp"; \ + elif test -f "$@.tmp"; then \ + mv "$@.tmp" "$@"; \ + echo " git HEAD changed: git-version.h regenerated"; \ + fi + +.PHONY: update-git-version-header diff --git a/app/version.c b/app/version.c index 6546c71bab..0766603759 100644 --- a/app/version.c +++ b/app/version.c @@ -34,6 +34,7 @@ #include "about.h" #include "version.h" +#include "git-version.h" #include "gimp-intl.h" @@ -128,6 +129,9 @@ gimp_version_show (gboolean be_verbose) if (be_verbose) { + g_print (_("git commit %s"), GIMP_GIT_VERSION); + g_print ("\n"); + g_print ("\n"); gimp_show_library_versions (); }