Permalink
Browse files

Use $TMPDIR instead of /tmp

The latter is shared between all users and as this bundle use hardcoded paths (e.g. ‘output.diff’) there could be a conflict if two users on the same system both use the Git bundle.
  • Loading branch information...
sorbits committed Jan 22, 2013
1 parent 426b154 commit cf0529e832d0278fb757ef1840155389ac335180
@@ -47,7 +47,7 @@ if left==right
end
filename = "git-conflict-resolve"
-tmp_path = "/tmp/git-conflict-resolve/"
+tmp_path = "#{ENV['TMPDIR']}/git-conflict-resolve/"
FileUtils.rm_rf(tmp_path)
FileUtils.mkdir_p(tmp_path)
@@ -62,9 +62,10 @@ def compare_revisions
protected
def open_in_tm_link
- File.unlink('/tmp/output.diff') if File.exist? '/tmp/output.diff'
+ tmp_file = "#{ENV['TMPDIR']}/output.diff"
+ File.unlink(tmp_file) if File.exist? tmp_file
puts <<-EOF
- <a style='float:right' href='txmt://open?url=file://#{e_url '/tmp/output.diff'}'>Open diff in TextMate</a>
+ <a style='float:right' href='txmt://open?url=file://#{e_url tmp_file}'>Open diff in TextMate</a>
EOF
end
@@ -9,7 +9,7 @@
puts "\000 #{file_path}asdf"
when "revert"
file_path = ARGV.shift
- File.open("/tmp/output", "wb") {|f| f.puts ARGV.inspect}
+ File.open("#{ENV['TMPDIR']}/output", "wb") {|f| f.puts ARGV.inspect}
git.revert(file_path)
puts "\000 #{file_path}"
end
View
@@ -283,7 +283,7 @@ def fetch(remote, callbacks = {})
end
def show_to_tmp_file(fullpath, revision)
- temp_name = '/tmp/' + human_readable_mktemp(fullpath, revision)
+ temp_name = "#{ENV['TMPDIR']}/" + human_readable_mktemp(fullpath, revision)
File.open(temp_name, "w") {|f| f.puts show(fullpath, revision) }
temp_name
end
@@ -363,7 +363,7 @@ def diff(options = {})
end
output = command(*params)
- File.open("/tmp/output.diff", "a") {|f| f.puts check + output }
+ File.open("#{ENV['TMPDIR']}/output.diff", "a") {|f| f.puts check + output }
parse_diff(output)
end
@@ -4,7 +4,7 @@ module StreamProgressMethods
def each_line_from_stream(stream, &block)
line = ""
- f = File.open("/tmp/output", "wb")
+ f = File.open("#{ENV['TMPDIR']}/output", "wb")
stream.each_byte do |char|
f.putc(char)
char = [char].pack('c')

0 comments on commit cf0529e

Please sign in to comment.