Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions lib/git/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,17 @@ def self.open(working_dir, opts={})

def initialize(options = {})
if working_dir = options[:working_directory]
options[:repository] ||= File.join(working_dir, '.git')
options[:index] ||= File.join(working_dir, '.git', 'index')
# Submodules have a .git *file* not a .git folder.
# This file's contents point to the location of
# where the git refs are held (In the parent repo)
working_dir_git_file = File.join(working_dir, '.git')
if File.file?(working_dir_git_file)
git_file = File.open(working_dir_git_file).read[8..-1].strip
options[:repository] ||= git_file
else
options[:repository] ||= working_dir_git_file
end
options[:index] ||= File.join(options[:repository], 'index')
end
if options[:log]
@logger = options[:log]
Expand Down