5 @working_directory = nil
9 # opens a Git Repository - no working directory options
10 def self.repo(git_dir)
11 self.new :repository => git_dir
14 # opens a new Git Project from a working directory
15 # you can specify non-standard git_dir and index file in the options
16 def self.open(working_dir, opts={})
17 default = {:working_directory => working_dir,
18 :repository => File.join(working_dir, '.git'),
19 :index => File.join(working_dir, '.git', 'index')}
20 git_options = default.merge(opts)
25 def self.init(working_dir, opts = {})
26 default = {:working_directory => working_dir,
27 :repository => File.join(working_dir, '.git')}
28 git_options = default.merge(opts)
30 if git_options[:working_directory]
31 # if !working_dir, make it
32 FileUtils.mkdir_p(git_options[:working_directory]) if !File.directory?(git_options[:working_directory])
36 Git::Lib.new(git_options).init
42 raise NotImplementedError
45 def initialize(options = {})
46 @working_directory = Git::WorkingDirectory.new(options[:working_directory]) if options[:working_directory]
47 @repository = Git::Repository.new(options[:repository]) if options[:repository]
48 @index = Git::Index.new(options[:index]) if options[:index]
67 #g.config('user.name', 'Scott Chacon') # sets value
68 #g.config('user.email', 'email@email.com') # sets value
69 #g.config('user.name') # returns 'Scott Chacon'
70 #g.config # returns whole config hash
71 def config(name = nil, value = nil)
86 Git::Object.new(self, objectish)
88 alias_method :tree, :object
89 alias_method :commit, :object
90 alias_method :blob, :object
94 Git::Log.new(self, count)
98 Git::Branches.new(self)
106 self.object('HEAD').grep(string)
109 def diff(objectish = 'HEAD', obj2 = nil)
110 Git::Diff.new(self, objectish, obj2)
113 # convenience methods
115 def revparse(objectish)
116 self.lib.revparse(objectish)