Bug #12239
closedconfigure script does not detect Git when in a working tree with non-directory .git
Description
make up doesn't work well on a Git working tree created by git-worktree add.
% git clone https://github.com/ruby/ruby.git ruby-src
% cd ruby-src
% git worktree add -f test-tree trunk
% cd test-tree
% autoconf && ./configure
% make up
# =>
  cannot
  retrieving mspec ...
  Cloning into 'spec/mspec'...
  remote: Counting objects: 5135, done.
  ...
% grep VCS Makefile
# => 
  VCS           = echo cannot
  ...
The current configure script's VCS detection flow is:
- If svn into $srcdirsucceeds
 -> VCS=svn
- If $srcdir/.git/svn is a directory
 -> VCS="git svn"
- If $srcdir/.git is a directory
 -> VCS=git
- If none satisfy
 -> VCS="echo cannot"
The 2. and 3. are problematic.
When $srcdir is a Git working tree created by git-worktree add (or is a submodule), $srcdir/.git is not a directory but a file pointing at the real git directory.
I attached a patch which fixes this using git-rev-parse: we can get the real git directory (such as .git and .git/worktrees/test-tree) with git --work-tree="$srcdir" --git-dir="$srcdir/.git" rev-parse --git-dir.
git-worktree is a fairly new command but the --work-tree option exists since Git 1.5.3 (released in 2010).
On nmake, the VCS detection is done by checking for the existence of $srcdir/.{svn,git,git/svn} (regardless of the type), so it works for plain Git working trees but not for git-svn trees.
However I don't know how to get command output with nmake, so I left win32/Makefile.sub untouched.
Files
        
           Updated by nobu (Nobuyoshi Nakada) over 9 years ago
          Updated by nobu (Nobuyoshi Nakada) over 9 years ago
          
          
        
        
      
      - Status changed from Open to Closed
Applied in changeset r54468.
improve git repository detection
- configure.in (AC_CONFIG_FILES): $srcdir/.git can be a file pointing
 the real git_dir, such as when the git working tree is a "linked
 working tree" (a working tree created by git-worktree). So use
 git-rev-parse --git-dir to check if $srcdir is the top-level of a git
 repository, not just checking if the $srcdir/.git directory does exist
 or not. [ruby-core:74759] [Bug #12239]
- tool/change_maker.rb: use tool/vcs.rb to detect VCS. This used to have
 its own VCS detection code, while we have tool/vcs.rb.
- tool/vcs.rb (detect): remove code duplication