From 2cedef1333fd166581a0f750a872b4b9d935ba82 Mon Sep 17 00:00:00 2001 From: Wilson Snyder Date: Thu, 23 Apr 2009 09:11:40 -0400 Subject: [PATCH] Avoid config_rev making empty file on errors --- src/config_rev.pl | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/config_rev.pl b/src/config_rev.pl index db16f9821..8319e9ed3 100755 --- a/src/config_rev.pl +++ b/src/config_rev.pl @@ -23,11 +23,11 @@ my $dir = $ARGV[0]; defined $dir or die "%Error: No directory argument,"; chdir $dir; +my $rev = 'UNKNOWN_REV'; my $data = `git log | head -1`; -if ($data !~ /commit\s*([a-z0-9]+)/i) { - die "%Error: No git revision found,"; +if ($data =~ /commit\s*([a-z0-9]+)/i) { + $rev = $1; } -my $rev = $1; $data = `git status`; if ($data !~ /nothing to commit/i) { @@ -35,3 +35,6 @@ if ($data !~ /nothing to commit/i) { } print "static const char* DTVERSION_rev = \"$rev\";\n"; + +# Die after the print, so at least the header has good contents +$rev =~ /UNKNOWN/ and die "%Error: No git revision found,";