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 --- doc/classes/Git/Base.html | 734 ++++++++++++++++++++++++++++------------------ 1 file changed, 452 insertions(+), 282 deletions(-) (limited to 'doc/classes/Git/Base.html') 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
-- 
cgit