summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lib/git/base.rb6
-rw-r--r--lib/git/branch.rb4
-rw-r--r--lib/git/lib.rb5
-rw-r--r--tests/units/test_tree_ops.rb9
4 files changed, 23 insertions, 1 deletions
diff --git a/lib/git/base.rb b/lib/git/base.rb
index 6372beb..4c5cdf5 100644
--- a/lib/git/base.rb
+++ b/lib/git/base.rb
@@ -6,6 +6,8 @@ module Git
@repository = nil
@index = nil
+ @lib = nil
+
# opens a bare Git Repository - no working directory options
def self.bare(git_dir)
self.new :repository => git_dir
@@ -376,6 +378,10 @@ module Git
commit_tree(tree, opts)
end
+ def update_ref(branch, commit)
+ branch(branch).update_ref(commit)
+ end
+
def ls_files
self.lib.ls_files
end
diff --git a/lib/git/branch.rb b/lib/git/branch.rb
index f9106ab..c2ce810 100644
--- a/lib/git/branch.rb
+++ b/lib/git/branch.rb
@@ -75,6 +75,10 @@ module Git
end
end
+ def update_ref(commit)
+ @base.lib.update_ref(@full, commit)
+ end
+
def to_a
[@full]
end
diff --git a/lib/git/lib.rb b/lib/git/lib.rb
index 690043d..7742702 100644
--- a/lib/git/lib.rb
+++ b/lib/git/lib.rb
@@ -376,6 +376,11 @@ module Git
command('commit-tree', arr_opts)
end
+ def update_ref(branch, commit)
+ command('update-ref', [branch.to_s, commit.to_s])
+ end
+
+
# creates an archive file
#
# options
diff --git a/tests/units/test_tree_ops.rb b/tests/units/test_tree_ops.rb
index 7dba642..f8e771a 100644
--- a/tests/units/test_tree_ops.rb
+++ b/tests/units/test_tree_ops.rb
@@ -95,8 +95,15 @@ class TestTreeOps < Test::Unit::TestCase
assert(index['b3/test-file3'])
g.commit('hi')
end
-
assert(c.commit?)
+
+ files = g.ls_files
+ assert(!files['b1/example.txt'])
+
+ g.branch('newbranch').update_ref(c)
+ g.checkout('newbranch')
+ assert(!files['b1/example.txt'])
+
assert_equal('b40f7a9072cdec637725700668f8fdebe39e6d38', c.gtree.sha)
end