[PATCH] D63657: [benchmark] Change GetGitVersion to only check "dirty" when a tag is found

Andrew Ng via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Jun 21 10:17:53 PDT 2019


andrewng created this revision.
andrewng added reviewers: kbobyrev, rnk.
Herald added subscribers: lebedev.ri, mgorny.
Herald added a reviewer: lebedev.ri.
Herald added a project: LLVM.

The check for "dirty" executes the following command:

  git update-index -q --refresh

This can take a considerable amount of time if the index does
need to be refreshed (particularly with the mono repo). This
situation can arise when building shared source on a host in
VMs.

This change moves the check, so that it is only done if a tag is
found. As there are no tags the check is not done.


https://reviews.llvm.org/D63657

Files:
  llvm/utils/benchmark/cmake/GetGitVersion.cmake


Index: llvm/utils/benchmark/cmake/GetGitVersion.cmake
===================================================================
--- llvm/utils/benchmark/cmake/GetGitVersion.cmake
+++ llvm/utils/benchmark/cmake/GetGitVersion.cmake
@@ -30,21 +30,22 @@
       else()
           string(STRIP ${GIT_VERSION} GIT_VERSION)
           string(REGEX REPLACE "-[0-9]+-g" "-" GIT_VERSION ${GIT_VERSION})
-      endif()
 
-      # Work out if the repository is dirty
-      execute_process(COMMAND ${GIT_EXECUTABLE} update-index -q --refresh
-          WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
-          OUTPUT_QUIET
-          ERROR_QUIET)
-      execute_process(COMMAND ${GIT_EXECUTABLE} diff-index --name-only HEAD --
-          WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
-          OUTPUT_VARIABLE GIT_DIFF_INDEX
-          ERROR_QUIET)
-      string(COMPARE NOTEQUAL "${GIT_DIFF_INDEX}" "" GIT_DIRTY)
-      if (${GIT_DIRTY})
-          set(GIT_VERSION "${GIT_VERSION}-dirty")
+          # Work out if the repository is dirty
+          execute_process(COMMAND ${GIT_EXECUTABLE} update-index -q --refresh
+              WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
+              OUTPUT_QUIET
+              ERROR_QUIET)
+          execute_process(COMMAND ${GIT_EXECUTABLE} diff-index --name-only HEAD --
+              WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
+              OUTPUT_VARIABLE GIT_DIFF_INDEX
+              ERROR_QUIET)
+          string(COMPARE NOTEQUAL "${GIT_DIFF_INDEX}" "" GIT_DIRTY)
+          if (${GIT_DIRTY})
+              set(GIT_VERSION "${GIT_VERSION}-dirty")
+          endif()
       endif()
+
   else()
       set(GIT_VERSION "v0.0.0")
   endif()


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D63657.206028.patch
Type: text/x-patch
Size: 1655 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190621/d7501569/attachment.bin>


More information about the llvm-commits mailing list