path: root/tool/vcs.rb
diff options
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-04-01 05:55:30 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-04-01 05:55:30 +0000
commit69d6e315b565a1c6956b101503c39ff286e51fa5 (patch)
tree421ed59d9ff179f2a019b72c196574326f6bfd74 /tool/vcs.rb
parent34c0c84086dc636618daa0b27d3a4307262ceb90 (diff)
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 git-svn-id: svn+ssh:// b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'tool/vcs.rb')
1 files changed, 4 insertions, 8 deletions
diff --git a/tool/vcs.rb b/tool/vcs.rb
index 4d8936c..0f20c6e 100644
--- a/tool/vcs.rb
+++ b/tool/vcs.rb
@@ -73,15 +73,11 @@ class VCS
def self.detect(path)
@@dirs.each do |dir, klass, pred|
- if pred ? pred[path, dir] :, dir))
- return
- end
- prev = path
+ curr = path
loop {
- curr = File.realpath(File.join(prev, '..'))
- break if curr == prev # stop at the root directory
- return if, dir))
- prev = curr
+ return if pred ? pred[curr, dir] :, dir))
+ prev, curr = curr, File.realpath(File.join(curr, '..'))
+ break if curr == prev # stop at the root directory
raise VCS::NotFoundError, "does not seem to be under a vcs: #{path}"