Bug #12239


configure script does not detect Git when in a working tree with non-directory .git

Added by rhenium (Kazuki Yamaguchi) about 5 years ago. Updated about 5 years ago.

Target version:


make up doesn't work well on a Git working tree created by git-worktree add.

% git clone ruby-src
% cd ruby-src
% git worktree add -f test-tree trunk
% cd test-tree
% autoconf && ./configure
% make up
# =>
  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:

  1. If svn into $srcdir succeeds -> VCS=svn
  2. If $srcdir/.git/svn is a directory -> VCS="git svn"
  3. If $srcdir/.git is a directory -> VCS=git
  4. 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.


0001-improve-git-repository-detection.patch (3.11 KB) 0001-improve-git-repository-detection.patch rhenium (Kazuki Yamaguchi), 03/31/2016 05:38 PM
Actions #1

Updated by nobu (Nobuyoshi Nakada) about 5 years ago

  • Status changed from Open to Closed

Applied in changeset r54468.

improve git repository detection

  • (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

Also available in: Atom PDF