From 38f009d6d0aa35b13d19575611db1c724a9d1a5b Mon Sep 17 00:00:00 2001 From: scott Chacon Date: Tue, 13 Nov 2007 07:36:50 -0800 Subject: updated a bunch of the documentation --- README | 21 + TODO | 5 + doc/classes/Git.html | 93 +++- doc/classes/Git/Author.html | 175 +++++++ doc/classes/Git/Base.html | 734 ++++++++++++++++++----------- doc/classes/Git/Branch.html | 122 ++--- doc/classes/Git/Branches.html | 72 +-- doc/classes/Git/Diff.html | 128 ++--- doc/classes/Git/Diff/DiffFile.html | 24 +- doc/classes/Git/Lib.html | 582 +++++++++++++---------- doc/classes/Git/Object.html | 20 +- doc/classes/Git/Object/AbstractObject.html | 114 ++--- doc/classes/Git/Object/Blob.html | 23 +- doc/classes/Git/Object/Commit.html | 241 +++++++++- doc/classes/Git/Object/Tag.html | 40 +- doc/classes/Git/Object/Tree.html | 142 +++++- doc/classes/Git/Path.html | 36 +- doc/classes/Git/Remote.html | 84 ++-- doc/created.rid | 2 +- doc/files/README.html | 51 +- doc/files/lib/git/author_rb.html | 101 ++++ doc/files/lib/git/base_rb.html | 2 +- doc/files/lib/git/lib_rb.html | 2 +- doc/files/lib/git/object_rb.html | 2 +- doc/files/lib/git_rb.html | 3 +- doc/fr_class_index.html | 1 + doc/fr_file_index.html | 1 + doc/fr_method_index.html | 283 +++++------ lib/git.rb | 46 ++ lib/git/base.rb | 96 +++- lib/git/object.rb | 38 +- 31 files changed, 2223 insertions(+), 1061 deletions(-) create mode 100644 doc/classes/Git/Author.html create mode 100644 doc/files/lib/git/author_rb.html diff --git a/README b/README index cc37f4c..c10117d 100644 --- a/README +++ b/README @@ -19,6 +19,27 @@ but eventually I'll replace that with either C bindings to libgit or libgit-thin, or I'll write pure ruby handlers for at least some of the Git stuff. += Major Objects + +Git::Base - this is the object returned from a Git.open or Git.clone. +Most major actions are called from this object. + +Git::Object - this is the base object for your tree, blob and commit objects, +returned from @git.gtree or @git.object calls. the Git::AbstractObject will +have most of the calls in common for all those objects. + +Git::Diff - returns from a @git.diff command. It is an Enumerable that returns +Git::Diff:DiffFile objects from which you can get per file patches and insertion/deletion +statistics. You can also get total statistics from the Git::Diff object directly. + +Git::Status + +Git::Branches + +Git::Remote + +Git::Log + = Examples diff --git a/TODO b/TODO index 0354005..9ae76f5 100644 --- a/TODO +++ b/TODO @@ -1,3 +1,8 @@ +* more documentation + +* compatible with git 1.4 + +* git archive * More Error Examples diff --git a/doc/classes/Git.html b/doc/classes/Git.html index 2fdebb8..523491f 100644 --- a/doc/classes/Git.html +++ b/doc/classes/Git.html @@ -55,6 +55,10 @@ In: + + lib/git/author.rb + +
lib/git/base.rb @@ -124,6 +128,31 @@
+
+

+Git/Ruby Library +

+

+This provides bindings for working with git in complex interactions, +including branching and merging, object inspection and manipulation, +history, patch generation and more. You should be able to do most +fundamental git operations with this library. +

+

+This module provides the basic functions to open a git reference to work +with. You can open a working directory, open a bare repository, initialize +a new repo or clone an existing remote repository. +

+ + + +
Author:Scott Chacon (schacon@gmail.com) + +
License:MIT License + +
+ +
@@ -149,7 +178,8 @@

Classes and Modules

- Class Git::Base
+ Class Git::Author
+Class Git::Base
Class Git::Branch
Class Git::Branches
Class Git::Diff
@@ -175,7 +205,7 @@ Class Git::WorkingDirectory VERSION = - '1.0.1' + '1.0.2'
@@ -200,11 +230,19 @@ Class Git::WorkingDirectory
+

+open a bare repository +

+

+this takes the path to a bare git repo it expects not to be able to use a +working directory so you can’t checkout stuff, commit things, etc. +but you can do most read operations +

[Source]

-# File lib/git.rb, line 36
+# File lib/git.rb, line 51
   def self.bare(git_dir)
     Base.bare(git_dir)
   end
@@ -223,11 +261,28 @@ Class Git::WorkingDirectory
         
+

+clones a remote repository +

+

+options +

+
+  :bare => true (does a bare clone)
+  :repository => '/path/to/alt_git_dir'
+  :index => '/path/to/alt_index_file'
+
+

+example +

+
+ Git.clone('git://repo.or.cz/rubygit.git', 'clone.git', :bare => true)
+

[Source]

-# File lib/git.rb, line 48
+# File lib/git.rb, line 88
   def self.clone(repository, name, options = {})
     Base.clone(repository, name, options)
   end
@@ -246,11 +301,21 @@ Class Git::WorkingDirectory
         
+

+initialize a new git repository, defaults to the current working directory +

+

+options +

+
+  :repository => '/path/to/alt_git_dir'
+  :index => '/path/to/alt_index_file'
+

[Source]

-# File lib/git.rb, line 44
+# File lib/git.rb, line 74
   def self.init(working_dir = '.', options = {})
     Base.init(working_dir, options)
   end
@@ -269,11 +334,27 @@ Class Git::WorkingDirectory
         
+

+open an existing git working directory +

+

+this will most likely be the most common way to create a git reference, +referring to a working directory. if not provided in the options, the +library will assume your git_dir and index are in the default place (.git/, +.git/index) +

+

+options +

+
+  :repository => '/path/to/alt_git_dir'
+  :index => '/path/to/alt_index_file'
+

[Source]

-# File lib/git.rb, line 40
+# File lib/git.rb, line 65
   def self.open(working_dir, options = {})
     Base.open(working_dir, options)
   end
diff --git a/doc/classes/Git/Author.html b/doc/classes/Git/Author.html
new file mode 100644
index 0000000..85441f9
--- /dev/null
+++ b/doc/classes/Git/Author.html
@@ -0,0 +1,175 @@
+
+
+
+
+
+  Class: Git::Author
+  
+  
+  
+  
+
+
+
+
+
+
+    
+ + + + + + + + + + + + + + +
ClassGit::Author
In: + + lib/git/author.rb + +
+
Parent: + + Object + +
+
+ + +
+ + + +
+ + + +
+ +
+

Methods

+ +
+ new   +
+
+ +
+ + + + +
+ + + + + +
+

Attributes

+ +
+ + + + + + + + + + + + + + + + +
date [RW] 
email [RW] 
name [RW] 
+
+
+ + + + +
+

Public Class methods

+ +
+ + + + +
+

[Source]

+
+
+# File lib/git/author.rb, line 5
+    def initialize(author_string)
+      if m = /(.*?) <(.*?)> (\d+) (.*)/.match(author_string)
+        @name = m[1]
+        @email = m[2]
+        @date = Time.at(m[3].to_i)
+      end
+    end
+
+
+
+
+ + +
+ + +
+ + + + + + \ No newline at end of file diff --git a/doc/classes/Git/Base.html b/doc/classes/Git/Base.html index 2a7fbce..9c994c6 100644 --- a/doc/classes/Git/Base.html +++ b/doc/classes/Git/Base.html @@ -88,48 +88,48 @@

Methods

- add   - add_remote   - add_tag   - bare   - branch   - branches   - chdir   - checkout   - clone   - commit   - commit_all   - config   - current_branch   - diff   - dir   - fetch   - gblob   - gcommit   - grep   - gtree   - index   - init   - lib   - log   - merge   - new   - object   - open   - pull   - push   - remote   - remotes   - remove   - repack   - repo   - repo_size   - reset   - reset_hard   - revparse   - status   - tag   - tags   + add   + add_remote   + add_tag   + bare   + branch   + branches   + chdir   + checkout   + clone   + commit   + commit_all   + config   + current_branch   + diff   + dir   + fetch   + gblob   + gcommit   + grep   + gtree   + index   + init   + lib   + log   + merge   + new   + object   + open   + pull   + push   + remote   + remotes   + remove   + repack   + repo   + repo_size   + reset   + reset_hard   + revparse   + status   + tag   + tags  
@@ -151,11 +151,11 @@

Public Class methods

-
- +
+ @@ -166,8 +166,8 @@ opens a bare Git Repository - no working directory options

[Source]

-
+ onclick="toggleCode('M000080-source');return false;">[Source]

+
 # File lib/git/base.rb, line 10
     def self.bare(git_dir)
@@ -178,11 +178,11 @@ href="Repository.html">Repository - no working directory options
         
-
- +
+ @@ -207,8 +207,8 @@ options: :index_file

[Source]

-
+ onclick="toggleCode('M000083-source');return false;">[Source]

+
 # File lib/git/base.rb, line 58
     def self.clone(repository, name, opts = {})
@@ -220,11 +220,11 @@ options:
         
-
- +
+ @@ -241,8 +241,8 @@ options: :index_file

[Source]

-
+ onclick="toggleCode('M000082-source');return false;">[Source]

+
 # File lib/git/base.rb, line 29
     def self.init(working_dir, opts = {})
@@ -265,19 +265,19 @@ options:
         
-
- +
+

[Source]

-
+ onclick="toggleCode('M000084-source');return false;">[Source]

+
 # File lib/git/base.rb, line 63
     def initialize(options = {})
@@ -295,11 +295,11 @@ options:
         
-
- +
+ @@ -310,8 +310,8 @@ opens a new Git Project from a working directory you can specify non-standard git_dir and index file in the options

[Source]

-
+ onclick="toggleCode('M000081-source');return false;">[Source]

+
 # File lib/git/base.rb, line 16
     def self.open(working_dir, opts={})    
@@ -327,11 +327,11 @@ you can specify non-standard git_dir and index file in the options
 
       

Public Instance methods

-
- +
+ @@ -341,10 +341,10 @@ you can specify non-standard git_dir and index file in the options adds files from the working directory to the git repository

[Source]

-
+ onclick="toggleCode('M000103-source');return false;">[Source]

+
-# File lib/git/base.rb, line 162
+# File lib/git/base.rb, line 212
     def add(path = '.')
       self.lib.add(path)
     end
@@ -353,21 +353,30 @@ adds files from the working directory to the git repository
         
-
- +
+
+

+adds a new remote to this repository url can be a git url or a Git::Base object if it’s a local reference +

+
+ @git.add_remote('scotts_git', 'git://repo.or.cz/rubygit.git')
+ @git.fetch('scotts_git')
+ @git.merge('scotts_git/master')
+

[Source]

-
+ onclick="toggleCode('M000115-source');return false;">[Source]

+
-# File lib/git/base.rb, line 213
+# File lib/git/base.rb, line 290
     def add_remote(name, url, opts = {})
       if url.is_a?(Git::Base)
         url = url.repo.path
@@ -380,21 +389,24 @@ adds files from the working directory to the git repository
         
-
- +
+
+

+creates a new git tag (Git::Tag) +

[Source]

-
+ onclick="toggleCode('M000118-source');return false;">[Source]

+
-# File lib/git/base.rb, line 229
+# File lib/git/base.rb, line 309
     def add_tag(tag_name)
       self.lib.tag(tag_name)
       tag(tag_name)
@@ -404,21 +416,24 @@ adds files from the working directory to the git repository
         
-
- +
+
+

+returns a Git::Branch object for branch_name +

[Source]

-
+ onclick="toggleCode('M000098-source');return false;">[Source]

+
-# File lib/git/base.rb, line 140
+# File lib/git/base.rb, line 167
     def branch(branch_name = 'master')
       Git::Branch.new(self, branch_name)
     end
@@ -427,21 +442,25 @@ adds files from the working directory to the git repository
         
-
- +
+
+

+returns a Git::Branches object of all the Git::Branch objects for this repo +

[Source]

-
+ onclick="toggleCode('M000097-source');return false;">[Source]

+
-# File lib/git/base.rb, line 136
+# File lib/git/base.rb, line 162
     def branches
       Git::Branches.new(self)
     end
@@ -450,21 +469,34 @@ adds files from the working directory to the git repository
         
-
- +
+
+

+changes current working directory for a block to the git working directory +

+

+example +

+
+ @git.chdir do
+   # write files
+   @git.add
+   @git.commit('message')
+ end
+

[Source]

-
+ onclick="toggleCode('M000088-source');return false;">[Source]

+
-# File lib/git/base.rb, line 87
+# File lib/git/base.rb, line 102
     def chdir
       Dir.chdir(dir.path) do
         yield dir.path
@@ -475,21 +507,24 @@ adds files from the working directory to the git repository
         
-
- +
+
+

+checks out a branch as the new git working directory +

[Source]

-
+ onclick="toggleCode('M000109-source');return false;">[Source]

+
-# File lib/git/base.rb, line 188
+# File lib/git/base.rb, line 246
     def checkout(branch = 'master', opts = {})
       self.lib.checkout(branch, opts)
     end
@@ -498,21 +533,24 @@ adds files from the working directory to the git repository
         
-
- +
+
+

+commits all pending changes in the index file to the git repository +

[Source]

-
+ onclick="toggleCode('M000107-source');return false;">[Source]

+
-# File lib/git/base.rb, line 179
+# File lib/git/base.rb, line 233
     def commit(message, opts = {})
       self.lib.commit(message, opts)
     end
@@ -521,21 +559,26 @@ adds files from the working directory to the git repository
         
-
- +
+
+

+commits all pending changes in the index file to the git repository, but +automatically adds all modified files without having to explicitly calling +@git.add() on them. +

[Source]

-
+ onclick="toggleCode('M000108-source');return false;">[Source]

+
-# File lib/git/base.rb, line 183
+# File lib/git/base.rb, line 240
     def commit_all(message, opts = {})
       opts = {:add_all => true}.merge(opts)
       self.lib.commit(message, opts)
@@ -545,11 +588,11 @@ adds files from the working directory to the git repository
         
-
- +
+ @@ -562,10 +605,10 @@ value g.config(‘user.name’) # returns ‘Scott Chacon’ g.config # returns whole config hash

[Source]

-
+ onclick="toggleCode('M000090-source');return false;">[Source]

+
-# File lib/git/base.rb, line 105
+# File lib/git/base.rb, line 121
     def config(name = nil, value = nil)
       if(name && value)
         # set value
@@ -583,21 +626,24 @@ Chacon’ g.config # returns whole config hash
         
-
- +
+
+

+returns the name of the branch the working directory is currently on +

[Source]

-
+ onclick="toggleCode('M000121-source');return false;">[Source]

+
-# File lib/git/base.rb, line 244
+# File lib/git/base.rb, line 330
     def current_branch
       self.lib.branch_current
     end
@@ -606,21 +652,24 @@ Chacon’ g.config # returns whole config hash
         
-
- +
+
+

+returns a Git::Diff object +

[Source]

-
+ onclick="toggleCode('M000102-source');return false;">[Source]

+
-# File lib/git/base.rb, line 157
+# File lib/git/base.rb, line 207
     def diff(objectish = 'HEAD', obj2 = nil)
       Git::Diff.new(self, objectish, obj2)
     end
@@ -629,21 +678,28 @@ Chacon’ g.config # returns whole config hash
         
-
- +
+
+

+returns a reference to the working directory +

+
+ @git.dir.path
+ @git.dir.writeable?
+

[Source]

-
+ onclick="toggleCode('M000085-source');return false;">[Source]

+
-# File lib/git/base.rb, line 75
+# File lib/git/base.rb, line 78
     def dir
       @working_directory
     end
@@ -652,21 +708,25 @@ Chacon’ g.config # returns whole config hash
         
-
- +
+
+

+fetches changes from a remote branch - this does not modify the working +directory, it just gets the changes from the remote if there are any +

[Source]

-
+ onclick="toggleCode('M000110-source');return false;">[Source]

+
-# File lib/git/base.rb, line 192
+# File lib/git/base.rb, line 252
     def fetch(remote = 'origin')
       self.lib.fetch(remote)
     end
@@ -675,8 +735,8 @@ Chacon’ g.config # returns whole config hash
         
-
- +
+
gblob(objectish) @@ -684,13 +744,13 @@ Chacon’ g.config # returns whole config hash

-Alias for object +Alias for object

-
- +
+
gcommit(objectish) @@ -698,26 +758,54 @@ Alias for object

-Alias for object +Alias for object

-
- +
+
+

+will run a grep for ‘string’ on the HEAD of the git repository +

+

+to be more surgical in your grep, you can call grep() off a specific git +object. for example: +

+
+ @git.object("v2.3").grep('TODO')
+
+

+in any case, it returns a hash of arrays of the type: +

+
+ hsh[tree-ish] = [[line_no, match], [line_no, match2]]
+ hsh[tree-ish] = [[line_no, match], [line_no, match2]]
+
+

+so you might use it like this: +

+
+  @git.grep("TODO").each do |sha, arr|
+    puts "in blob #{sha}:"
+    arr.each do |match|
+      puts "\t line #{match[0]}: '#{match[1]}'"
+    end
+  end
+

[Source]

-
+ onclick="toggleCode('M000101-source');return false;">[Source]

+
-# File lib/git/base.rb, line 153
+# File lib/git/base.rb, line 202
     def grep(string)
       self.object('HEAD').grep(string)
     end
@@ -726,8 +814,8 @@ Alias for object
         
-
- +
+
gtree(objectish) @@ -735,26 +823,29 @@ Alias for object

-Alias for object +Alias for object

-
- +
+
+

+returns reference to the git index file +

[Source]

-
+ onclick="toggleCode('M000087-source');return false;">[Source]

+
-# File lib/git/base.rb, line 83
+# File lib/git/base.rb, line 89
     def index
       @index
     end
@@ -763,21 +854,27 @@ Alias for object
         
-
- +
+
+

+this is a convenience method for accessing the class that wraps all the +actual ‘git’ forked system calls. At some point I hope to +replace the Git::Lib class with one that uses native +methods or libgit C bindings +

[Source]

-
+ onclick="toggleCode('M000100-source');return false;">[Source]

+
-# File lib/git/base.rb, line 149
+# File lib/git/base.rb, line 179
     def lib
       Git::Lib.new(self)
     end
@@ -786,21 +883,24 @@ Alias for object
         
-
- +
+
+

+returns a Git::Log object with count commits +

[Source]

-
+ onclick="toggleCode('M000095-source');return false;">[Source]

+
-# File lib/git/base.rb, line 128
+# File lib/git/base.rb, line 152
     def log(count = 30)
       Git::Log.new(self, count)
     end
@@ -809,21 +909,28 @@ Alias for object
         
-
- +
+
+

+merges one or more branches into the current working branch +

+

+you can specify more than one branch to merge by passing an array of +branches +

[Source]

-
+ onclick="toggleCode('M000112-source');return false;">[Source]

+
-# File lib/git/base.rb, line 200
+# File lib/git/base.rb, line 268
     def merge(branch, message = 'merge')
       self.lib.merge(branch, message)
     end
@@ -832,24 +939,32 @@ Alias for object
         
-
- +
+

-factory methods +returns a Git::Object of the appropriate type you +can also call @git.gtree(‘tree’), but that’s just for +readability. If you call @git.gtree(‘HEAD’) it will still +return a Git::Object::Commit object. +

+

+@git.object calls a factory method that will run a rev-parse on the +objectish and determine the type of the object and return an appropriate +object for that type

[Source]

-
+ onclick="toggleCode('M000091-source');return false;">[Source]

+
-# File lib/git/base.rb, line 120
+# File lib/git/base.rb, line 144
     def object(objectish)
       Git::Object.new(self, objectish)
     end
@@ -858,21 +973,25 @@ factory methods
         
-
- +
+
+

+fetches a branch from a remote and merges it into the current working +branch +

[Source]

-
+ onclick="toggleCode('M000113-source');return false;">[Source]

+
-# File lib/git/base.rb, line 204
+# File lib/git/base.rb, line 273
     def pull(remote = 'origin', branch = 'master', message = 'origin pull')
       fetch(remote)
       merge(branch, message)
@@ -882,21 +1001,29 @@ factory methods
         
-
- +
+
+

+pushes changes to a remote repository - easiest if this is a cloned +repository, otherwise you may have to run something like this first to +setup the push parameters: +

+
+ @git.config('remote.remote-name.push', 'refs/heads/master:refs/heads/master')
+

[Source]

-
+ onclick="toggleCode('M000111-source');return false;">[Source]

+
-# File lib/git/base.rb, line 196
+# File lib/git/base.rb, line 261
     def push(remote = 'origin', branch = 'master')
       self.lib.push(remote, branch)
     end
@@ -905,21 +1032,24 @@ factory methods
         
-
- +
+
+

+returns a Git::Remote object +

[Source]

-
+ onclick="toggleCode('M000099-source');return false;">[Source]

+
-# File lib/git/base.rb, line 144
+# File lib/git/base.rb, line 172
     def remote(remote_name = 'origin')
       Git::Remote.new(self, remote_name)
     end
@@ -928,21 +1058,25 @@ factory methods
         
-
- +
+
+

+returns an array of Git:Remote objects +

[Source]

-
+ onclick="toggleCode('M000114-source');return false;">[Source]

+
-# File lib/git/base.rb, line 209
+# File lib/git/base.rb, line 279
     def remotes
       self.lib.remotes.map { |r| Git::Remote.new(self, r) }
     end
@@ -951,21 +1085,24 @@ factory methods
         
-
- +
+
+

+removes file(s) from the git repository +

[Source]

-
+ onclick="toggleCode('M000104-source');return false;">[Source]

+
-# File lib/git/base.rb, line 166
+# File lib/git/base.rb, line 217
     def remove(path = '.', opts = {})
       self.lib.remove(path, opts)
     end
@@ -974,24 +1111,24 @@ factory methods
         
-
- +
+

-convenience methods +repacks the repository

[Source]

-
+ onclick="toggleCode('M000119-source');return false;">[Source]

+
-# File lib/git/base.rb, line 236
+# File lib/git/base.rb, line 315
     def repack
       self.lib.repack
     end
@@ -1000,21 +1137,27 @@ convenience methods
         
-
- +
+
+

+returns reference to the git repository directory +

+
+ @git.dir.path
+

[Source]

-
+ onclick="toggleCode('M000086-source');return false;">[Source]

+
-# File lib/git/base.rb, line 79
+# File lib/git/base.rb, line 84
     def repo
       @repository
     end
@@ -1023,21 +1166,24 @@ convenience methods
         
-
- +
+
+

+returns the repository size in bytes +

[Source]

-
+ onclick="toggleCode('M000089-source');return false;">[Source]

+
-# File lib/git/base.rb, line 93
+# File lib/git/base.rb, line 109
     def repo_size
       size = 0
       Dir.chdir(repo.path) do
@@ -1050,21 +1196,24 @@ convenience methods
         
-
- +
+
+

+resets the working directory to the provided commitish +

[Source]

-
+ onclick="toggleCode('M000105-source');return false;">[Source]

+
-# File lib/git/base.rb, line 170
+# File lib/git/base.rb, line 222
     def reset(commitish = nil, opts = {})
       self.lib.reset(commitish, opts)
     end
@@ -1073,21 +1222,25 @@ convenience methods
         
-
- +
+
+

+resets the working directory to the commitish with +’—hard’ +

[Source]

-
+ onclick="toggleCode('M000106-source');return false;">[Source]

+
-# File lib/git/base.rb, line 174
+# File lib/git/base.rb, line 227
     def reset_hard(commitish = nil, opts = {})
       opts = {:hard => true}.merge(opts)
       self.lib.reset(commitish, opts)
@@ -1097,21 +1250,29 @@ convenience methods
         
-
- +
+
+

+runs git rev-parse to convert the objectish to a full sha +

+
+  @git.revparse("HEAD^^")
+  @git.revparse('v2.4^{tree}')
+  @git.revparse('v2.4:/doc/index.html')
+

[Source]

-
+ onclick="toggleCode('M000120-source');return false;">[Source]

+
-# File lib/git/base.rb, line 240
+# File lib/git/base.rb, line 325
     def revparse(objectish)
       self.lib.revparse(objectish)
     end
@@ -1120,21 +1281,24 @@ convenience methods
         
-
- +
+
+

+returns a Git::Status object +

[Source]

-
+ onclick="toggleCode('M000096-source');return false;">[Source]

+
-# File lib/git/base.rb, line 132
+# File lib/git/base.rb, line 157
     def status
       Git::Status.new(self)
     end
@@ -1143,21 +1307,24 @@ convenience methods
         
-
- +
+
+

+returns a Git::Tag object +

[Source]

-
+ onclick="toggleCode('M000117-source');return false;">[Source]

+
-# File lib/git/base.rb, line 225
+# File lib/git/base.rb, line 304
     def tag(tag_name)
       Git::Object.new(self, tag_name, true)
     end
@@ -1166,21 +1333,24 @@ convenience methods
         
-
- +
+
+

+returns an array of all Git::Tag objects for this repository +

[Source]

-
+ onclick="toggleCode('M000116-source');return false;">[Source]

+
-# File lib/git/base.rb, line 221
+# File lib/git/base.rb, line 299
     def tags
       self.lib.tags.map { |r| tag(r) }
     end
diff --git a/doc/classes/Git/Branch.html b/doc/classes/Git/Branch.html
index 4fb476d..9b392fd 100644
--- a/doc/classes/Git/Branch.html
+++ b/doc/classes/Git/Branch.html
@@ -88,16 +88,16 @@
       

Methods

- checkout   - create   - current   - delete   - gcommit   - in_branch   - merge   - new   - to_a   - to_s   + checkout   + create   + current   + delete   + gcommit   + in_branch   + merge   + new   + to_a   + to_s  
@@ -142,19 +142,19 @@

Public Class methods

-
- +
+

[Source]

-
+ onclick="toggleCode('M000070-source');return false;">[Source]

+
 # File lib/git/branch.rb, line 9
     def initialize(base, name)
@@ -177,19 +177,19 @@
 
       

Public Instance methods

-
- +
+

[Source]

-
+ onclick="toggleCode('M000072-source');return false;">[Source]

+
 # File lib/git/branch.rb, line 28
     def checkout
@@ -201,19 +201,19 @@
         
-
- +
+

[Source]

-
+ onclick="toggleCode('M000074-source');return false;">[Source]

+
 # File lib/git/branch.rb, line 50
     def create
@@ -224,19 +224,19 @@
         
-
- +
+

[Source]

-
+ onclick="toggleCode('M000076-source');return false;">[Source]

+
 # File lib/git/branch.rb, line 58
     def current
@@ -247,19 +247,19 @@
         
-
- +
+

[Source]

-
+ onclick="toggleCode('M000075-source');return false;">[Source]

+
 # File lib/git/branch.rb, line 54
     def delete
@@ -270,19 +270,19 @@
         
-
- +
+

[Source]

-
+ onclick="toggleCode('M000071-source');return false;">[Source]

+
 # File lib/git/branch.rb, line 23
     def gcommit
@@ -294,11 +294,11 @@
         
-
- +
+ @@ -306,7 +306,7 @@

g.branch(‘new_branch’).in_branch do +href="Branch.html#M000073">in_branch do

   # create new file
@@ -317,8 +317,8 @@ href="Branch.html#M000070">in_branch do
 end
 

[Source]

-
+ onclick="toggleCode('M000073-source');return false;">[Source]

+
 # File lib/git/branch.rb, line 39
     def in_branch (message = 'in branch work')
@@ -336,19 +336,19 @@ end
         
-
- +
+

[Source]

-
+ onclick="toggleCode('M000077-source');return false;">[Source]

+
 # File lib/git/branch.rb, line 62
     def merge(branch = nil, message = nil)
@@ -368,19 +368,19 @@ end
         
-
- +
+

[Source]

-
+ onclick="toggleCode('M000078-source');return false;">[Source]

+
 # File lib/git/branch.rb, line 75
     def to_a
@@ -391,19 +391,19 @@ end
         
-
- +
+

[Source]

-
+ onclick="toggleCode('M000079-source');return false;">[Source]

+
 # File lib/git/branch.rb, line 79
     def to_s
diff --git a/doc/classes/Git/Branches.html b/doc/classes/Git/Branches.html
index c9f9f7e..e812dd6 100644
--- a/doc/classes/Git/Branches.html
+++ b/doc/classes/Git/Branches.html
@@ -94,12 +94,12 @@ object that holds all the available branches
       

Methods

- []   - each   - local   - new   - remote   - size   + []   + each   + local   + new   + remote   + size  
@@ -128,19 +128,19 @@ object that holds all the available branches

Public Class methods

-
- +
+

[Source]

-
+ onclick="toggleCode('M000064-source');return false;">[Source]

+
 # File lib/git/branches.rb, line 10
     def initialize(base)
@@ -159,19 +159,19 @@ object that holds all the available branches
 
       

Public Instance methods

-
- +
+

[Source]

-
+ onclick="toggleCode('M000069-source');return false;">[Source]

+
 # File lib/git/branches.rb, line 40
     def [](symbol)
@@ -182,19 +182,19 @@ object that holds all the available branches
         
-
- +
+

[Source]

-
+ onclick="toggleCode('M000068-source');return false;">[Source]

+
 # File lib/git/branches.rb, line 34
     def each
@@ -207,19 +207,19 @@ object that holds all the available branches
         
-
- +
+

[Source]

-
+ onclick="toggleCode('M000065-source');return false;">[Source]

+
 # File lib/git/branches.rb, line 20
     def local
@@ -230,19 +230,19 @@ object that holds all the available branches
         
-
- +
+

[Source]

-
+ onclick="toggleCode('M000066-source');return false;">[Source]

+
 # File lib/git/branches.rb, line 24
     def remote
@@ -253,11 +253,11 @@ object that holds all the available branches
         
-
- +
+ @@ -267,8 +267,8 @@ object that holds all the available branches array like methods

[Source]

-
+ onclick="toggleCode('M000067-source');return false;">[Source]

+
 # File lib/git/branches.rb, line 30
     def size
diff --git a/doc/classes/Git/Diff.html b/doc/classes/Git/Diff.html
index a57584c..63ebee2 100644
--- a/doc/classes/Git/Diff.html
+++ b/doc/classes/Git/Diff.html
@@ -94,17 +94,17 @@ object that holds the last X commits on given branch
       

Methods

- []   - deletions   - each   - insertions   - lines   - new   - patch   - path   - size   - stats   - to_s   + []   + deletions   + each   + insertions   + lines   + new   + patch   + path   + size   + stats   + to_s  
@@ -139,19 +139,19 @@ object that holds the last X commits on given branch

Public Class methods

-
- +
+

[Source]

-
+ onclick="toggleCode('M000153-source');return false;">[Source]

+
 # File lib/git/diff.rb, line 16
     def initialize(base, from = nil, to = nil)
@@ -166,11 +166,11 @@ object that holds the last X commits on given branch
 
       

Public Instance methods

-
- +
+ @@ -180,8 +180,8 @@ object that holds the last X commits on given branch enumerable methods

[Source]

-
+ onclick="toggleCode('M000162-source');return false;">[Source]

+
 # File lib/git/diff.rb, line 61
     def [](key)
@@ -193,19 +193,19 @@ enumerable methods
         
-
- +
+

[Source]

-
+ onclick="toggleCode('M000157-source');return false;">[Source]

+
 # File lib/git/diff.rb, line 37
     def deletions
@@ -217,19 +217,19 @@ enumerable methods
         
-
- +
+

[Source]

-
+ onclick="toggleCode('M000163-source');return false;">[Source]

+
 # File lib/git/diff.rb, line 66
     def each
@@ -243,19 +243,19 @@ enumerable methods
         
-
- +
+

[Source]

-
+ onclick="toggleCode('M000158-source');return false;">[Source]

+
 # File lib/git/diff.rb, line 42
     def insertions
@@ -267,19 +267,19 @@ enumerable methods
         
-
- +
+

[Source]

-
+ onclick="toggleCode('M000156-source');return false;">[Source]

+
 # File lib/git/diff.rb, line 32
     def lines
@@ -291,11 +291,11 @@ enumerable methods
         
-
- +
+ @@ -305,8 +305,8 @@ enumerable methods if file is provided and is writable, it will write the patch into the file

[Source]

-
+ onclick="toggleCode('M000160-source');return false;">[Source]

+
 # File lib/git/diff.rb, line 53
     def patch(file = nil)
@@ -318,19 +318,19 @@ if file is provided and is writable, it will write the patch into the file
         
-
- +
+

[Source]

-
+ onclick="toggleCode('M000154-source');return false;">[Source]

+
 # File lib/git/diff.rb, line 22
     def path(path)
@@ -342,19 +342,19 @@ if file is provided and is writable, it will write the patch into the file
         
-
- +
+

[Source]

-
+ onclick="toggleCode('M000155-source');return false;">[Source]

+
 # File lib/git/diff.rb, line 27
     def size
@@ -366,19 +366,19 @@ if file is provided and is writable, it will write the patch into the file
         
-
- +
+

[Source]

-
+ onclick="toggleCode('M000159-source');return false;">[Source]

+
 # File lib/git/diff.rb, line 47
     def stats
@@ -390,8 +390,8 @@ if file is provided and is writable, it will write the patch into the file
         
-
- +
+
to_s(file = nil) @@ -399,7 +399,7 @@ if file is provided and is writable, it will write the patch into the file

-Alias for patch +Alias for patch

diff --git a/doc/classes/Git/Diff/DiffFile.html b/doc/classes/Git/Diff/DiffFile.html index f13fd79..39139e5 100644 --- a/doc/classes/Git/Diff/DiffFile.html +++ b/doc/classes/Git/Diff/DiffFile.html @@ -86,8 +86,8 @@

Methods

- blob   - new   + blob   + new  
@@ -147,19 +147,19 @@

Public Class methods

-
- +
+

[Source]

-
+ onclick="toggleCode('M000164-source');return false;">[Source]

+
 # File lib/git/diff.rb, line 77
       def initialize(base, hash)
@@ -178,19 +178,19 @@
 
       

Public Instance methods

-
- +
+

[Source]

-
+ onclick="toggleCode('M000165-source');return false;">[Source]

+
 # File lib/git/diff.rb, line 87
       def blob(type = :dst)
diff --git a/doc/classes/Git/Lib.html b/doc/classes/Git/Lib.html
index bb507b4..9c4992e 100644
--- a/doc/classes/Git/Lib.html
+++ b/doc/classes/Git/Lib.html
@@ -88,43 +88,45 @@
       

Methods

- add   - branch_current   - branch_delete   - branch_new   - branches_all   - checkout   - clone   - commit   - config_get   - config_list   - config_remote   - config_set   - diff_files   - diff_full   - diff_index   - diff_stats   - fetch   - grep   - init   - log_commits   - ls_files   - merge   - new   - object_contents   - object_size   - object_type   - push   - remote_add   - remote_remove   - remotes   - remove   - repack   - reset   - revparse   - tag   - tag_sha   - tags   + add   + branch_current   + branch_delete   + branch_new   + branches_all   + checkout   + clone   + commit   + commit_data   + config_get   + config_list   + config_remote   + config_set   + diff_files   + diff_full   + diff_index   + diff_stats   + fetch   + grep   + init   + log_commits   + ls_files   + ls_tree   + merge   + new   + object_contents   + object_size   + object_type   + push   + remote_add   + remote_remove   + remotes   + remove   + repack   + reset   + revparse   + tag   + tag_sha   + tags  
@@ -146,19 +148,19 @@

Public Class methods

-
- +
+

[Source]

-
+ onclick="toggleCode('M000025-source');return false;">[Source]

+
 # File lib/git/lib.rb, line 13
     def initialize(base = nil)
@@ -179,21 +181,21 @@
 
       

Public Instance methods

-
- +
+

[Source]

-
+ onclick="toggleCode('M000047-source');return false;">[Source]

+
-# File lib/git/lib.rb, line 215
+# File lib/git/lib.rb, line 251
     def add(path = '.')
       path = path.join(' ') if path.is_a?(Array)
       command('add', path)
@@ -203,21 +205,21 @@
         
-
- +
+

[Source]

-
+ onclick="toggleCode('M000036-source');return false;">[Source]

+
-# File lib/git/lib.rb, line 96
+# File lib/git/lib.rb, line 132
     def branch_current
       branches_all.select { |b| b[1] }.first[0] rescue nil
     end
@@ -226,21 +228,21 @@
         
-
- +
+

[Source]

-
+ onclick="toggleCode('M000052-source');return false;">[Source]

+
-# File lib/git/lib.rb, line 248
+# File lib/git/lib.rb, line 284
     def branch_delete(branch)
       command('branch', ['-d', branch])
     end
@@ -249,21 +251,21 @@
         
-
- +
+

[Source]

-
+ onclick="toggleCode('M000051-source');return false;">[Source]

+
-# File lib/git/lib.rb, line 244
+# File lib/git/lib.rb, line 280
     def branch_new(branch)
       command('branch', branch)
     end
@@ -272,21 +274,21 @@
         
-
- +
+

[Source]

-
+ onclick="toggleCode('M000035-source');return false;">[Source]

+
-# File lib/git/lib.rb, line 86
+# File lib/git/lib.rb, line 122
     def branches_all
       arr = []
       command_lines('branch', '-a').each do |b| 
@@ -301,21 +303,21 @@
         
-
- +
+

[Source]

-
+ onclick="toggleCode('M000053-source');return false;">[Source]

+
-# File lib/git/lib.rb, line 252
+# File lib/git/lib.rb, line 288
     def checkout(branch, opts = {})
       arr_opts = []
       arr_opts << '-f' if opts[:force]
@@ -328,11 +330,11 @@
         
-
- +
+ @@ -358,8 +360,8 @@ accepts options: TODO - make this work with SSH password or auth_key

[Source]

-
+ onclick="toggleCode('M000027-source');return false;">[Source]

+
 # File lib/git/lib.rb, line 40
     def clone(repository, name, opts = {})
@@ -381,21 +383,21 @@ TODO - make this work with SSH password or auth_key
         
-
- +
+

[Source]

-
+ onclick="toggleCode('M000049-source');return false;">[Source]

+
-# File lib/git/lib.rb, line 230
+# File lib/git/lib.rb, line 266
     def commit(message, opts = {})
       arr_opts = ["-m '#{message}'"]
       arr_opts << '-a' if opts[:add_all]
@@ -406,21 +408,68 @@ TODO - make this work with SSH password or auth_key
         
-
- +
+ + +
+

+returns useful array of raw commit object data +

+

[Source]

+
+
+# File lib/git/lib.rb, line 83
+    def commit_data(sha)
+      in_message = false
+      
+      hsh = {'message' => '', 'parent' => []}
+      command_lines('cat-file', ['commit', sha.to_s]).each do |line|
+        if in_message
+          hsh['message'] += line + "\n"
+        end
+        
+        if (line != '') && !in_message
+          data = line.split
+          key = data.shift
+          value = data.join(' ')
+          if key == 'parent'
+            hsh[key] << value
+          else
+            hsh[key] = value
+          end
+        else
+          in_message = true
+        end
+      end
+      hsh
+    end
+
+
+
+
+ +
+ + +

[Source]

-
+ onclick="toggleCode('M000044-source');return false;">[Source]

+
-# File lib/git/lib.rb, line 196
+# File lib/git/lib.rb, line 232
     def config_get(name)
       command('config', ['--get', name])
     end
@@ -429,21 +478,21 @@ TODO - make this work with SSH password or auth_key
         
-
- +
+

[Source]

-
+ onclick="toggleCode('M000045-source');return false;">[Source]

+
-# File lib/git/lib.rb, line 200
+# File lib/git/lib.rb, line 236
     def config_list
       hsh = {}
       command_lines('config', ['--list']).each do |line|
@@ -457,21 +506,21 @@ TODO - make this work with SSH password or auth_key
         
-
- +
+

[Source]

-
+ onclick="toggleCode('M000043-source');return false;">[Source]

+
-# File lib/git/lib.rb, line 187
+# File lib/git/lib.rb, line 223
     def config_remote(name)
       hsh = {}
       command_lines('config', ['--get-regexp', "remote.#{name}"]).each do |line|
@@ -485,11 +534,11 @@ TODO - make this work with SSH password or auth_key
         
-
- +
+ @@ -499,10 +548,10 @@ TODO - make this work with SSH password or auth_key WRITE COMMANDS ##

[Source]

-
+ onclick="toggleCode('M000046-source');return false;">[Source]

+
-# File lib/git/lib.rb, line 211
+# File lib/git/lib.rb, line 247
     def config_set(name, value)
       command('config', [name, "'#{value}'"])
     end
@@ -511,11 +560,11 @@ WRITE COMMANDS ##
         
-
- +
+ @@ -525,10 +574,10 @@ WRITE COMMANDS ## compares the index and the working directory

[Source]

-
+ onclick="toggleCode('M000040-source');return false;">[Source]

+
-# File lib/git/lib.rb, line 153
+# File lib/git/lib.rb, line 189
     def diff_files
       hsh = {}
       command_lines('diff-files').each do |line|
@@ -544,21 +593,21 @@ compares the index and the working directory
         
-
- +
+

[Source]

-
+ onclick="toggleCode('M000038-source');return false;">[Source]

+
-# File lib/git/lib.rb, line 123
+# File lib/git/lib.rb, line 159
     def diff_full(obj1 = 'HEAD', obj2 = nil, opts = {})
       diff_opts = ['-p']
       diff_opts << obj1
@@ -572,11 +621,11 @@ compares the index and the working directory
         
-
- +
+ @@ -586,10 +635,10 @@ compares the index and the working directory compares the index and the repository

[Source]

-
+ onclick="toggleCode('M000041-source');return false;">[Source]

+
-# File lib/git/lib.rb, line 165
+# File lib/git/lib.rb, line 201
     def diff_index(treeish)
       hsh = {}
       command_lines('diff-index', treeish).each do |line|
@@ -605,21 +654,21 @@ compares the index and the repository
         
-
- +
+

[Source]

-
+ onclick="toggleCode('M000039-source');return false;">[Source]

+
-# File lib/git/lib.rb, line 132
+# File lib/git/lib.rb, line 168
     def diff_stats(obj1 = 'HEAD', obj2 = nil, opts = {})
       diff_opts = ['--numstat']
       diff_opts << obj1
@@ -644,21 +693,21 @@ compares the index and the repository
         
-
- +
+

[Source]

-
+ onclick="toggleCode('M000060-source');return false;">[Source]

+
-# File lib/git/lib.rb, line 295
+# File lib/git/lib.rb, line 331
     def fetch(remote)
       command('fetch', remote.to_s)
     end
@@ -667,11 +716,11 @@ compares the index and the repository
         
-
- +
+ @@ -689,10 +738,10 @@ returns hash

[Source]

-
+ onclick="toggleCode('M000037-source');return false;">[Source]

+
-# File lib/git/lib.rb, line 104
+# File lib/git/lib.rb, line 140
     def grep(string, opts = {})
       opts[:object] = 'HEAD' if !opts[:object]
 
@@ -716,19 +765,19 @@ returns hash
         
-
- +
+

[Source]

-
+ onclick="toggleCode('M000026-source');return false;">[Source]

+
 # File lib/git/lib.rb, line 25
     def init
@@ -739,11 +788,11 @@ returns hash
         
-
- +
+ @@ -753,8 +802,8 @@ returns hash READ COMMANDS ##

[Source]

-
+ onclick="toggleCode('M000028-source');return false;">[Source]

+
 # File lib/git/lib.rb, line 59
     def log_commits(opts = {})
@@ -772,21 +821,21 @@ READ COMMANDS ##
         
-
- +
+

[Source]

-
+ onclick="toggleCode('M000042-source');return false;">[Source]

+
-# File lib/git/lib.rb, line 176
+# File lib/git/lib.rb, line 212
     def ls_files
       hsh = {}
       command_lines('ls-files', '--stage').each do |line|
@@ -801,21 +850,50 @@ READ COMMANDS ##
         
-
- +
+ + +
+

[Source]

+
+
+# File lib/git/lib.rb, line 112
+    def ls_tree(sha)
+      data = {'blob' => {}, 'tree' => {}}
+      command_lines('ls-tree', sha.to_s).each do |line|
+        (info, filenm) = line.split("\t")
+        (mode, type, sha) = info.split
+        data[type][filenm] = {:mode => mode, :sha => sha}
+      end
+      data
+    end
+
+
+
+
+ +
+ + +

[Source]

-
+ onclick="toggleCode('M000054-source');return false;">[Source]

+
-# File lib/git/lib.rb, line 260
+# File lib/git/lib.rb, line 296
     def merge(branch, message = nil)      
       arr_opts = []
       arr_opts << ["-m '#{message}'"] if message
@@ -827,21 +905,21 @@ READ COMMANDS ##
         
-
- +
+

[Source]

-
+ onclick="toggleCode('M000033-source');return false;">[Source]

+
-# File lib/git/lib.rb, line 82
+# File lib/git/lib.rb, line 108
     def object_contents(sha)
       command('cat-file', ['-p', sha])
     end
@@ -850,19 +928,19 @@ READ COMMANDS ##
         
-
- +
+

[Source]

-
+ onclick="toggleCode('M000031-source');return false;">[Source]

+
 # File lib/git/lib.rb, line 78
     def object_size(sha)
@@ -873,19 +951,19 @@ READ COMMANDS ##
         
-
- +
+

[Source]

-
+ onclick="toggleCode('M000030-source');return false;">[Source]

+
 # File lib/git/lib.rb, line 74
     def object_type(sha)
@@ -896,21 +974,21 @@ READ COMMANDS ##
         
-
- +
+

[Source]

-
+ onclick="toggleCode('M000061-source');return false;">[Source]

+
-# File lib/git/lib.rb, line 299
+# File lib/git/lib.rb, line 335
     def push(remote, branch = 'master')
       command('push', [remote.to_s, branch.to_s])
     end
@@ -919,21 +997,21 @@ READ COMMANDS ##
         
-
- +
+

[Source]

-
+ onclick="toggleCode('M000055-source');return false;">[Source]

+
-# File lib/git/lib.rb, line 267
+# File lib/git/lib.rb, line 303
     def remote_add(name, url, opts = {})
       arr_opts = ['add']
       arr_opts << '-f' if opts[:with_fetch]
@@ -947,11 +1025,11 @@ READ COMMANDS ##
         
-
- +
+ @@ -962,10 +1040,10 @@ this is documented as such, but seems broken for some reason i’ll try to get around it some other way later

[Source]

-
+ onclick="toggleCode('M000056-source');return false;">[Source]

+
-# File lib/git/lib.rb, line 278
+# File lib/git/lib.rb, line 314
     def remote_remove(name)
       command('remote', ['rm', name])
     end
@@ -974,21 +1052,21 @@ to get around it some other way later
         
-
- +
+

[Source]

-
+ onclick="toggleCode('M000057-source');return false;">[Source]

+
-# File lib/git/lib.rb, line 282
+# File lib/git/lib.rb, line 318
     def remotes
       command_lines('remote')
     end
@@ -997,21 +1075,21 @@ to get around it some other way later
         
-
- +
+

[Source]

-
+ onclick="toggleCode('M000048-source');return false;">[Source]

+
-# File lib/git/lib.rb, line 220
+# File lib/git/lib.rb, line 256
     def remove(path = '.', opts = {})
       path = path.join(' ') if path.is_a?(Array)
 
@@ -1026,21 +1104,21 @@ to get around it some other way later
         
-
- +
+

[Source]

-
+ onclick="toggleCode('M000063-source');return false;">[Source]

+
-# File lib/git/lib.rb, line 307
+# File lib/git/lib.rb, line 343
     def repack
       command('repack', ['-a', '-d'])
     end
@@ -1049,21 +1127,21 @@ to get around it some other way later
         
-
- +
+

[Source]

-
+ onclick="toggleCode('M000050-source');return false;">[Source]

+
-# File lib/git/lib.rb, line 236
+# File lib/git/lib.rb, line 272
     def reset(commit, opts = {})
       arr_opts = []
       arr_opts << '--hard' if opts[:hard]
@@ -1075,19 +1153,19 @@ to get around it some other way later
         
-
- +
+

[Source]

-
+ onclick="toggleCode('M000029-source');return false;">[Source]

+
 # File lib/git/lib.rb, line 70
     def revparse(string)
@@ -1098,21 +1176,21 @@ to get around it some other way later
         
-
- +
+

[Source]

-
+ onclick="toggleCode('M000059-source');return false;">[Source]

+
-# File lib/git/lib.rb, line 290
+# File lib/git/lib.rb, line 326
     def tag(tag)
       command('tag', tag)
     end
@@ -1121,21 +1199,21 @@ to get around it some other way later
         
-
- +
+

[Source]

-
+ onclick="toggleCode('M000062-source');return false;">[Source]

+
-# File lib/git/lib.rb, line 303
+# File lib/git/lib.rb, line 339
     def tag_sha(tag_name)
       command('show-ref',  ['--tags', '-s', tag_name])
     end
@@ -1144,21 +1222,21 @@ to get around it some other way later
         
-
- +
+

[Source]

-
+ onclick="toggleCode('M000058-source');return false;">[Source]

+
-# File lib/git/lib.rb, line 286
+# File lib/git/lib.rb, line 322
     def tags
       command_lines('tag')
     end
diff --git a/doc/classes/Git/Object.html b/doc/classes/Git/Object.html
index d6d12f1..cde1e7d 100644
--- a/doc/classes/Git/Object.html
+++ b/doc/classes/Git/Object.html
@@ -80,6 +80,12 @@
 
   
+
+

+represents a git object +

+ +
@@ -88,7 +94,7 @@

Methods

- new   + new  
@@ -120,11 +126,11 @@ Class Git::Object::Tree

Public Class methods

-
- +
+ @@ -135,10 +141,10 @@ if we’re calling this, we don’t know what type it is yet so this is our little factory method

[Source]

-
+ onclick="toggleCode('M000125-source');return false;">[Source]

+
-# File lib/git/object.rb, line 87
+# File lib/git/object.rb, line 206
       def new(base, objectish, is_tag = false)
         if is_tag
           sha = base.lib.tag_sha(objectish)
diff --git a/doc/classes/Git/Object/AbstractObject.html b/doc/classes/Git/Object/AbstractObject.html
index 10d0080..222bc67 100644
--- a/doc/classes/Git/Object/AbstractObject.html
+++ b/doc/classes/Git/Object/AbstractObject.html
@@ -86,14 +86,14 @@
       

Methods

- contents   - contents_array   - diff   - grep   - log   - new   - setup   - to_s   + contents   + contents_array   + diff   + grep   + log   + new   + setup   + to_s  
@@ -143,24 +143,24 @@

Public Class methods

-
- +
+

[Source]

-
+ onclick="toggleCode('M000136-source');return false;">[Source]

+
-# File lib/git/object.rb, line 13
+# File lib/git/object.rb, line 14
       def initialize(base, sha)
         @base = base
-        @sha = sha
+        @sha = sha.to_s
         @size = @base.lib.object_size(@sha)
         setup
       end
@@ -171,21 +171,21 @@
 
       

Public Instance methods

-
- +
+

[Source]

-
+ onclick="toggleCode('M000137-source');return false;">[Source]

+
-# File lib/git/object.rb, line 20
+# File lib/git/object.rb, line 21
       def contents
         @base.lib.object_contents(@sha)
       end
@@ -194,21 +194,21 @@
         
-
- +
+

[Source]

-
+ onclick="toggleCode('M000138-source');return false;">[Source]

+
-# File lib/git/object.rb, line 24
+# File lib/git/object.rb, line 25
       def contents_array
         self.contents.split("\n")
       end
@@ -217,21 +217,21 @@
         
-
- +
+

[Source]

-
+ onclick="toggleCode('M000142-source');return false;">[Source]

+
-# File lib/git/object.rb, line 42
+# File lib/git/object.rb, line 43
       def diff(objectish)
         Git::Diff.new(@base, @sha, objectish)
       end
@@ -240,21 +240,21 @@
         
-
- +
+

[Source]

-
+ onclick="toggleCode('M000141-source');return false;">[Source]

+
-# File lib/git/object.rb, line 36
+# File lib/git/object.rb, line 37
       def grep(string, path_limiter = nil, opts = {})
         default = {:object => @sha, :path_limiter => path_limiter}
         grep_options = default.merge(opts)
@@ -265,21 +265,21 @@
         
-
- +
+

[Source]

-
+ onclick="toggleCode('M000143-source');return false;">[Source]

+
-# File lib/git/object.rb, line 46
+# File lib/git/object.rb, line 47
       def log(count = 30)
         Git::Log.new(@base, count).object(@sha)
       end
@@ -288,21 +288,21 @@
         
-
- +
+

[Source]

-
+ onclick="toggleCode('M000139-source');return false;">[Source]

+
-# File lib/git/object.rb, line 28
+# File lib/git/object.rb, line 29
       def setup
         raise NotImplementedError
       end
@@ -311,21 +311,21 @@
         
-
- +
+

[Source]

-
+ onclick="toggleCode('M000140-source');return false;">[Source]

+
-# File lib/git/object.rb, line 32
+# File lib/git/object.rb, line 33
       def to_s
         @sha
       end
diff --git a/doc/classes/Git/Object/Blob.html b/doc/classes/Git/Object/Blob.html
index a3fcb39..453a324 100644
--- a/doc/classes/Git/Object/Blob.html
+++ b/doc/classes/Git/Object/Blob.html
@@ -88,7 +88,7 @@
       

Methods

- setup   + new  
@@ -108,25 +108,26 @@
-

Public Instance methods

+

Public Class methods

-
- +
+

[Source]

-
+ onclick="toggleCode('M000145-source');return false;">[Source]

+
-# File lib/git/object.rb, line 54
-      def setup
-        @type = 'blob'
+# File lib/git/object.rb, line 56
+      def initialize(base, sha, mode = nil)
+        super(base, sha)
+        @mode = mode
       end
 
diff --git a/doc/classes/Git/Object/Commit.html b/doc/classes/Git/Object/Commit.html index 2f1e595..3be4f27 100644 --- a/doc/classes/Git/Object/Commit.html +++ b/doc/classes/Git/Object/Commit.html @@ -88,7 +88,16 @@

Methods

- setup   + author   + author_date   + committer   + committer_date   + date   + diff_parent   + gtree   + message   + parent   + parents  
@@ -110,23 +119,235 @@

Public Instance methods

-
- +
+
+

+git author +

[Source]

-
+ onclick="toggleCode('M000130-source');return false;">[Source]

+
-# File lib/git/object.rb, line 66
-      def setup
-        @type = 'commit'
+# File lib/git/object.rb, line 143
+      def author     
+        check_commit
+        @author
+      end
+
+
+
+
+ +
+ + + + +
+

[Source]

+
+
+# File lib/git/object.rb, line 148
+      def author_date
+        author.date
+      end
+
+
+
+
+ +
+ + + + +
+

+git author +

+

[Source]

+
+
+# File lib/git/object.rb, line 153
+      def committer
+        check_commit
+        @committer
+      end
+
+
+
+
+ +
+ + + + +
+

[Source]

+
+
+# File lib/git/object.rb, line 158
+      def committer_date 
+        committer.date
+      end
+
+
+
+
+ +
+ + +
+ date() +
+ +
+

+Alias for committer_date +

+
+
+ +
+ + + + +
+

[Source]

+
+
+# File lib/git/object.rb, line 163
+      def diff_parent
+        diff(parent)
+      end
+
+
+
+
+ +
+ + + + +
+

[Source]

+
+
+# File lib/git/object.rb, line 127
+      def gtree
+        check_commit
+        Tree.new(@base, @tree)
+      end
+
+
+
+
+ +
+ + + + +
+

[Source]

+
+
+# File lib/git/object.rb, line 122
+      def message
+        check_commit
+        @message
+      end
+
+
+
+
+ +
+ + + + +
+

[Source]

+
+
+# File lib/git/object.rb, line 132
+      def parent
+        parents.first
+      end
+
+
+
+
+ +
+ + + + +
+

+array of all parent commits +

+

[Source]

+
+
+# File lib/git/object.rb, line 137
+      def parents
+        check_commit
+        @parents        
       end
 
diff --git a/doc/classes/Git/Object/Tag.html b/doc/classes/Git/Object/Tag.html index 260b4c4..799baaa 100644 --- a/doc/classes/Git/Object/Tag.html +++ b/doc/classes/Git/Object/Tag.html @@ -88,8 +88,7 @@

Methods

- new   - setup   + new  
@@ -124,21 +123,21 @@

Public Class methods

-
- +
+

[Source]

-
+ onclick="toggleCode('M000144-source');return false;">[Source]

+
-# File lib/git/object.rb, line 74
+# File lib/git/object.rb, line 190
       def initialize(base, sha, name)
         super(base, sha)
         @name = name
@@ -148,31 +147,6 @@
         
-

Public Instance methods

- -
- - - - -
-

[Source]

-
-
-# File lib/git/object.rb, line 79
-      def setup
-        @type = 'tag'
-      end
-
-
-
-
-
diff --git a/doc/classes/Git/Object/Tree.html b/doc/classes/Git/Object/Tree.html index 4d681e8..72a8a61 100644 --- a/doc/classes/Git/Object/Tree.html +++ b/doc/classes/Git/Object/Tree.html @@ -88,7 +88,13 @@

Methods

- setup   + blobs   + children   + files   + new   + subdirectories   + subtrees   + trees  
@@ -108,25 +114,141 @@
+

Public Class methods

+ +
+ + + + +
+

[Source]

+
+
+# File lib/git/object.rb, line 73
+      def initialize(base, sha, mode = nil)
+        super(base, sha)
+        @mode = mode
+      end
+
+
+
+
+

Public Instance methods

-
- +
+ + + + +
+

[Source]

+
+
+# File lib/git/object.rb, line 82
+      def blobs
+        check_tree
+        @blobs
+      end
+
+
+
+
+ +
+ + + + +
+

[Source]

+
+
+# File lib/git/object.rb, line 78
+      def children
+        blobs.merge(subtrees)
+      end
+
+
+
+
+ +
+ + +
+ files() +
+ +
+

+Alias for blobs +

+
+
+ +
+ + +
+ subdirectories() +
+ +
+

+Alias for trees +

+
+
+ +
+ + +
+ subtrees() +
+ +
+

+Alias for trees +

+
+
+ +
+

[Source]

-
+ onclick="toggleCode('M000150-source');return false;">[Source]

+
-# File lib/git/object.rb, line 60
-      def setup
-        @type = 'tree'
+# File lib/git/object.rb, line 88
+      def trees
+        check_tree
+        @trees
       end
 
diff --git a/doc/classes/Git/Path.html b/doc/classes/Git/Path.html index 16f02af..1f49a3e 100644 --- a/doc/classes/Git/Path.html +++ b/doc/classes/Git/Path.html @@ -88,9 +88,9 @@

Methods

- new   - readable?   - writable?   + new   + readable?   + writable?  
@@ -125,19 +125,19 @@

Public Class methods

-
- +
+

[Source]

-
+ onclick="toggleCode('M000122-source');return false;">[Source]

+
 # File lib/git/path.rb, line 6
     def initialize(path, check_path = true)
@@ -154,19 +154,19 @@
 
       

Public Instance methods

-
- +
+

[Source]

-
+ onclick="toggleCode('M000123-source');return false;">[Source]

+
 # File lib/git/path.rb, line 14
     def readable?
@@ -177,19 +177,19 @@
         
-
- +
+

[Source]

-
+ onclick="toggleCode('M000124-source');return false;">[Source]

+
 # File lib/git/path.rb, line 18
     def writable?
diff --git a/doc/classes/Git/Remote.html b/doc/classes/Git/Remote.html
index bf59b38..ebe825f 100644
--- a/doc/classes/Git/Remote.html
+++ b/doc/classes/Git/Remote.html
@@ -88,13 +88,13 @@
       

Methods

- branch   - fetch   - merge   - new   - remove   - remove   - to_s   + branch   + fetch   + merge   + new   + remove   + remove   + to_s  
@@ -139,19 +139,19 @@

Public Class methods

-
- +
+

[Source]

-
+ onclick="toggleCode('M000166-source');return false;">[Source]

+
 # File lib/git/remote.rb, line 8
     def initialize(base, name)
@@ -168,19 +168,19 @@
 
       

Public Instance methods

-
- +
+

[Source]

-
+ onclick="toggleCode('M000170-source');return false;">[Source]

+
 # File lib/git/remote.rb, line 29
     def branch(branch = 'master')
@@ -191,19 +191,19 @@
         
-
- +
+

[Source]

-
+ onclick="toggleCode('M000168-source');return false;">[Source]

+
 # File lib/git/remote.rb, line 20
     def fetch
@@ -214,11 +214,11 @@
         
-
- +
+ @@ -228,8 +228,8 @@ merge this remote locally

[Source]

-
+ onclick="toggleCode('M000169-source');return false;">[Source]

+
 # File lib/git/remote.rb, line 25
     def merge(branch = 'master')
@@ -240,19 +240,19 @@ merge this remote locally
         
-
- +
+

[Source]

-
+ onclick="toggleCode('M000167-source');return false;">[Source]

+
 # File lib/git/remote.rb, line 16
     def remove
@@ -263,19 +263,19 @@ merge this remote locally
         
-
- +
+

[Source]

-
+ onclick="toggleCode('M000171-source');return false;">[Source]

+
 # File lib/git/remote.rb, line 33
     def remove
@@ -286,19 +286,19 @@ merge this remote locally
         
-
- +
+

[Source]

-
+ onclick="toggleCode('M000172-source');return false;">[Source]

+
 # File lib/git/remote.rb, line 37
     def to_s
diff --git a/doc/created.rid b/doc/created.rid
index 21b2cf5..f9d24d4 100644
--- a/doc/created.rid
+++ b/doc/created.rid
@@ -1 +1 @@
-Mon Nov 12 11:08:01 PST 2007
+Tue Nov 13 07:35:28 PST 2007
diff --git a/doc/files/README.html b/doc/files/README.html
index 0a797bb..0832d66 100644
--- a/doc/files/README.html
+++ b/doc/files/README.html
@@ -56,7 +56,7 @@
     
     
       Last Update:
-      Mon Nov 12 11:07:58 PST 2007
+      Tue Nov 13 06:53:10 PST 2007
     
     
   
@@ -95,6 +95,39 @@ eventually I’ll replace that with either C bindings to libgit or libgit-thin, or I’ll write pure ruby handlers for at least some of the Git stuff.

+

Major Objects

+

+Git::Base - this is the object +returned from a Git.open or Git.clone. Most major actions are +called from this object. +

+

+Git::Object - this is the base +object for your tree, blob and commit objects, returned from @git.gtree or +@git.object calls. the Git::AbstractObject will have most of the calls in +common for all those objects. +

+

+Git::Diff - returns from a @git.diff +command. It is an Enumerable that returns Git::Diff:DiffFile objects from which +you can get per file patches and insertion/deletion statistics. You can +also get total statistics from the Git::Diff object directly. +

+

+Git::Status +

+

+Git::Branches +

+

+Git::Remote +

+

+Git::Log +

Examples

Here are a bunch of examples of how to use the Ruby/ + + + + + File: author.rb + + + + + + + + + + +

+ + +
+ + + +
+ + + +
+ + +
+ + + + +
+ + + + + + + + + + + +
+ + +
+ + + \ No newline at end of file diff --git a/doc/files/lib/git/base_rb.html b/doc/files/lib/git/base_rb.html index 980bf39..b88352c 100644 --- a/doc/files/lib/git/base_rb.html +++ b/doc/files/lib/git/base_rb.html @@ -56,7 +56,7 @@ Last Update: - Mon Nov 12 10:49:59 PST 2007 + Tue Nov 13 07:35:24 PST 2007
diff --git a/doc/files/lib/git/lib_rb.html b/doc/files/lib/git/lib_rb.html index ff92663..2462126 100644 --- a/doc/files/lib/git/lib_rb.html +++ b/doc/files/lib/git/lib_rb.html @@ -56,7 +56,7 @@ Last Update: - Mon Nov 12 10:50:14 PST 2007 + Mon Nov 12 17:40:54 PST 2007
diff --git a/doc/files/lib/git/object_rb.html b/doc/files/lib/git/object_rb.html index 8ea73f7..b1cfe7d 100644 --- a/doc/files/lib/git/object_rb.html +++ b/doc/files/lib/git/object_rb.html @@ -56,7 +56,7 @@ Last Update: - Sun Nov 11 15:59:01 PST 2007 + Tue Nov 13 06:37:18 PST 2007
diff --git a/doc/files/lib/git_rb.html b/doc/files/lib/git_rb.html index 8864d94..192691a 100644 --- a/doc/files/lib/git_rb.html +++ b/doc/files/lib/git_rb.html @@ -56,7 +56,7 @@ Last Update: - Mon Nov 12 10:59:30 PST 2007 + Tue Nov 13 07:04:48 PST 2007
@@ -93,6 +93,7 @@ isn’t there already. git/remote   git/diff   git/status   + git/author  
diff --git a/doc/fr_class_index.html b/doc/fr_class_index.html index 2d3002e..a668a74 100644 --- a/doc/fr_class_index.html +++ b/doc/fr_class_index.html @@ -21,6 +21,7 @@

Classes

Git
+ Git::Author
Git::Base
Git::Branch
Git::Branches
diff --git a/doc/fr_file_index.html b/doc/fr_file_index.html index c0e6c49..967c090 100644 --- a/doc/fr_file_index.html +++ b/doc/fr_file_index.html @@ -22,6 +22,7 @@
README
lib/git.rb
+ lib/git/author.rb
lib/git/base.rb
lib/git/branch.rb
lib/git/branches.rb
diff --git a/doc/fr_method_index.html b/doc/fr_method_index.html index 9cb8879..1c86105 100644 --- a/doc/fr_method_index.html +++ b/doc/fr_method_index.html @@ -20,161 +20,178 @@

Methods

- [] (Git::Branches)
[] (Git::Status)
- [] (Git::Diff)
- add (Git::Base)
- add (Git::Lib)
- add_remote (Git::Base)
- add_tag (Git::Base)
+ [] (Git::Branches)
+ [] (Git::Diff)
+ add (Git::Base)
+ add (Git::Lib)
+ add_remote (Git::Base)
+ add_tag (Git::Base)
added (Git::Status)
- bare (Git::Base)
+ author (Git::Object::Commit)
+ author_date (Git::Object::Commit)
+ bare (Git::Base)
bare (Git)
between (Git::Log)
- blob (Git::Diff::DiffFile)
blob (Git::Status::StatusFile)
- branch (Git::Remote)
- branch (Git::Base)
- branch_current (Git::Lib)
- branch_delete (Git::Lib)
- branch_new (Git::Lib)
- branches (Git::Base)
- branches_all (Git::Lib)
+ blob (Git::Diff::DiffFile)
+ blobs (Git::Object::Tree)
+ branch (Git::Remote)
+ branch (Git::Base)
+ branch_current (Git::Lib)
+ branch_delete (Git::Lib)
+ branch_new (Git::Lib)
+ branches (Git::Base)
+ branches_all (Git::Lib)
changed (Git::Status)
- chdir (Git::Base)
- checkout (Git::Branch)
- checkout (Git::Lib)
- checkout (Git::Base)
- clone (Git::Base)
+ chdir (Git::Base)
+ checkout (Git::Lib)
+ checkout (Git::Branch)
+ checkout (Git::Base)
+ children (Git::Object::Tree)
+ clone (Git::Lib)
+ clone (Git::Base)
clone (Git)
- clone (Git::Lib)
- commit (Git::Lib)
- commit (Git::Base)
- commit_all (Git::Base)
- config (Git::Base)
- config_get (Git::Lib)
- config_list (Git::Lib)
- config_remote (Git::Lib)
- config_set (Git::Lib)
- contents (Git::Object::AbstractObject)
- contents_array (Git::Object::AbstractObject)
- create (Git::Branch)
- current (Git::Branch)
- current_branch (Git::Base)
- delete (Git::Branch)
+ commit (Git::Base)
+ commit (Git::Lib)
+ commit_all (Git::Base)
+ commit_data (Git::Lib)
+ committer (Git::Object::Commit)
+ committer_date (Git::Object::Commit)
+ config (Git::Base)
+ config_get (Git::Lib)
+ config_list (Git::Lib)
+ config_remote (Git::Lib)
+ config_set (Git::Lib)
+ contents (Git::Object::AbstractObject)
+ contents_array (Git::Object::AbstractObject)
+ create (Git::Branch)
+ current (Git::Branch)
+ current_branch (Git::Base)
+ date (Git::Object::Commit)
+ delete (Git::Branch)
deleted (Git::Status)
- deletions (Git::Diff)
- diff (Git::Base)
- diff (Git::Object::AbstractObject)
- diff_files (Git::Lib)
- diff_full (Git::Lib)
- diff_index (Git::Lib)
- diff_stats (Git::Lib)
- dir (Git::Base)
- each (Git::Diff)
- each (Git::Branches)
- each (Git::Status)
+ deletions (Git::Diff)
+ diff (Git::Object::AbstractObject)
+ diff (Git::Base)
+ diff_files (Git::Lib)
+ diff_full (Git::Lib)
+ diff_index (Git::Lib)
+ diff_parent (Git::Object::Commit)
+ diff_stats (Git::Lib)
+ dir (Git::Base)
each (Git::Log)
- fetch (Git::Remote)
- fetch (Git::Lib)
- fetch (Git::Base)
+ each (Git::Diff)
+ each (Git::Status)
+ each (Git::Branches)
+ fetch (Git::Base)
+ fetch (Git::Remote)
+ fetch (Git::Lib)
+ files (Git::Object::Tree)
first (Git::Log)
- gblob (Git::Base)
- gcommit (Git::Branch)
- gcommit (Git::Base)
- grep (Git::Lib)
- grep (Git::Object::AbstractObject)
- grep (Git::Base)
- gtree (Git::Base)
- in_branch (Git::Branch)
- index (Git::Base)
- init (Git::Lib)
+ gblob (Git::Base)
+ gcommit (Git::Branch)
+ gcommit (Git::Base)
+ grep (Git::Base)
+ grep (Git::Lib)
+ grep (Git::Object::AbstractObject)
+ gtree (Git::Object::Commit)
+ gtree (Git::Base)
+ in_branch (Git::Branch)
+ index (Git::Base)
init (Git)
- init (Git::Base)
- insertions (Git::Diff)
- lib (Git::Base)
- lines (Git::Diff)
- local (Git::Branches)
- log (Git::Object::AbstractObject)
- log (Git::Base)
- log_commits (Git::Lib)
- ls_files (Git::Lib)
- merge (Git::Base)
- merge (Git::Lib)
- merge (Git::Branch)
- merge (Git::Remote)
- new (Git::Object::Tag)
+ init (Git::Base)
+ init (Git::Lib)
+ insertions (Git::Diff)
+ lib (Git::Base)
+ lines (Git::Diff)
+ local (Git::Branches)
+ log (Git::Object::AbstractObject)
+ log (Git::Base)
+ log_commits (Git::Lib)
+ ls_files (Git::Lib)
+ ls_tree (Git::Lib)
+ merge (Git::Base)
+ merge (Git::Remote)
+ merge (Git::Branch)
+ merge (Git::Lib)
+ message (Git::Object::Commit)
+ new (Git::Object)
+ new (Git::Remote)
+ new (Git::Diff)
+ new (Git::Object::Tree)
+ new (Git::Lib)
+ new (Git::Object::Blob)
+ new (Git::Object::Tag)
+ new (Git::Object::AbstractObject)
+ new (Git::Branches)
new (Git::Status::StatusFile)
- new (Git::Branches)
- new (Git::Diff)
- new (Git::Base)
new (Git::Log)
- new (Git::Object::AbstractObject)
- new (Git::Diff::DiffFile)
- new (Git::Object)
- new (Git::Branch)
- new (Git::Lib)
+ new (Git::Base)
+ new (Git::Diff::DiffFile)
+ new (Git::Author)
new (Git::Status)
- new (Git::Path)
- new (Git::Remote)
+ new (Git::Path)
+ new (Git::Branch)
object (Git::Log)
- object (Git::Base)
- object_contents (Git::Lib)
- object_size (Git::Lib)
- object_type (Git::Lib)
+ object (Git::Base)
+ object_contents (Git::Lib)
+ object_size (Git::Lib)
+ object_type (Git::Lib)
open (Git)
- open (Git::Base)
- patch (Git::Diff)
- path (Git::Diff)
+ open (Git::Base)
+ parent (Git::Object::Commit)
+ parents (Git::Object::Commit)
+ patch (Git::Diff)
path (Git::Log)
+ path (Git::Diff)
pretty (Git::Status)
- pull (Git::Base)
- push (Git::Base)
- push (Git::Lib)
- readable? (Git::Path)
- remote (Git::Branches)
- remote (Git::Base)
- remote_add (Git::Lib)
- remote_remove (Git::Lib)
- remotes (Git::Base)
- remotes (Git::Lib)
- remove (Git::Lib)
- remove (Git::Remote)
- remove (Git::Base)
- remove (Git::Remote)
- repack (Git::Lib)
- repack (Git::Base)
- repo (Git::Base)
- repo_size (Git::Base)
- reset (Git::Base)
- reset (Git::Lib)
- reset_hard (Git::Base)
- revparse (Git::Lib)
- revparse (Git::Base)
- setup (Git::Object::Tag)
- setup (Git::Object::Commit)
- setup (Git::Object::Blob)
- setup (Git::Object::AbstractObject)
- setup (Git::Object::Tree)
+ pull (Git::Base)
+ push (Git::Lib)
+ push (Git::Base)
+ readable? (Git::Path)
+ remote (Git::Base)
+ remote (Git::Branches)
+ remote_add (Git::Lib)
+ remote_remove (Git::Lib)
+ remotes (Git::Base)
+ remotes (Git::Lib)
+ remove (Git::Base)
+ remove (Git::Lib)
+ remove (Git::Remote)
+ remove (Git::Remote)
+ repack (Git::Base)
+ repack (Git::Lib)
+ repo (Git::Base)
+ repo_size (Git::Base)
+ reset (Git::Lib)
+ reset (Git::Base)
+ reset_hard (Git::Base)
+ revparse (Git::Lib)
+ revparse (Git::Base)
+ setup (Git::Object::AbstractObject)
since (Git::Log)
+ size (Git::Diff)
+ size (Git::Branches)
size (Git::Log)
- size (Git::Branches)
- size (Git::Diff)
- stats (Git::Diff)
- status (Git::Base)
- tag (Git::Base)
- tag (Git::Lib)
- tag_sha (Git::Lib)
- tags (Git::Lib)
- tags (Git::Base)
- to_a (Git::Branch)
- to_s (Git::Diff)
- to_s (Git::Branch)
- to_s (Git::Object::AbstractObject)
+ stats (Git::Diff)
+ status (Git::Base)
+ subdirectories (Git::Object::Tree)
+ subtrees (Git::Object::Tree)
+ tag (Git::Lib)
+ tag (Git::Base)
+ tag_sha (Git::Lib)
+ tags (Git::Lib)
+ tags (Git::Base)
+ to_a (Git::Branch)
to_s (Git::Log)
- to_s (Git::Remote)
+ to_s (Git::Diff)
+ to_s (Git::Branch)
+ to_s (Git::Object::AbstractObject)
+ to_s (Git::Remote)
+ trees (Git::Object::Tree)
untracked (Git::Status)
- writable? (Git::Path)
+ writable? (Git::Path)
diff --git a/lib/git.rb b/lib/git.rb index 7dfbd40..b1d55af 100644 --- a/lib/git.rb +++ b/lib/git.rb @@ -23,22 +23,68 @@ require 'git/diff' require 'git/status' require 'git/author' +# Git/Ruby Library +# +# This provides bindings for working with git in complex +# interactions, including branching and merging, object +# inspection and manipulation, history, patch generation +# and more. You should be able to do most fundamental git +# operations with this library. +# +# This module provides the basic functions to open a git +# reference to work with. You can open a working directory, +# open a bare repository, initialize a new repo or clone an +# existing remote repository. +# +# Author:: Scott Chacon (mailto:schacon@gmail.com) +# License:: MIT License module Git VERSION = '1.0.2' + # open a bare repository + # + # this takes the path to a bare git repo + # it expects not to be able to use a working directory + # so you can't checkout stuff, commit things, etc. + # but you can do most read operations def self.bare(git_dir) Base.bare(git_dir) end + # open an existing git working directory + # + # this will most likely be the most common way to create + # a git reference, referring to a working directory. + # if not provided in the options, the library will assume + # your git_dir and index are in the default place (.git/, .git/index) + # + # options + # :repository => '/path/to/alt_git_dir' + # :index => '/path/to/alt_index_file' def self.open(working_dir, options = {}) Base.open(working_dir, options) end + # initialize a new git repository, defaults to the current working directory + # + # options + # :repository => '/path/to/alt_git_dir' + # :index => '/path/to/alt_index_file' def self.init(working_dir = '.', options = {}) Base.init(working_dir, options) end + # clones a remote repository + # + # options + # :bare => true (does a bare clone) + # :repository => '/path/to/alt_git_dir' + # :index => '/path/to/alt_index_file' + # + # example + # Git.clone('git://repo.or.cz/rubygit.git', 'clone.git', :bare => true) + # def self.clone(repository, name, options = {}) Base.clone(repository, name, options) end diff --git a/lib/git/base.rb b/lib/git/base.rb index 21578f8..e7eaf22 100644 --- a/lib/git/base.rb +++ b/lib/git/base.rb @@ -72,24 +72,40 @@ module Git end + # returns a reference to the working directory + # @git.dir.path + # @git.dir.writeable? def dir @working_directory end + # returns reference to the git repository directory + # @git.dir.path def repo @repository end + # returns reference to the git index file def index @index end + # changes current working directory for a block + # to the git working directory + # + # example + # @git.chdir do + # # write files + # @git.add + # @git.commit('message') + # end def chdir Dir.chdir(dir.path) do yield dir.path end end + # returns the repository size in bytes def repo_size size = 0 Dir.chdir(repo.path) do @@ -117,6 +133,14 @@ module Git # factory methods + # returns a Git::Object of the appropriate type + # you can also call @git.gtree('tree'), but that's + # just for readability. If you call @git.gtree('HEAD') it will + # still return a Git::Object::Commit object. + # + # @git.object calls a factory method that will run a rev-parse + # on the objectish and determine the type of the object and return + # an appropriate object for that type def object(objectish) Git::Object.new(self, objectish) end @@ -124,36 +148,62 @@ module Git alias_method :gcommit, :object alias_method :gblob, :object - + # returns a Git::Log object with count commits def log(count = 30) Git::Log.new(self, count) end + # returns a Git::Status object def status Git::Status.new(self) end + # returns a Git::Branches object of all the Git::Branch objects for this repo def branches Git::Branches.new(self) end + # returns a Git::Branch object for branch_name def branch(branch_name = 'master') Git::Branch.new(self, branch_name) end + # returns a Git::Remote object def remote(remote_name = 'origin') Git::Remote.new(self, remote_name) end - + # this is a convenience method for accessing the class that wraps all the + # actual 'git' forked system calls. At some point I hope to replace the Git::Lib + # class with one that uses native methods or libgit C bindings def lib Git::Lib.new(self) end + # will run a grep for 'string' on the HEAD of the git repository + # + # to be more surgical in your grep, you can call grep() off a specific + # git object. for example: + # + # @git.object("v2.3").grep('TODO') + # + # in any case, it returns a hash of arrays of the type: + # hsh[tree-ish] = [[line_no, match], [line_no, match2]] + # hsh[tree-ish] = [[line_no, match], [line_no, match2]] + # + # so you might use it like this: + # + # @git.grep("TODO").each do |sha, arr| + # puts "in blob #{sha}:" + # arr.each do |match| + # puts "\t line #{match[0]}: '#{match[1]}'" + # end + # end def grep(string) self.object('HEAD').grep(string) end + # returns a Git::Diff object def diff(objectish = 'HEAD', obj2 = nil) Git::Diff.new(self, objectish, obj2) end @@ -163,53 +213,80 @@ module Git self.lib.add(path) end + # removes file(s) from the git repository def remove(path = '.', opts = {}) self.lib.remove(path, opts) end + # resets the working directory to the provided commitish def reset(commitish = nil, opts = {}) self.lib.reset(commitish, opts) end + # resets the working directory to the commitish with '--hard' def reset_hard(commitish = nil, opts = {}) opts = {:hard => true}.merge(opts) self.lib.reset(commitish, opts) end + # commits all pending changes in the index file to the git repository def commit(message, opts = {}) self.lib.commit(message, opts) end + # commits all pending changes in the index file to the git repository, + # but automatically adds all modified files without having to explicitly + # calling @git.add() on them. def commit_all(message, opts = {}) opts = {:add_all => true}.merge(opts) self.lib.commit(message, opts) end + # checks out a branch as the new git working directory def checkout(branch = 'master', opts = {}) self.lib.checkout(branch, opts) end + # fetches changes from a remote branch - this does not modify the working directory, + # it just gets the changes from the remote if there are any def fetch(remote = 'origin') self.lib.fetch(remote) end + # pushes changes to a remote repository - easiest if this is a cloned repository, + # otherwise you may have to run something like this first to setup the push parameters: + # + # @git.config('remote.remote-name.push', 'refs/heads/master:refs/heads/master') + # def push(remote = 'origin', branch = 'master') self.lib.push(remote, branch) end + # merges one or more branches into the current working branch + # + # you can specify more than one branch to merge by passing an array of branches def merge(branch, message = 'merge') self.lib.merge(branch, message) end + # fetches a branch from a remote and merges it into the current working branch def pull(remote = 'origin', branch = 'master', message = 'origin pull') fetch(remote) merge(branch, message) end + # returns an array of Git:Remote objects def remotes self.lib.remotes.map { |r| Git::Remote.new(self, r) } end - + + # adds a new remote to this repository + # url can be a git url or a Git::Base object if it's a local reference + # + # @git.add_remote('scotts_git', 'git://repo.or.cz/rubygit.git') + # @git.fetch('scotts_git') + # @git.merge('scotts_git/master') + # def add_remote(name, url, opts = {}) if url.is_a?(Git::Base) url = url.repo.path @@ -218,29 +295,38 @@ module Git Git::Remote.new(self, name) end + # returns an array of all Git::Tag objects for this repository def tags self.lib.tags.map { |r| tag(r) } end + # returns a Git::Tag object def tag(tag_name) Git::Object.new(self, tag_name, true) end + # creates a new git tag (Git::Tag) def add_tag(tag_name) self.lib.tag(tag_name) tag(tag_name) end - # convenience methods - + # repacks the repository def repack self.lib.repack end + # runs git rev-parse to convert the objectish to a full sha + # + # @git.revparse("HEAD^^") + # @git.revparse('v2.4^{tree}') + # @git.revparse('v2.4:/doc/index.html') + # def revparse(objectish) self.lib.revparse(objectish) end + # returns the name of the branch the working directory is currently on def current_branch self.lib.branch_current end diff --git a/lib/git/object.rb b/lib/git/object.rb index 4886f09..7702811 100644 --- a/lib/git/object.rb +++ b/lib/git/object.rb @@ -3,6 +3,7 @@ module Git class GitTagNameDoesNotExist< StandardError end + # represents a git object class Object class AbstractObject @@ -57,9 +58,11 @@ module Git @mode = mode end - def setup - @type = 'blob' - end + private + + def setup + @type = 'blob' + end end class Tree < AbstractObject @@ -72,10 +75,6 @@ module Git @mode = mode end - def setup - @type = 'tree' - end - def children blobs.merge(subtrees) end @@ -92,9 +91,13 @@ module Git end alias_method :subtrees, :trees alias_method :subdirectories, :trees - + private + def setup + @type = 'tree' + end + # actually run the git command def check_tree if !@trees @@ -116,10 +119,6 @@ module Git @committer = nil @message = nil - def setup - @type = 'commit' - end - def message check_commit @message @@ -164,9 +163,13 @@ module Git def diff_parent diff(parent) end - + private + def setup + @type = 'commit' + end + # see if this object has been initialized and do so if not def check_commit if !@tree @@ -189,9 +192,12 @@ module Git @name = name end - def setup - @type = 'tag' - end + private + + def setup + @type = 'tag' + end + end class << self -- cgit