diff options
author | scott Chacon <schacon@agadorsparticus.(none)> | 2007-11-16 11:23:24 -0800 |
---|---|---|
committer | scott Chacon <schacon@agadorsparticus.(none)> | 2007-11-16 11:23:24 -0800 |
commit | de071dcd8dee3d853291a5077b9dcdec07dd5362 (patch) | |
tree | bd335c0a79ed4da9fc4c05b2f44542a03a2d3b5d /lib/git/lib.rb | |
parent | 3687e45effe8ad433da31712149b424d46effe64 (diff) | |
download | third_party-ruby-git-de071dcd8dee3d853291a5077b9dcdec07dd5362.tar.gz third_party-ruby-git-de071dcd8dee3d853291a5077b9dcdec07dd5362.tar.xz third_party-ruby-git-de071dcd8dee3d853291a5077b9dcdec07dd5362.zip |
added some low level tree operations and tests
Diffstat (limited to 'lib/git/lib.rb')
-rw-r--r-- | lib/git/lib.rb | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/lib/git/lib.rb b/lib/git/lib.rb index c196312..690043d 100644 --- a/lib/git/lib.rb +++ b/lib/git/lib.rb @@ -350,6 +350,32 @@ module Git command('repack', ['-a', '-d']) end + # reads a tree into the current index file + def read_tree(treeish, opts = {}) + arr_opts = [] + arr_opts << "--prefix=#{opts[:prefix]}" if opts[:prefix] + arr_opts << treeish.to_a.join(' ') + command('read-tree', arr_opts) + end + + def write_tree + command('write-tree') + end + + def commit_tree(tree, opts = {}) + opts[:message] = "commit tree #{tree}" if !opts[:message] + t = Tempfile.new('commit-message') do |t| + t.write(opts[:message]) + end + + arr_opts = [] + arr_opts << tree + arr_opts << "-p #{opts[:parent]}" if opts[:parent] + opts[:parents].each { |p| arr_opts << "-p #{p.to_s}" } if opts[:parents] + arr_opts << "< #{t.path}" + command('commit-tree', arr_opts) + end + # creates an archive file # # options |