Closed
Description
Subject of the issue
Using g.show(":my_file.txt")
to see the file as it is returns a string missing the last newline.
Your environment
git: git version 2.28.0
ruby-git: 1.7.0
ruby: ruby 2.6.6p146 (2020-03-31 revision 67876) [x86_64-linux]
Steps to reproduce
require "git"
puts Git::VERSION
Dir.mktmpdir("git_auto_fixup_test") do |root|
g = Git.init(root)
g.commit("Initial commit", allow_empty: true)
File.write("#{root}/my_file.txt", "hello\nworld\n")
g.add("my_file.txt")
puts "From gem: #{g.show(":my_file.txt").inspect}"
puts "From git: #{`git -C #{root} show :my_file.txt`.inspect}"
end
Note that only 1 newline is removed. If I put more than one at the end, ruby-git will return one less.
Actual behaviour
1.7.0
From gem: "hello\nworld"
From git: "hello\nworld\n"
Expected behaviour
1.7.0
From gem: "hello\nworld\n"
From git: "hello\nworld\n"
Metadata
Metadata
Assignees
Labels
No labels