use a temp GIT_INDEX_FILE when working with the real git index (during reverts)

This commit is contained in:
rick
2010-12-08 15:17:18 -08:00
parent 057baac3ce
commit 074b2119fa
2 changed files with 13 additions and 3 deletions
+11 -1
View File
@@ -557,10 +557,20 @@ module Gollum
end
def write_to_real_index(head_sha)
old_index = ENV['GIT_INDEX_FILE']
temp_index = @repo.git.create_tempfile('index', :clean)
ENV['GIT_INDEX_FILE'] = temp_index
@repo.git.native('read-tree', {}, head_sha)
if yield
@repo.git.native('write-tree')
tree_sha = @repo.git.native('write-tree')
after_index = ENV['GIT_INDEX_FILE']
if after_index != temp_index
raise 'environment was changed for the git call'
end
tree_sha
end
ensure
ENV['GIT_INDEX_FILE'] = old_index
end
def full_diff_for(page, sha1, sha2 = nil)
+2 -2
View File
@@ -30,8 +30,8 @@ end
def commit_details
{ :message => "Did something at #{Time.now}",
:name => "Tom Preston-Werner",
:email => "tom@github.com" }
:name => "Tom Preston-Werner",
:email => "tom@github.com" }
end
# test/spec/mini 3