summaryrefslogtreecommitdiffstats
path: root/lib/git/status.rb
diff options
context:
space:
mode:
authorscott Chacon <schacon@agadorsparticus.(none)>2007-11-11 10:43:27 -0800
committerscott Chacon <schacon@agadorsparticus.(none)>2007-11-11 10:43:27 -0800
commita4fa110279ea28873fe1e4df10c89ddc591046b4 (patch)
tree60e08ccf8caca2fe428dee76c06c102cc54bc98b /lib/git/status.rb
parenta1237671ba3ec38f5b123ee6600e4352dc03196b (diff)
downloadthird_party-ruby-git-a4fa110279ea28873fe1e4df10c89ddc591046b4.tar.gz
third_party-ruby-git-a4fa110279ea28873fe1e4df10c89ddc591046b4.tar.xz
third_party-ruby-git-a4fa110279ea28873fe1e4df10c89ddc591046b4.zip
added the commit(), changed base.commit, base.tree, base.blob to gcommit, gtree, gblob
Diffstat (limited to 'lib/git/status.rb')
-rw-r--r--lib/git/status.rb23
1 files changed, 17 insertions, 6 deletions
diff --git a/lib/git/status.rb b/lib/git/status.rb
index 24fd98d..f738644 100644
--- a/lib/git/status.rb
+++ b/lib/git/status.rb
@@ -27,8 +27,8 @@ module Git
out = ''
self.each do |file|
out << file.path
- out << "\n\tsha(r) " + file.sha_repo.to_s
- out << "\n\tsha(i) " + file.sha_index.to_s
+ out << "\n\tsha(r) " + file.sha_repo.to_s + ' ' + file.mode_repo.to_s
+ out << "\n\tsha(i) " + file.sha_index.to_s + ' ' + file.mode_index.to_s
out << "\n\ttype " + file.type.to_s
out << "\n\tstage " + file.stage.to_s
out << "\n\tuntrac " + file.untracked.to_s
@@ -55,7 +55,10 @@ module Git
attr_accessor :mode_index, :mode_repo
attr_accessor :sha_index, :sha_repo
- def initialize(hash)
+ @base = nil
+
+ def initialize(base, hash)
+ @base = base
@path = hash[:path]
@type = hash[:type]
@stage = hash[:stage]
@@ -66,6 +69,14 @@ module Git
@untracked = hash[:untracked]
end
+ def blob(type = :index)
+ if type == :repo
+ @base.object(@sha_repo)
+ else
+ @base.object(@sha_index) rescue @base.object(@sha_repo)
+ end
+ end
+
end
@@ -85,16 +96,16 @@ module Git
# find modified in tree
@base.lib.diff_files.each do |path, data|
- @files[path].merge!(data)
+ @files[path] ? @files[path].merge!(data) : @files[path] = data
end
# find added but not committed - new files
@base.lib.diff_index('HEAD').each do |path, data|
- @files[path].merge!(data)
+ @files[path] ? @files[path].merge!(data) : @files[path] = data
end
@files.each do |k, file_hash|
- @files[k] = StatusFile.new(file_hash)
+ @files[k] = StatusFile.new(@base, file_hash)
end
end