From: Gisle Aas Date: Tue, 2 Mar 2010 19:42:39 +0000 (+0100) Subject: Only define PERL_PATCHNUM when either git or the .patch file is available X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=691ce773f92d2810db171a8ff46c3dd0196abfb5;hp=bfc37ff708b737d2490a23505b932c94f1898073;p=p5sagit%2Fp5-mst-13.2.git Only define PERL_PATCHNUM when either git or the .patch file is available This patch also make PERL_GIT_UNCOMMITTED_CHANGES useful and thus avoids always adding the "*" to the 'perl -v' output. --- diff --git a/make_patchnum.pl b/make_patchnum.pl index 28148de..ac32808 100644 --- a/make_patchnum.pl +++ b/make_patchnum.pl @@ -93,7 +93,7 @@ sub backtick { my $command = shift; if (wantarray) { my @result= `$subcd $command`; - warn "$subcd $command: \$?=$?\n" if $?; + #warn "$subcd $command: \$?=$?\n" if $?; print "#> $subcd $command ->\n @result\n" if !$? and $opt_v; chomp @result; return @result; @@ -122,9 +122,9 @@ sub write_files { return 0; } -my $unpushed_commits = '/*no-op*/'; +my $unpushed_commits = ' '; my ($read, $branch, $snapshot_created, $commit_id, $describe)= ("") x 5; -my ($changed, $extra_info, $commit_title, $new_patchnum, $status)= ("") x 5; +my ($changed, $extra_info, $commit_title)= ("") x 3; if (my $patch_file= read_file(".patch")) { ($branch, $snapshot_created, $commit_id, $describe) = split /\s+/, $patch_file; @@ -145,8 +145,14 @@ elsif (-d "$srcdir/.git") { $commit_id = backtick("git rev-parse HEAD"); $describe = backtick("git describe"); my $commit_created = backtick(qq{git log -1 --pretty="format:%ci"}); - $new_patchnum = "describe: $describe"; $extra_info = "git_commit_date='$commit_created'"; + backtick("git diff --no-ext-diff --quiet --exit-code"); + $changed = $?; + unless ($changed) { + backtick("git diff-index --cached --quiet HEAD --"); + $changed = $?; + } + if (length $branch && length $remote) { # git cherry $remote/$branch | awk 'BEGIN{ORS=","} /\+/ {print $2}' | sed -e 's/,$//' my $unpushed_commit_list = @@ -165,12 +171,8 @@ git_remote_branch='$remote/$merge' git_unpushed='$unpushed_commit_list'"; } } - if ($changed) { # not touched since init'd. never true. - $changed = 'true'; + if ($changed) { $commit_title = "Derived from:"; - $status='"uncommitted-changes"' - } else { - $status='/*clean-working-directory-maybe*/' } $commit_title ||= "Commit id:"; } @@ -181,10 +183,10 @@ write_files(<<"EOF_HEADER", <<"EOF_CONFIG"); * WARNING: 'git_version.h' is automatically generated by make_patchnum.pl * DO NOT EDIT DIRECTLY - edit make_patchnum.pl instead ***************************************************************************/ -#define PERL_GIT_UNCOMMITTED_CHANGES $status -#define PERL_PATCHNUM "$describe" +@{[$describe ? "#define PERL_PATCHNUM \"$describe\"" : ()]} #define PERL_GIT_UNPUSHED_COMMITS\t\t\\ $unpushed_commits/*leave-this-comment*/ +@{[$changed ? "#define PERL_GIT_UNCOMMITTED_CHANGES" : ()]} EOF_HEADER ###################################################################### # WARNING: 'lib/Config_git.pl' is generated by make_patchnum.pl diff --git a/patchlevel.h b/patchlevel.h index 1d4a98b..31eedf0 100644 --- a/patchlevel.h +++ b/patchlevel.h @@ -118,19 +118,19 @@ hunk. #if !defined(PERL_PATCHLEVEL_H_IMPLICIT) && !defined(LOCAL_PATCH_COUNT) # if defined(PERL_IS_MINIPERL) # define PERL_PATCHNUM "UNKNOWN-miniperl" -# define PERL_GIT_UNCOMMITTED_CHANGES ,"UNKNOWN" # define PERL_GIT_UNPUSHED_COMMITS /*leave-this-comment*/ # elif defined(PERL_MICRO) # define PERL_PATCHNUM "UNKNOWN-microperl" -# define PERL_GIT_UNCOMMITTED_CHANGES ,"UNKNOWN" # define PERL_GIT_UNPUSHED_COMMITS /*leave-this-comment*/ # else #include "git_version.h" # endif static const char * const local_patches[] = { NULL +#ifdef PERL_GIT_UNCOMMITTED_CHANGES + ,"uncommitted-changes" +#endif PERL_GIT_UNPUSHED_COMMITS /* do not remove this line */ - PERL_GIT_UNCOMMITTED_CHANGES /* do not remove this line */ ,NULL }; diff --git a/utils/perlbug.PL b/utils/perlbug.PL index c015e25..2fe3c59 100644 --- a/utils/perlbug.PL +++ b/utils/perlbug.PL @@ -42,7 +42,7 @@ while () { last if /^\s*}/; next if /^\s*#/; # preprocessor stuff next if /PERL_GIT_UNPUSHED_COMMITS/; # XXX expand instead - next if /PERL_GIT_UNCOMMITTED_CHANGES/; # XXX expand instead + next if /"uncommitted-changes"/; # XXX determine if active instead chomp; s/^\s+,?\s*"?//; s/"?\s*,?$//;