Better reporting of detached git state in --version and --show-config
authorMorgan Deters <mdeters@cs.nyu.edu>
Wed, 20 Mar 2013 22:46:45 +0000 (18:46 -0400)
committerMorgan Deters <mdeters@cs.nyu.edu>
Thu, 21 Mar 2013 00:00:55 +0000 (20:00 -0400)
src/Makefile.am
src/main/options_handlers.h
src/util/configuration.cpp

index 3d90f302e4312ddd2bb4c55d6e7d139e573011e3..b505750d4e13e8d133328940e6c7e5a456cf390e 100644 (file)
@@ -137,7 +137,7 @@ gitinfo: gitinfo.tmp
 # .PHONY ensures the .tmp version is always rebuilt (to check for any changes)
 .PHONY: gitinfo.tmp
 gitinfo.tmp:
-       $(AM_V_GEN)(cd "$(top_srcdir)" && sed 's,^ref: refs/heads/,,' .git/HEAD && git show-ref refs/heads/`sed 's,^ref: refs/heads/,,' .git/HEAD` && echo "Modifications: `test -z \"\`git status -s -uno\`\" && echo false || echo true`") >"$@" 2>/dev/null || true
+       $(AM_V_GEN)(cd "$(top_srcdir)"; if ! grep -q '^ref: refs/heads/' .git/HEAD; then echo; fi; sed 's,^ref: refs/heads/,,' .git/HEAD; git show-ref refs/heads/`sed 's,^ref: refs/heads/,,' .git/HEAD`; echo "Modifications: `test -z \"\`git status -s -uno\`\" && echo false || echo true`") >"$@" 2>/dev/null || true
 
 install-data-local:
        (echo include/cvc4.h; \
index f14a67d5f9582ffc70d303296977aa3e4ede4e01..4bb4841fe129c2ba60c4c377b33dc8554b837c05 100644 (file)
@@ -27,8 +27,12 @@ inline void showConfiguration(std::string option, SmtEngine* smt) {
   printf("\n");
   printf("version    : %s\n", Configuration::getVersionString().c_str());
   if(Configuration::isGitBuild()) {
+    const char* branchName = Configuration::getGitBranchName();
+    if(*branchName == '\0') {
+      branchName = "-";
+    }
     printf("scm        : git [%s %s%s]\n",
-           Configuration::getGitBranchName(),
+           branchName,
            std::string(Configuration::getGitCommit()).substr(0, 8).c_str(),
            Configuration::hasGitModifications() ?
              " (with modifications)" : "");
index 9be4e41044d234bb9de97f7cf2136e3a5a719fc2..ce6273a130ffd4b922ddd5917fbaff0987c9a717 100644 (file)
@@ -216,8 +216,13 @@ std::string Configuration::getGitId() {
     return "";
   }
 
+  const char* branchName = getGitBranchName();
+  if(*branchName == '\0') {
+    branchName = "-";
+  }
+
   stringstream ss;
-  ss << "git " << getGitBranchName() << " " << string(getGitCommit()).substr(0, 8)
+  ss << "git " << branchName << " " << string(getGitCommit()).substr(0, 8)
      << ( ::CVC4::Configuration::hasGitModifications() ? " (with modifications)" : "" );
   return ss.str();
 }