summaryrefslogtreecommitdiffstats
path: root/lib/git
diff options
context:
space:
mode:
authorScott Chacon <schacon@gmail.com>2008-03-23 13:32:52 -0700
committerScott Chacon <schacon@gmail.com>2008-03-23 13:32:52 -0700
commitae106e2a3569e5ea874852c613ed060d8e232109 (patch)
treedd6879ca27f80243564787f5d3a43b4901fb3cea /lib/git
parent6c4af60f5fc5193b956a4698b604ad96ef3c51c6 (diff)
downloadthird_party-ruby-git-ae106e2a3569e5ea874852c613ed060d8e232109.tar.gz
third_party-ruby-git-ae106e2a3569e5ea874852c613ed060d8e232109.tar.xz
third_party-ruby-git-ae106e2a3569e5ea874852c613ed060d8e232109.zip
bug fixes
Diffstat (limited to 'lib/git')
-rw-r--r--lib/git/lib.rb31
1 files changed, 15 insertions, 16 deletions
diff --git a/lib/git/lib.rb b/lib/git/lib.rb
index c9c46e0..55191fe 100644
--- a/lib/git/lib.rb
+++ b/lib/git/lib.rb
@@ -181,7 +181,11 @@ module Git
data
end
-
+
+ def mv(file1, file2)
+ command_lines('mv', [file1, file2])
+ end
+
def full_tree(sha)
command_lines('ls-tree', ['-r', sha.to_s])
end
@@ -190,29 +194,24 @@ module Git
full_tree(sha).size
end
+ def change_head_branch(branch_name)
+ command('symbolic-ref', ['HEAD', "refs/heads/#{branch_name}"])
+ end
+
def branches_all
- head = File.read(File.join(@git_dir, 'HEAD'))
arr = []
-
- if m = /ref: refs\/heads\/(.*)/.match(head)
- current = m[1]
+ command_lines('branch', '-a').each do |b|
+ current = false
+ current = true if b[0, 2] == '* '
+ arr << [b.gsub('* ', '').strip, current]
end
- arr += list_files('heads').map { |f| [f, f == current] }
- arr += list_files('remotes').map { |f| [f, false] }
-
- #command_lines('branch', '-a').each do |b|
- # current = false
- # current = true if b[0, 2] == '* '
- # arr << [b.gsub('* ', '').strip, current]
- #end
-
arr
end
def list_files(ref_dir)
dir = File.join(@git_dir, 'refs', ref_dir)
- files = nil
- Dir.chdir(dir) { files = Dir.glob('**/*').select { |f| File.file?(f) } }
+ files = []
+ Dir.chdir(dir) { files = Dir.glob('**/*').select { |f| File.file?(f) } } rescue nil
files
end