better git based version numbering (hopefully sane)
Yves Orton [Fri, 26 Dec 2008 16:12:22 +0000 (17:12 +0100)]
.gitignore
make_patchnum.sh
perl.c

index 81f4486..c2aab49 100644 (file)
@@ -2,8 +2,9 @@
 *.patch
 # ignore local .config files
 .config
-# ignore generated .patchnum file
+# these are generated by make_patchnum.sh from git or from a .patchfile
 .patchnum
+.sha1
 
 
 # files produced by './configure.gnu' on a Linux machine
index 5a61637..b26217f 100644 (file)
@@ -1,18 +1,22 @@
 #!/bin/sh
 
 Existing=`cat .patchnum 2>/dev/null`
+Existing_Sha1=`cat .sha1 2>/dev/null`
 if [ -e ".patch" ]; then
        Current=`awk '{print $4}' .patch`
+       Sha1=`awk '{print $3}' .patch`
 elif [ -d ".git" ]; then
        # we should do something better here
        Current=`git describe`
+       Sha1=`git rev-parse HEAD`
        Changed=`git diff-index --name-only HEAD`
        [ -n "$Changed" ] && Current="$Current-with-uncommitted-changes"
 fi
 
-if [ "$Existing" != "$Current" ]; then
-       echo "Updating .patchnum"
+if [ "$Existing" != "$Current" -o "$Existing_Sha1" != "$Sha1" ]; then
+       echo "Updating .patchnum and .sha1"
        echo -n $Current > .patchnum
+       echo -n $Sha1 > .sha1
 else
-       echo "Reusing .patchnum" 
+       echo "Reusing .patchnum and .sha1" 
 fi
diff --git a/perl.c b/perl.c
index e963c0b..be78890 100644 (file)
--- a/perl.c
+++ b/perl.c
@@ -1898,9 +1898,7 @@ S_parse_body(pTHX_ char **env, XSINIT_t xsinit)
 #else
                    sv_catpvs(opts_prog,"\"\\nCharacteristics of this binary (from libperl): \\n");
 #endif
-#ifdef PERL_PATCHNUM
-                   sv_catpvs(opts_prog, "  Git Description: " STRINGIFY(PERL_PATCHNUM) "\\n");
-#endif
+                   sv_catpvs(opts_prog,"  Source revision: " STRINGIFY(PERL_GIT_SHA1) "\\n");
                    sv_catpvs(opts_prog,"  Compile-time options: $_\\n\",");
 
 #if defined(LOCAL_PATCH_COUNT)
@@ -1910,7 +1908,13 @@ S_parse_body(pTHX_ char **env, XSINIT_t xsinit)
                                 "\"  Locally applied patches:\\n\",");
                        for (i = 1; i <= LOCAL_PATCH_COUNT; i++) {
                            if (PL_localpatches[i])
-                               Perl_sv_catpvf(aTHX_ opts_prog,"q%c\t%s\n%c,",
+#ifdef X_PERL_PATCHNUM
+                               if (strEQ(PL_localpatches[i],"DEVEL"))
+                                   Perl_sv_catpvf(aTHX_ opts_prog,"q%c\t%s\n%c,",
+                                              0, STRINGIFY(PERL_PATCHNUM), 0);
+                               else
+#endif
+                                   Perl_sv_catpvf(aTHX_ opts_prog,"q%c\t%s\n%c,",
                                               0, PL_localpatches[i], 0);
                        }
                    }
@@ -3320,10 +3324,9 @@ Perl_moreswitches(pTHX_ const char *s)
                        Perl_form(aTHX_ "        OS Specific Release: %s\n",
                                        OSVERS));
 #endif /* !DGUX */
-#ifdef PERL_PATCHNUM
-       PerlIO_printf(PerlIO_stdout(), "\nGit Description: %s", STRINGIFY(PERL_PATCHNUM));
+#if defined PERL_PATCHNUM
+       PerlIO_printf(PerlIO_stdout(),"\nCompiled from: %s",STRINGIFY(PERL_PATCHNUM));
 #endif
-
 #if defined(LOCAL_PATCH_COUNT)
        if (LOCAL_PATCH_COUNT > 0)
            PerlIO_printf(PerlIO_stdout(),