Skip to content
Snippets Groups Projects
Commit 4b5521c3 authored by Jacob Vosmaer's avatar Jacob Vosmaer
Browse files

Set the work_tree to the working_dir

Grit guesses the `working_dir` for each repo it opens; if it can't find
one Repo#working_dir is nil. This change passes Repo#working_dir to Git
command in Git#native via Git's `--work-tree` command-line option.
parent 30bebc10
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -21,6 +21,7 @@ We patched existing grit library to use it inside GitLab
* Fixes symlinks omission from diff
* Added Gemfile
* Ruby 2.0 support
* Automatically set the `--work-tree=` option for Git
* and much more small fixes
 
 
Loading
Loading
Loading
Loading
@@ -93,9 +93,9 @@ module Grit
 
attr_accessor :git_dir, :bytes_read, :work_tree
 
def initialize(git_dir)
def initialize(git_dir, options={})
self.git_dir = git_dir
self.work_tree = git_dir.gsub(/\/\.git$/,'')
self.work_tree = options[:work_tree]
self.bytes_read = 0
end
 
Loading
Loading
@@ -326,6 +326,7 @@ module Grit
argv = []
argv << Git.git_binary
argv << "--git-dir=#{git_dir}" if base
argv << "--work-tree=#{work_tree}" if work_tree
argv << cmd.to_s.tr('_', '-')
argv.concat(options_to_argv(options))
argv.concat(args)
Loading
Loading
Loading
Loading
@@ -54,7 +54,7 @@ module Grit
raise NoSuchPathError.new(epath)
end
 
self.git = Git.new(self.path)
self.git = Git.new(self.path, work_tree: self.working_dir)
end
 
# Public: Initialize a git repository (create it on the filesystem). By
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment