]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/dist: reflect local changes to tree in goversion
authorMike Andrews <mra@xoba.com>
Thu, 3 Apr 2014 23:31:41 +0000 (16:31 -0700)
committerIan Lance Taylor <iant@golang.org>
Thu, 3 Apr 2014 23:31:41 +0000 (16:31 -0700)
runtime.Version() requires a trailing "+" when
tree had local modifications at time of build.

Fixes #7701

LGTM=iant
R=golang-codereviews, iant
CC=golang-codereviews
https://golang.org/cl/84040045

src/cmd/dist/build.c

index d898a31b9ee60fafd3ccdce772204388d7c1e420..be05b82f19f673cc0a29edd7c32a3bc6e89d1da8 100644 (file)
@@ -242,12 +242,13 @@ findgoversion(void)
 {
        char *tag, *rev, *p;
        int i, nrev;
-       Buf b, path, bmore, branch;
+       Buf b, path, bmore, bplus, branch;
        Vec tags;
 
        binit(&b);
        binit(&path);
        binit(&bmore);
+       binit(&bplus);
        binit(&branch);
        vinit(&tags);
 
@@ -314,11 +315,16 @@ findgoversion(void)
                // Add extra information.
                run(&bmore, goroot, CheckExit, "hg", "log", "--template", " +{node|short} {date|date}", "-r", rev, nil);
                chomp(&bmore);
+               // Generate a list of local modifications, if any.
+               run(&bplus, goroot, CheckExit, "hg", "status", "-m", "-a", "-r", "-d", nil);
+               chomp(&bplus);
        }
 
        bprintf(&b, "%s", tag);
        if(bmore.len > 0)
                bwriteb(&b, &bmore);
+       if(bplus.len > 0)
+               bwritestr(&b, " +");
 
        // Cache version.
        writefile(&b, bstr(&path), 0);
@@ -330,6 +336,7 @@ done:
        bfree(&b);
        bfree(&path);
        bfree(&bmore);
+       bfree(&bplus);
        bfree(&branch);
        vfree(&tags);