<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -1,34 +1,3 @@
-= Gash, Git meets Hash
-Modify a Git-repo without touching the working-directory
-  
-  gash = Gash.new(&quot;master&quot;, &quot;.git&quot;)
-  gash[&quot;README&quot;]           # =&gt; This file
-  gash[&quot;lib/gash.rb&quot;]      # =&gt; That file
-  gash[&quot;lib&quot;][&quot;gash.rb&quot;]   # =&gt; Another way
-  gash / &quot;lib&quot; / &quot;gash.rb&quot; # =&gt; Yet another way
-  
-  gash[&quot;test&quot;] = &quot;Just a little demo&quot;
-  gash.changed?         # =&gt; true
-  gash[&quot;test&quot;].changed? # =&gt; true
-  gash[&quot;lib&quot;].changed?  # =&gt; false
-  gash.commit(&quot;Playing with Gash&quot;)
-  gash.changed?         # =&gt; false
-  
-  gash[&quot;lib&quot;].sha1     # =&gt; SHA1 to tree
-  gash[&quot;lib&quot;].mode     # =&gt; &quot;040000&quot;
-  gash[&quot;README&quot;].sha1  # =&gt; SHA1 to blob
-  gash[&quot;README&quot;].mode  # =&gt; &quot;100644&quot;
-  
-  git = Gash.new(&quot;master&quot;, &quot;../git/.git&quot;)  # Really big repo
-  # Lazy loading, so the above command is really quick
-  r = git[&quot;README&quot;, true] # =&gt; Don't load the blob yet
-  r.sha1   # =&gt; not yet...
-  r.mode   # =&gt; not yet...
-  r.upcase # =&gt; there it will!
-  # Load explict with r.load!
+= Gash, Git + Hash
 
-= Warning!
-This is a really alpha, so don't blame me for destroying your repo.
- 
-= Thanks!
-This would be impossible without siebertm's git-shelve...
+Please see http://dojo.rubyforge.org/gash or the documentation in lib/gash.rb!</diff>
      <filename>README</filename>
    </modified>
    <modified>
      <diff>@@ -1,25 +1,82 @@
 require 'delegate'
 
+# == What is Gash?
+#
+# * Gash lets you access a Git-repo as a Hash.
+# * Gash only cares about the data, not the commits.
+# * Gash only cares about the _latest_ data.
+# * Gash can commit.
+# * Gash doesn't touch your working directory
+# * Gash will automatically create branches if they don't exists.
+# * Gash only loads what it needs, so it handles large repos well.
+#
+# == How do you use it?
+#
+#   gash = Gash.new
+#   gash[&quot;README&quot;] = &quot;new content&quot;
+#   gash.commit(&quot;Some changes...&quot;)
+#
+# It's also important to remember that a Gash is simply a Tree, so you can
+# also call those methods.
+#
+# &lt;strong&gt;See also&lt;/strong&gt;: #new, #commit, Tree
+#
+# == Limitation
+#
+# The only Hash-like features which currently works is #[] and #[]=,
+# so don't try #merge or something like that.
 class Gash &lt; SimpleDelegator
+  module Errors
+    # This error is raised when the Git-command fails.
+    class Git &lt; StandardError; end
+  end
+  
+  # Some common methods used by both Tree and Blob.
   module Helpers
     attr_accessor :sha1, :mode, :parent
     
+    # Sets the accessors using a Hash:
+    #
+    #   tree = Gash::Tree.new(:sha1 =&gt; &quot;some thing&quot;, :mode =&gt; &quot;some thing&quot;,
+    #                         :parent =&gt; &quot;some parent&quot;)
+    #   tree.sha1 == &quot;some thing&quot;
+    #   tree.mode == &quot;some thing&quot;
+    #   tree.parent == &quot;some parent&quot;
     def initialize(opts = {})
       opts.each do |key, value|
         send(&quot;#{key}=&quot;, value)
       end
     end
     
-    def blob?;    self.class == Gash::Blob; end
-    def tree?;    self.class == Gash::Tree; end
-    def changed?; !@sha1;                   end
+    # Checks if this is a Blob.
+    def blob?; self.class == Gash::Blob end
+    # Checks if this is a Tree.
+    def tree?; self.class == Gash::Tree end
+    # Checks if this object has been changed (since last commit).
+    def changed?; !@sha1 end
+    # Mark this, and all parents as changed.
     def changed!; @sha1 = nil;parent.changed! end
-    def gash;     parent.gash;              end
+    # Returns the Gash-object (top-parent).
+    def gash; parent.gash end
   end
   
+  # A Tree is a Hash which can store other instances of Tree and Blob.
+  #
+  # &lt;strong&gt;See also&lt;/strong&gt;: Helpers, Blob
   class Tree &lt; Hash
     include Helpers
     
+    # Retrieves the _value_ stored as +key+:
+    #
+    #   tree[&quot;FILE&quot;] == the file
+    #   tree[&quot;DIR/FILE&quot;] == tree[&quot;DIR&quot;][&quot;FILE&quot;] = another file
+    #
+    # It will automatically call the +load!+-method in order to load
+    # it from the repo. Set +lazy+ to +true+ if this is not what you want:
+    #
+    #   blob = tree[&quot;FILE&quot;, true] == #&lt;Blob:1234...&gt;
+    #   # do some other stuff...
+    #   blob.laod! # Load it now!
     def [](key, lazy = nil)
       ret = if key.include?(&quot;/&quot;)
         key, rest = key.split(&quot;/&quot;, 2)
@@ -34,12 +91,30 @@ class Gash &lt; SimpleDelegator
     end
     alias / []
     
-    def []=(*a)
-      case a.length
-      when 3
-        key, keep_sha1, value = [*a]
-      when 2
-        key, value = [*a]
+    # Stores the given _value_:
+    #
+    #   tree[&quot;FILE&quot;] = &quot;Content&quot;
+    #
+    # Unless it's already a Tree or a Blob, it will be converted to a Blob,
+    # and the parent will _always_ be set to +self+.
+    #
+    #   tree[&quot;FILE&quot;] = &quot;Content&quot;
+    #     # is the same as:
+    #   tree[&quot;FILE&quot;] = Gash::Blob.new(:content =&gt; &quot;Content&quot;, :parent =&gt; tree)
+    #
+    # It will also mark the object as changed (using &lt;code&gt;Helpers#changed!&lt;/code&gt;).
+    # Set +not_changed+ to +true+ if this is not what you want.
+    # 
+    # (If you give it three arguments, then the second one will act as
+    # +not_changed+, not the third):
+    #
+    #   tree[&quot;FILE&quot;, true] = &quot;Test&quot;
+    #   tree[&quot;FILE&quot;].changed? # =&gt; false
+    def []=(key, value, not_changed = nil)
+      key, value, not_changed = if not_changed.nil?
+        [key, value]
+      else
+        [key, not_changed, value]
       end
       
       if key.include?(&quot;/&quot;)
@@ -48,7 +123,7 @@ class Gash &lt; SimpleDelegator
         keys.inject(self) do |memo, i|
           memo[i] = Tree.new(:parent =&gt; self) unless memo.include?(i)
           memo[i, true]
-        end[name, keep_sha1] = value
+        end[name, not_changed] = value
       else
         value = case value
         when Tree, Blob
@@ -60,45 +135,73 @@ class Gash &lt; SimpleDelegator
         super(key, value)
       end
     ensure
-      self.changed! unless keep_sha1
+      self.changed! unless not_changed
     end
   end
   
+  # A Blob represent a string:
+  #
+  #   blob = Gash::Blob.new(:content =&gt; &quot;Some content&quot;)
+  #   blob # =&gt; &quot;Some content&quot;
+  #
+  # == Using SHA1
+  #
+  # However, if you provide a SHA1 (and have a parent which is connected to
+  # a Gash-object) it will then load the content from the repo when needed:
+  #
+  #   blob = Gash::Blob.new(:sha1 =&gt; &quot;1234&quot; * 10, :parent =&gt; gash_OR_tree_connected_to_gash)
+  #   blob        # =&gt; #&lt;Blob:1234123412341234123412341234123412341234&gt;
+  #   blob.upcase # It's loaded when needed
+  #   #blob.load! # or forced with #load!
+  #   blob        # =&gt; &quot;Content of the blob&quot;
+  #
+  # Tree#[]= automatically sets the parent to itself, so you don't need to
+  # provide it then:
+  #
+  #   tree[&quot;FILE&quot;] = Gash::Blob.new(:sha1 =&gt; a_sha1)
+  #
+  # &lt;strong&gt;See also&lt;/strong&gt;: Helpers, Tree
   class Blob &lt; Delegator
     include Helpers
     attr_accessor :content
     
-    def inspect
-      @content ? @content.inspect : (@sha1 ? &quot;#&lt;Blob:#{@sha1}&gt;&quot; : to_s.inspect) 
-    end
-    
+    # Loads the file from Git, unless it's already been loaded.
     def load!
       @content ||= gash.send(:cat_file, @sha1)
     end
     
-    def __getobj__
+    def inspect #:nodoc:
+      @content ? @content.inspect : (@sha1 ? &quot;#&lt;Blob:#{@sha1}&gt;&quot; : to_s.inspect) 
+    end
+    
+    def __getobj__ #:nodoc:
       @content ||= @sha1 ? load! : ''
     end
-    alias to_s __getobj__
+    alias_method :to_s, :__getobj__
   end
   
   attr_accessor :branch, :repository
   
-  def initialize(branch, repo = &quot;.&quot;)
+  # Opens the +repo+ with the specified +branch+.
+  #
+  # &lt;strong&gt;Please note:&lt;/strong&gt; The +repo+ must link to the actual repo,
+  # not the working directory!
+  def initialize(branch = &quot;master&quot;, repo = &quot;.git&quot;)
     @branch = branch
     @repository = File.expand_path(repo)
     __setobj__(Tree.new(:parent =&gt; self))
     update!
   end
   
-  def gash
+  def gash #:nodoc:
     self
   end
   
-  def changed!
+  def changed! #:nodoc:
     @sha1 = nil
   end
   
+  # Fetch the latest data from Git; you can use this as a +clear+-method.
   def update!
     clear
     self.sha1 = git_tree_sha1
@@ -127,6 +230,9 @@ class Gash &lt; SimpleDelegator
     self
   end
   
+  # Commit the current changes and returns the commit-hash.
+  #
+  # Returns +nil+ if nothing has changed.
   def commit(msg)
     return unless changed?
     commit = commit_tree(to_tree!, msg)
@@ -134,14 +240,15 @@ class Gash &lt; SimpleDelegator
     commit
   end
   
+  # Checks if the current branch exists
   def branch_exists?
     git('rev-parse', @branch, '2&gt;&amp;1')
     true
-  rescue GitError
+  rescue Errors::Git
     false
   end
   
-  def inspect
+  def inspect #:nodoc:
     __getobj__.inspect
   end
   
@@ -187,13 +294,13 @@ class Gash &lt; SimpleDelegator
     git('ls-tree', '-r', '-t', @branch, '2&gt;&amp;1') do |f|
       f.each_line(&amp;blk)
     end
-  rescue GitError
+  rescue Errors::Git
     &quot;&quot;
   end
   
   def git_tree_sha1(from = @branch)
     git('rev-parse', @branch + '^{tree}', '2&gt;&amp;1')
-  rescue GitError
+  rescue Errors::Git
   end
   
   def method_missing(meth, *args, &amp;blk)
@@ -215,7 +322,7 @@ class Gash &lt; SimpleDelegator
   # :strip&lt;Boolean&gt;:: true to strip the output String#strip, false not to to it
   #
   # ==== Raises
-  # GitError:: if git returns non-null, an Exception is raised
+  # Errors::Git:: if git returns non-null, an Exception is raised
   #
   # ==== Returns
   # String:: if you didn't supply a block, the things git said on STDOUT, otherwise noting
@@ -223,7 +330,7 @@ class Gash &lt; SimpleDelegator
     result, status = run_git(cmd, *rest, &amp;block)
 
     if status != 0
-      raise GitError.new(&quot;Error: #{cmd} returned #{status}. Result: #{result}&quot;)
+      raise Errors::Git.new(&quot;Error: #{cmd} returned #{status}. Result: #{result}&quot;)
     end
     result
   end
@@ -253,7 +360,7 @@ class Gash &lt; SimpleDelegator
   # :strip&lt;Boolean&gt;:: true to strip the output String#strip, false not to to it
   #
   # ==== Raises
-  # GitError:: if git returns non-null, an Exception is raised
+  # Errors::Git:: if git returns non-null, an Exception is raised
   #
   # ==== Returns
   # Array[String, Integer]:: the first item is the STDOUT of git, the second is the return-status
@@ -291,7 +398,4 @@ class Gash &lt; SimpleDelegator
 
     [result, status]
   end
-  
-  class GitError &lt; StandardError
-  end
 end
\ No newline at end of file</diff>
      <filename>lib/gash.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>97375947ed5295aa38dedabbd4dcab30c0b82da0</id>
    </parent>
  </parents>
  <author>
    <name>Magnus Holm</name>
    <email>judofyr@gmail.com</email>
  </author>
  <url>http://github.com/judofyr/gash/commit/cab460d38b354282348e9923dc33ed5c1c1228cf</url>
  <id>cab460d38b354282348e9923dc33ed5c1c1228cf</id>
  <committed-date>2008-09-04T12:12:16-07:00</committed-date>
  <authored-date>2008-09-04T12:12:16-07:00</authored-date>
  <message>Adding documentation + some refactoring</message>
  <tree>341edd3002f00d9bd611e08e07984ac7999baf47</tree>
  <committer>
    <name>Magnus Holm</name>
    <email>judofyr@gmail.com</email>
  </committer>
</commit>
