Skip to content
  • Brad King's avatar
    ExternalProject: Fix git.cmd version detection · 8cb8ccc5
    Brad King authored
    When GIT_EXECUTABLE points at ".../Git/cmd/git.cmd" in an msysGit
    installation we previously failed to detect the version number in a
    subtle case.  The "git.cmd" assumes 'chcp' is in PATH.  It is typically
    available at "C:\Windows\System32\chcp.com".  On 64-bit Windows the File
    System Redirector maps this location to "C:\Windows\SysWOW64\chcp.com"
    for 32-bit processes.  However, some Windows installations fail to
    provide chcp.com at this path.  Whenever git.cmd runs in a 32-bit
    command shell, as it does under a 32-bit CMake binary, it reports
    
     'chcp' is not recognized as an internal or external command,
      operable program or batch file.
    
    on stderr.  Capture stderr separately so it does not affect parsing
    of the version number.
    
    See also msysGit issue 358:
    
      http://code.google.com/p/msysgit/issues/detail?id=358
    
    Note that FindGit prefers "git.cmd" over "git.exe" because it sets up
    the proper HOME environment variable necessary for Git ssh connections
    to work the same as they do from the Git bash prompt.
    8cb8ccc5